home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-01-08 | 2.5 KB | 91 lines |
- ' *-------------------------------------------*
- ' | |
- ' | This is some sample code to show how |
- ' | to get the date and time from within |
- ' | Amos. Written in version 1.23. |
- ' | By Tony Domigan & Evan Thomas. |
- ' | |
- ' *-------------------------------------------*
- '
- ' First allocate 12 bytes of storage and get its address. I think the
- ' storage has to be word aligned, but I'm not sure. In any case the
- ' following code makes the address word aligned (AMOS string variables
- ' are always half word aligned).
- '
- DATE$=Space$(14)
- DATE=Varptr(DATE$)
- DATE=DATE+(DATE mod 4)
- '
- ' Some mundane stuff.
- Curs Off
- Dim MONTH$(12)
- For M=1 To 12
- Read MONTH$(M)
- Next M
- Data "January","February","March","April","May","June","July"
- Data "August","September","October","November","December"
- '
- ' Load the address into data registor one and call the Amiga DOS date
- ' function. This is described in "Amiga System Programmer's Guide" by
- ' Dittrich, Gelfand & Schemmel, published by Abacus and no doubt in
- ' many places as well.
- '
- Do
- Dreg(1)=DATE
- R=Doscall(-192)
- '
- ' After the call the data is in the string DATE$. The format is:
- ' word 1 = days since 1/1/1978
- ' word 2 = minutes
- ' word 3 = sixtieths of a second elapsed in the minute
- '
- DAYS=Leek(DATE) : Rem 4 byte day value
- MS=Leek(DATE+4) : Rem 4 byte minute value
- TICK=Leek(DATE+8) : Rem 4 byte sixtieths of a second value
- '
- ' date-time conversion routine
- ' modified from C source [Programmer's Guide to Amiga (Peck) p42]
- '
- N=DAYS-2251
- Y=(4*N+3)/1461
- NN=N-(1461*Y)/4
- YY=Y+1984
- M=(5*NN+2)/153
- D=NN-(153*M+2)/5+1
- MM=M+3
- '
- ' MM=months
- ' MN=minutes
- ' SECS=seconds
- ' TICK=sixtieths of a second in the minute
- '
- If MM>12
- Inc YY
- MM=MM-12
- End If
- HR=Int(MS/60)
- MN=MS-(HR*60)
- SECS=TICK/60
- '
- ' Format and output.
- '
- Locate 8,12
- Print Using "##";D;
- Print " ";MONTH$(MM);YY;
- Locate 21,12
- Print Using "###";HR;
- Locate 24,12
- If MN<10
- Print ":0"; Using "#";MN;
- Else
- Print ":"; Using "##";MN;
- End If
- Locate 27,12
- If SECS<10
- Print ":0"; Using "#";SECS
- Else
- Print ":"; Using "##";SECS
- End If
- '
- Multi Wait
- Loop