Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!pasteur!agate!eris!doug From: doug@eris (Doug Merritt) Newsgroups: comp.sys.amiga.tech Subject: Re: Idea Message-ID: <9289@agate.BERKELEY.EDU> Date: 27 Apr 88 09:09:15 GMT References: <8804231647.AA09390@jade.berkeley.edu> <5809@well.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: doug@eris.UUCP (Doug Merritt) Organization: University of California, Berkeley Lines: 74 Summary: Software clock; also problem with Prog. Guide to the Amiga >In article <8804231647.AA09390@jade.berkeley.edu> SLMYQ@USU.BITNET writes: >>The T.O.D. (Time Of Day) clocks in the 8520s on the Amiga aren't used, right? In article <5809@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes: > I had this same idea about a year ago, and wrote a quickie program to >discover if it would work. As it turns out, hitting Ctrl-A-A asserts >RESET, and RESET resets the 8520's Time-Of-Day clock. Personally, I think How about if you add a keyboard reset handler that grabs the TOD and saves it somewhere...say in an unused part of the boot block (forget it!) or touches a df0: file (better) or a vd0: file (better yet)? 'Course, it makes the 8520 part of the idea useless, but I've been meaning to mention for a long time now that I wrote a sort of cron job that updates a vd0: file with the current time every thirty seconds, and my startup-sequence sets the time/date from that. Makes a very, very nice substitute for a true clock...the time is always *approximately* correct, whereas it's *always* wrong otherwise. Sure helps with 'make'! Anyone interested? I never posted it because I felt like it was sort of kludgy (both the concept, and also that I'm not sure if it works correctly if you reboot right around midnight on Dec 31, but didn't care enough to check...It works, I'm busy). But upon consideration, anyone without a real time clock should use *something* like this. Better than nothing! Perhaps better yet would be to use the "cron" that's been floating around; haven't tried it yet myself. * * * >P.S: This was how I found out that there's no CloseResource() call in the >system. So what am I supposed to do with something that I've OpenResource()d? Hmmm...Wasn't this part of the (ancient) general discussion about "How come there's a call for OpenXXXXX() but no CloseXXXXX() ???" Answer being, no need, other than esthetics. CATS will probably answer this momentarily anyway. * * * Speaking of kludges regarding the date, sorry for the miniflame, but: both Peck (the book's author) and Rokicki (who wrote this particular piece of code) should be *ashamed* to have released a piece of code like ShowDate() on page 42 of the Programmer's Guide to the Amiga. I thought it was a publisher's misprint at first, it was so full of magic meaningless constants. The algorithm is *totally* opaque, despite the fact that I understand the USUAL approaches to date algorithms, including the the one for calculating the day of the week that any day in history falls on, in your head. So I tried to prove it didn't work. Well, I was wrong, it does work (as far as I could tell). I even started to get an idea of why before I gave it up as a waste of time. Considering the usual fine quality of work I've seen both of them do, this kind of dreck (in a "How To" book at that!) is both surprising and disappointing. Some #defines and some comments, at *minimum*, are mandatory for something as obscure as this. See, for instance, The Elements of Programming Style (Kernighan & Plauger). I hope it'll be fixed (or at least deleted) in the second edition. If it's too much trouble to hack something minor like that, I'd be happy to donate code to a perfectly clear (although possibly less efficient, as if that matters) version of ShowDate(). I wrote it for my cron-date program, since I didn't trust the one in the book. (Hence my flame; it says a lot if it's more reliable to cook something up from scratch than to copy a few lines from a book.) BTW I loved the rest of the book, and I very much appreciate all of the work that both Tom and Bob have done for the Amiga world. (Don't want you thinking I'm ungrateful!) Doug Merritt doug@mica.berkeley.edu (ucbvax!mica!doug) or ucbvax!unisoft!certes!doug or sun.com!cup.portal.com!doug-merritt