Rpbasic-52 programming guide, Time – Remote Processing BASIC 52 User Manual
Page 132

RPBASIC-52 PROGRAMMING GUIDE
2-113
TIME
(function)
Syntax:
A = TIME(n)
Where: n = 0 to 4
0 = hours
1 = minutes
2 = seconds
3 = hundredths of a second
4 = seconds since midnight
Function:
Returns the hour, minute, second, or hundredths of a second from the real time clock
Mode:
Comm and, Run
Use:
A=TIM E(1)
Returns minutes
Cards:
All
D E S C R IP T I ON
A DS1216DM must be installed in the data RAM socket, usually U5. Refer to your hardware manual for
exac t locati on. Th e num erical value of the h our, m inute, o r secon d is retu rned.
TIME(4) returns the seconds plus hundredths of a second since midnight. This is useful when time stamping
an eve nt.
A HAR DWA RE error is returned when the RTC module is missing or bad. Use ONERR to trap for this kind
of error. Error code is 50 at address 101H
RELATED
TIME (comm and)
ERRORS
BAD ARGUMENT When n out of range, negative
H A R D W A R E
RTC m odule missing
EXAMPLE
The following program converts a TIME number into a string.
100 STRING 200,20
110 $(0) = " : : " :REM SETUP FOR HH:MM:SS
120 HR = TIME(0)
130 MN = TIME(1)
140 SC = TIME(2)
150 T = HR/10 :REM use T for temporaries
160 ASC($(0),1) = INT(T) .OR.48
:REM 10's of hours
170 ASC($(0),2) = (T-INT(T))*10) .OR. 48
:REM 1's
180 T = MN/10 :REM minutes conversion
190 ASC($(0),4) = INT(T) .OR. 48
200 ASC($(0),5) = ((T-INT(T)) * 10) .OR. 48
210 T = SC/10 :REM temp for seconds
220 ASC($(0),7) = INT(T) .OR. 48
230 ASC($(0),8) = ((T-INT(T)) * 10) .OR. 48
240 PRINT "Time:",$(0)