I used the instruction RealTime for get the time of the CR1000 in an array rTime(9) as long. Then I use formatLong for I have each rTime() with always two digits, I mean complete with zeros (right justified).
Like rTime(1)=20, rTime(2)=03, rTime(3)=29, rTime(4)=04....
Like you see with two digits, complete with zeros.
But when I see in the public it shows: rTime(1)=20, rTime(2)=3, rTime(3)=29, rTime(4)=4. With no zeros.
This is a part of program
Public rTime(9) As Long
Beginprog
SlowSequence
Scan (5,Min,0,0)
RealTime (rTime)
For a=1 To 9
rTime(a)= FormatLong(rTime(a),"%02d")
Next a
Nextscan
EndProg
To preserve leading zeroes, the destination variable needs to be a string data type.
Public rTime(9) As Long public TimeOutput(9) as String Beginprog SlowSequence Scan (5,Min,0,0) RealTime (rTime) For a=1 To 9 TimeOutput(a)= FormatLong(rTime(a),"%02d") Next a Nextscan EndProg
SprintF() is really handy in formatting the results of RealTime() into strings.
Dim rTime(9) As Long Alias rTime(1) = Year,Month,DayOfMonth,Hour,Minute,Second,uSecond,DayOfWeek,DayofYear Public tString1 As String * 32 Public tString2 As String * 32 Public tString3 As String * 32 Public tString4 As String * 32 BeginProg Scan (1,Sec,0,0) RealTime (rTime) '2020-04-11_17-03-43 Sprintf (tString1,"%04d-%02d-%02d_%02d-%02d-%02d",Year,Month,DayOfMonth,Hour,Minute,Second) '20200411170355 Sprintf (tString2,"%04d%02d%02d%02d%02d%02d",Year,Month,DayOfMonth,Hour,Minute,Second) '04/11/20 Sprintf (tString3,"%02d/%02d/%02d",Month,DayOfMonth,CTYPE(FRAC(Year/100)*100,Long)) '2020-04-11 17:04:19 Sprintf (tString4,"%04d-%02d-%02d %02d:%02d:%02d%",Year,Month,DayOfMonth,Hour,Minute,Second) NextScan EndProg