by Alan Neeley


The ability to stamp the date on files being stored in a computer is a very useful feature. It provides the user with a method of going back and determining when a file was created or the last time it was edited. The latest versions of TDOS have this feature (besides keeping track of the DATE and TIME when the file was created, TDOS also keeps track of when it was last accessed). The ADAM's EOS also has date stamping capabilities. Most ADAM owners know little about them or how they can be made use of. This article is for those readers who want to learn more about date stamping and how it can be made use of in the EOS.

Even though the provisions for EOS date stamping have always been there, Coleco never took advantage of them in their programs. Any application program that makes use of the EOS file saving routines in a conventional manner could take advantage of this feature if only a method of setting the current date had been provided. Coleco could have easily introduced a program that would allow for setting the current date (or SYSTEM DATE) and then boot any other application program - but they didn't.

There are a couple of commercial programs available that can provide the function of setting the system date and then booting another program. AJM's Hard Disk program can do this and so can Trisyd Video Game's SmartClock software. It takes a program such as FILEMANAGER (another AJM product) in order to read the date that has been stamped in each file entry.

Each file stored in a standard EOS environment has a 21 byte entry in the EOS directory. The last three bytes of each entry is reserved for date stamping purposes (for more information on this type of directory, see my article on the ADAM EOS directory presented way back in issue #2 of this publication). There is also a 3 byte address reserved In EOS memory used specifically for date stamping. The three addresses are 64992, 64993, and 64994. The EOS file saving routines are designed to take the data found in the reserved addresses and insert them into the last three bytes of the current file entry being stored in the directory.

EOS date stamping is rather limited (especially compared to the date stamping features offered through TDOS). There are only 3 bytes reserved to store the information to. This allows room for only the day, month, and year to be stamped Into a file entry.

The way the date is arranged in the three reserved bytes in memory is not critical. The programmer/user could start with the month in the first byte, the day in the second, and the year in the third, or any other pattern that they desire. Another thing that must be decided is which base system should be used to represent the date info: hexadecimal or decimal. AJM's hard disk and Filemanager programs use a hexadecimal format with the year in the first byte, the month in the second, and the day in the third.


SmartBASIC can take advantage of EOS date stamping with the help of a couple of BASIC programs (or the commercial programs previously mentioned). Any file that is created using the SAVE or BSAVE commands will have the current system date added to its file entry in the directory. Unfortunately, The OS commands used to create sequential or random access files in basic will not have the system date stamped in their file entry (See the SmartBASIC WorkSHOP on Random Access files in Issue #17 for an idea on how the date can be stamped on these kind of files).

Before starting to make a BASIC program to take advantage of the EOS date stamping features, the programmer must decide what type of format they are going to use. The program I've put together for this workshop will use the same format used by the AJM programs in order to keep things standardized.

Being that SmartBASIC works under the decimal number system, some routines are needed for converting back and forth between the hexadecimal and decimal number systems. The following two small programs demonstrate how this is done.

10 HOME:INPUT "Enter a number from 0-255:"; cn
15 IF cn<0 OR ce>255 THEN ? "Sorry, only 0-255":END
20 GOSUB 100
25 ? cn$
30 END
100 x$="0123456789ABCDEF"
105 cn$=MID$(x$, INT(cn/16)+1, 1)+MID$(x$, (cn/16-INT(cn/16))*16+1, 1):RETURN

10 HOME:INPUT 'Enter Hexadecimal number 00-FF:'; cm$
15 GOSUB 100
20 ? cn
20 END
100 IF LEN((cn$))=2 THEN h$=LEFT$((cn$), 1): l$=RIGHT$((cn$), 1):GOTO 200
105 ? "Sorry only 00-FF":RETURN
200 a$=h$:GOSUB 300: h=a*16
205 a$=1$:GOSUB 300: 1=a
210 cn=h+1:RETURN
300 IF a$="A" OR a$="a" THEN a=10:RETURN
305 IF a$="B" OR a$="b" THEN a=11:RETURN
310 IF a$="C" OR a$="c" THEN a=12:RETURN
315 IF a$="D" OR a$="d" THEN a=13:RETURN
320 IF a$="E" OR a$="e" THEN a=14:RETURN
325 IF a$="F" OR a$="f" THEN a=15:RETURN
330 a=VAL(a$):RETURN

Now let's take the routines we have above and work it into a program that will set and read the system date. This program is simple yet it provides a great example of how to make use of date stamping in SmartBASIC. Try modifying the program to your own liking. A nice addition would be to add the capability of having a hardware clock set the System Date automatically.

6 REM Written By Alan Neeley
10 POKE 16149, 255:POKE 16150, 255
100 HOME
110 VTAB 5:HTAB 5
115 ? "1 - SET SYSTEM DATE"
125 HTAB 5:? "3 - END PROGRAM"
130 GET a$
135 IF VAL(a$)<1 OR VAL(a$)>3 THEN 130
140 IF VAL(a$)=1 THEN 200
145 IF VAL(a$)=2 THEN 300
150 IF VAL(a$)=3 THEN END
200 HOME
210 HTAB 5:VTAB 5:INPUT "Enter year:"; cn$
215 GOSUB 600: y=cn
220 HTAB 5:INPUT "Enter month:"; cn$
225 GOSUB 600: m=cn
230 HTAB 5:INPUT "Enter day:"; cn$
235 GOSUB 600: d=cn
240 POKE 64992, y:POKE 64993, m:POKE 64994, d
245 GOTO 100
300 HOME
310 cn=PEEK(64992):GOSUB 500: y$=cn$
315 cn=PEEK(64993):GOSUB 500: m$=cn$
320 cn=PEEK(64994):GOSUB 500: d$=cn$
325 HTAB 8:VTAB 5:? m$; "/"; d$; "/"; y$
330 ?:HTAB 5:? "PRESS ANY KEY"
335GET a$:GOTO 100
500 x$="0123456789ABCDEF"
505 cn$=MID$(x$, INT(cn/16)+1, 1)+MID$(x$, (cn/16-INT(cn/16))*16+1, 1):RETURN
605 IF VAL(cn$)<10 THEN cn=VAL(cn$):RETURN
610 cn=VAL(LEFT$(cn$, 1))*16+VAL(RIGHT$(cn$, 1)):RETURN

The program requires that you enter only the last two numbers for the year (91 not 1991) and that numbers be used to represent the month (2 not FEBRUARY).

One thing the above program listing does not do is read the date that is actually stamped to each file entry In the directory. It would take a considerable amount of programming to accomplish this feat. I will try to work on it and possibly will include it in a future issue. For now, I would recommend using a program such as FILEMANAGER for reading the dates in each file entry.

From the Jan-Jul 1991 issue of The ADAM Informant, SmartBASIC Workshop (Intermediate Programming Level), p. 9-10. OCRed and spellchecked by Scott Gordon. Republished with permission by The ADAM Resource.

Back to Top