Hi,
I need to make a string containing the date of the current scan like this : "name_image_controle_YYYY_MM_DD_HH_MM.jpg".
I use the RealTime instruction to get the scan date and then I concatenate the rtime values (code below). The problem is that I obtain for example :
"name_image_controle_2017_1_8_10_20.jpg"
but what I want to obtain is :
"name_image_controle_2017_01_08_10_20.jpg"
Is there a way to convert an integer into a string of 2 characters in CRBasic? If not, have you got another idea for doing this ?
Thank you for your help,
Yoann
My code :
'##### Variables #####
Public rTime(9) 'declare as public and dimension rTime to 9
Alias rTime(1) = Year 'assign the alias Year to rTime(1)
Alias rTime(2) = Month 'assign the alias Month to rTime(2)
Alias rTime(3) = DOM 'assign the alias DOM to rTime(3)
Alias rTime(4) = Hour 'assign the alias Hour to rTime(4)
Alias rTime(5) = Minute 'assign the alias Minute to rTime(5)
Alias rTime(6) = Second 'assign the alias Second to rTime(6)
Alias rTime(7) = uSecond 'assign the alias uSecond to rTime(7)
Alias rTime(8) = WeekDay 'assign the alias WeekDay to rTime(8)
Alias rTime(9) = Day_of_Year 'assign the alias Day_of_Year to rTime(9)
Public name_image_controle as string * 40
'##### Data Table #####
DataTable(Test,True,-1)
Sample (1, name_image_controle, String)
EndTable
'##### Main Prog #####
beginProg
Scan(1,min,0,0)
realtime(rTime)
name_image_controle = "image_controle_+"_"+Year+"_"+Month+"_"+DOM+"_"+Hour+"_"+Minute+".jpg"
CallTable(Test)
NextScan
EndProg
I use FormatFloat.
Time$ = FormatFloat (Hour,"%02.0f") + ":" + FormatFloat (Minute,"%02.0f") + ":" + FormatFloat (Second,"%02.0f")
It works fine !
Thank you for your help IslandMan.
Yoann