[comp.sys.apple] Reading IIgs clock

scott@geowhiz.UUCP (Scott Kempf) (08/13/87)

     Some people have wanted to know how to read the //gs clock from
BASIC.  The only "correct" way to read the //gs clock is by using one
of two //gs tools. They are both in the Miscellaneous Tool set (#3) and
are functions number 13 and 15.  ReadTimeHex and ReadASCIITime
respectively.  The following is a short BASIC program that pokes a
machine language program into memory.  The machine language program is
used to call ReadASCIITime.  The ASCII time is stored at address
00/0200 which is the text buffer (safe for temporary use) in the format
selected from the control panel.  The time has been moved to 00/0200
the BASIC program must more it byte by byte into a variable (T$).  The
machine language program is completely relocatable, if you don't have
page 3 free.

Just execute this and it will save itself:

--------------------------------< Cut Here >---------------------------------
NEW
10A=768
20REMThe variable A can be any address where there are 20 free bytes.
100FORI=ATOA+19
110READX:POKEI,X
120NEXT
130DATA24,251,194,48,244,0,0,244,0,2,162,3,15,34,0,0,225,56, 251,96
200HOME
210GOSUB10000
220PRINT"It is now ";T$
230END
999STOP
10000REMThis routine calls the tool ReadASCIITime
10010CALLA
10100T$=""
10110FORI=512TO531
10120T$=T$+CHR$(PEEK(I))
10130NEXT
10140RETURN
SAVEREAD.CLOCK.DEMO

--------------------------------< Cut Here >---------------------------------

Scott Kempf      uwvax!geowhiz!scott      (The only address I know will work.)

p.s.  Is APW a figment of my imagination?  I haven't written Apple, yet.
      I thought asking by news would be faster.  Was I wrong?