Variable assignment critical error

Discuss RoboTask here
Post Reply
BrianSmith
Posts: 46
Joined: Tue Apr 27, 2004 7:50 pm

Variable assignment critical error

Post by BrianSmith »

I have created a FileLoop action and assigned the modified time of each file in the loop to a variable CURRENT_DATETIME.

Outside the loop I create a variable LATEST_DATETIME = 01/01/1890 12:00:00 that gets set inside the loop to the CURRENT_DATETIME variable only if the CURRENT_DATETIME variable is greater then the LATEST_DATETIME variable.

This task is to find the latest/newest file in a folder by the way.

When the If statement is true I "Set Variable" LATEST_DATETIME = "{CURRENT_DATETIME}"
This works the first time the If statement is true which in most cases will always be the first file, but after that each time the FileLoop grabs another file and sets the CURRENT_DATETIME, LATEST_DATETIME automatically gets set to the value of CURRENT_DATETIME as the If statement has assigned the LATEST_DATETIME variable to be {CURRENT_DATETIME} as a string.

This causes the If statement to never execute again and the LATEST_DATETIME variable to always take on the CURRENT_DATETIME of the current file so I end up with the LATEST_DATETIME variable holding the modified date of the last file in the folder.

How do I stop the variable assignment of LATEST_DATETIME from taking on the string "{CURRENT_DATETIME}" and not just the date/time value of this variable.

I have included the RoboTask for you to test.

;********************
; RoboTask Task file
; Do not edit!
;********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|802282160
ExternalName=STRING|"Task7"
Hide=INTEGER|0
ID=INTEGER|782740870
Name=STRING|"Find the latest/newest modified file in a folder."
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create variable ""LATEST_DATETIME"" with value ""01/01/1890 12:00:00"""
Params=FOLDER

[Actions\Action1\Params]
varname=STRING|"LATEST_DATETIME"
varvalue=STRING|"01/01/1890 12:00:00"

[Actions\Action10]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action11]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""The latest file is ({LATEST_FILENAME}) modified {LATEST_DATETIME}."""
Params=FOLDER

[Actions\Action11\Params]
icon=STRING|"1"
msg0=STRING|"The latest file is ({LATEST_FILENAME}) modified {LATEST_DATETIME}."
msg2=STRING|"You can now add another action to this task to copy this file wherever you like."
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action2\Params]
createmode=STRING|"1"
date1=STRING|"20040520"
date2=STRING|"20040520"
destvar=STRING|"CURRENT_FILENAME"
DuringDays=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{TEMPDIR}\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"1"
timevar=STRING|"CURRENT_DATETIME"
WithoutPath=STRING|"1"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action3\Params]
message=STRING|"{CURRENT_DATETIME}"
type=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action4\Params]
message=STRING|"{LATEST_DATETIME}"
type=STRING|"0"

[Actions\Action5]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
operator=STRING|"3"
type=STRING|"2"
value1=STRING|"{CURRENT_DATETIME}"
value2=STRING|"{LATEST_DATETIME}"

[Actions\Action6]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action6\Params]
message=STRING|"CURRENT_DATETIME {CURRENT_DATETIME} > LATEST_DATETIME {LATEST_DATETIME}"
type=STRING|"0"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""LATEST_FILENAME"" with value ""{CURRENT_FILENAME}"""
Params=FOLDER

[Actions\Action7\Params]
varname=STRING|"LATEST_FILENAME"
varvalue=STRING|"{CURRENT_FILENAME}"

[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""LATEST_DATETIME"" with value ""{CURRENT_DATETIME}"""
Params=FOLDER

[Actions\Action8\Params]
varname=STRING|"LATEST_DATETIME"
varvalue=STRING|"{CURRENT_DATETIME}"

[Actions\Action9]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Last edited by BrianSmith on Thu May 20, 2004 10:14 am, edited 1 time in total.
AlexeySurkis
Posts: 51
Joined: Wed Oct 01, 2003 4:55 pm
Contact:

Variable assignment critical error

Post by AlexeySurkis »

In the Set Variable action, we've added the "Expand Variable Value" option. Please wait for the new version 2.1. Thank you for your patience.
Post Reply