function {DateTime}

Discuss RoboTask here
Post Reply
Helix78
Posts: 11
Joined: Tue May 27, 2014 9:17 am

function {DateTime}

Post by Helix78 »

I'd like to assign a timestamp to a variable in case of an event.
I do that with Set Variable LASTRUN = {DateTime}
Later in the task I want to display this stored timestamp in the log windows.
I do that with Log Message "Last file activity: {LASTRUN}"

My problem is that the {DateTime} got stored but it always displays the actual time in the log window.
I am not able to read the variable LASTRUN with the timestamp originally assigned.

Is this a bug or am I wrong :?:
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: function {DateTime}

Post by Oleg »

If you want to save variable value at this moment you should switch on parameter Expand Variable Value now
See on screenshot below:
expandnow.png
expandnow.png (17.01 KiB) Viewed 8647 times
Otherwise RoboTask calculates the value only when you use this variable.
See example below, which illustrates how this works:

Code: Select all

 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task373"
Hide=INTEGER|0
ID=INTEGER|1278625633
LogOnAsUser=INTEGER|1
Name=STRING|"DateTime illustration"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""NOEXPAND"" with value ""{DateTime}"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"NOEXPAND"
varvalue=STRING|"{DateTime}"

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""FORCEEXPAND"" with value ""{DateTime}"""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"FORCEEXPAND"
varvalue=STRING|"{DateTime}"

[Actions\Action3]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 5 sec"
Params=FOLDER

[Actions\Action3\Params]
delay=STRING|"5"
dimension=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{NoExpand}"""
Params=FOLDER

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"{NoExpand}"
msg1=STRING|"{ForceExpand}"
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Post Reply