home *** CD-ROM | disk | FTP | other *** search
- Comments on the TimeSet program...
-
- version 1.0 9/19/86 written in Lattice C v3.03b
-
- Length of compiled file TIMESET -- 20112 bytes
-
- TIMESET allows you to set the date and time on your Amiga using slider
- controls. I include it as part of my boot sequence (defined in
- <bootdisk>:s/startup-sequence):
-
- <commands>
- :timeset
- <commands>
-
- For this to work TIMESET must be in the root directory of your bootdisk. If
- you put it somewhere else you must tell AmigaDos how to find it; that's what
- the colon before TIMESET is doing.
-
- There are two source code files contained in the archive, DATE.C and TIMESET.C.
- In addition, a compiled and linked version of TIMESET is included.
-
- *** TIMESET calls certain functions defined in DATE, so if you will need to
- link the object files together in order to get a functional program. ***
-
- DATE is provided separately since I've found that the functions in it are
- useful in other situations. Also, it was easier to write the overall program
- by splitting it into smaller pieces!
-
- If you look at TIMESET.C you will no doubt notice that a number of the
- functions and variable definitions do not have to have the global scope they
- are given. Right you are! This is a vestige of an earlier approach I took in
- writing the program which I was too lazy to change. Of course, as I said
- above, having the separate functions does make (at least for me) it easier to
- design and write the overall program. In this instance I didn't think the loss
- in speed due to the function calls was worth the ability to fragment the
- program. If you feel differently, be my guest and change the source code.
-
- In two places in TIMESET.C I call sprintf() to build a formatted string. One
- part of that formatting is the need to display the current minute count as a
- two digit field with a leading zero. I first tried to do this as follows (I've
- simplified this fragment for clarity):
-
- sprintf("%.2d",Minute);
-
- This generated a 2 digit field, but with a leading blank. I then tried:
-
- sprintf("%2.2d",Minute);
-
- with the same result. Finally, I read the fine print in my C bible
- ("Programming in C", (c) 1983 by Stephen G. Kochan; I recommend it) and used:
-
- sprintf("%02d",Minute);
-
- which worked. Unfortunately, a footnote said (ibid, p. 287)
-
- "2 This modifier is no longer officially supported as of Release 3.0
- of UNIX and has been replaced with a new interpretation of the
- .precision modifier."
-
- The 'new interpretation' was not described. My Lattice documentation does not
- say one way or another whether what I did should work. It does as of v3.03b,
- but who can tell what the future holds?
-
- If worse comes to worse you could replace the sprintf() calls with numeric to
- string conversions, padders (i.e., add leading zero when necessary) and a slew
- of concatenations. Being lazy, I prefer the sprintf() route -- even though
- I've been warned by many more experience programmers that one should use the
- printf() and scanf() routines only as a last resort.
-
- Enjoy!!
-
- Mark Olbert
- aka ChairmanMAO