File Loop Variable

Discuss RoboTask here
Post Reply
jkvandalen
Posts: 1
Joined: Tue Mar 05, 2019 12:15 am

File Loop Variable

Post by jkvandalen »

1st time user ... evaluating the product.

I'm creating a task that must login to FTP, go to a local directory and upload all file (i.e. *.csv).

Everything is working ok other than the File Loop.

The Loop is defined as:

Search for Files: {FROMDIRECTORY}\*.CSV
{FROMDIRECTORY} was setup previously
Assign Current Filename to Variable: {FILETOUPLOAD}

{FILETOUPLOAD} is not being set ... is always empty. I did wrote to a text file inside the loop and see the value for {FROMDIRECTORY} 4 times (there are 4 files in the directory) but the {FILETOUPLOAD} never gets set.

Any idea on what I'm doing wrong? Exported task attached

Thanks in advance.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: File Loop Variable

Post by Oleg »

Use FILETOUPLOAD (without braces) as name of variable

Like this - look at the example below

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|742360135
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task534"
Hide=INTEGER|0
ID=INTEGER|-432359209
LogOnAsUser=INTEGER|1
Name=STRING|"file loop example"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|2
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20190305"
date2=STRING|"20190305"
destvar=STRING|"FILE"
DuringDays=STRING|"1"
DuringHours=STRING|"1"
DuringMinutes=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"{TempDir}\*.*"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderHours=STRING|"1"
OlderMinutes=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
sort=STRING|"0"
sortby=STRING|"0"
sortorder=STRING|"0"
subdirs=STRING|"0"
timesize=STRING|"0"
WithoutPath=STRING|"0"

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

[Actions\Action2\Params]
message=STRING|"{file}"
type=STRING|"3"

[Actions\Action3]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

If you use variable in some expression you highlight the variable name. So you have to use braces "{}"
When you want to specify variable name to save some value - just specify the name only.

The problem is that you can specify a variable name using other variables in the expression. For example: MyVar{num}
Oleg Yershov
Post Reply