Setting multiple variables

Post comments and suggestions for RoboTask here

Setting multiple variables

Postby juanlu » Sun Aug 18, 2019 10:08 pm

Hi Oleg,

It would be great if we could set multiple variables using just one action. For example, we can this today with the Excel Get Cells, which is cool. Then, it would be great if the Set Variable action had the same feature of entering multiple variable names and its corresponding values.

As of today, if you need to set many variables (e.g. after using regex to read a csv file with many columns), you need to use as many Set Variable actions, which makes the task unnecessarily long and difficult to read.

Kind regards,
Juanlu.
juanlu
 
Posts: 32
Joined: Wed Jul 31, 2019 12:33 am

Re: Setting multiple variables

Postby Oleg » Mon Aug 19, 2019 10:40 am

look here how to set to indexed variables in the loop
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task318"
Hide=INTEGER|0
ID=INTEGER|2024929902
LogOnAsUser=INTEGER|1
Name=STRING|"set to multiple variables"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

[Actions\Action1]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//the source comma-separated string. any number of elements"
Params=FOLDER

[Actions\Action1\Params]
comment=STRING|"the source comma-separated string. any number of elements"

[Actions\Action10]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//output values"
Params=FOLDER

[Actions\Action10\Params]
comment=STRING|"output values"

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

[Actions\Action11\Params]
message=STRING|"Soutce = {Source}"
type=STRING|"3"

[Actions\Action12]
ActionID=STRING|"A_LOOP_SIMPLE"
Enabled=INTEGER|-1
Name=STRING|"Simple Loop"
Params=FOLDER

[Actions\Action12\Params]
begin=STRING|"1"
end=STRING|"{sz}"
variable=STRING|"NUM"

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

[Actions\Action13\Params]
message=STRING|"var{num} = {var{num}}"
type=STRING|"3"

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

[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""SOURCE"" with value """"1-st value"", ""2-nd value"", ""3-d value"", ""Hello world!!!"""""
Params=FOLDER

[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"SOURCE"
varvalue=STRING|"""1-st value"", ""2-nd value"", ""3-d value"", ""Hello world!!!"""

[Actions\Action3]
ActionID=STRING|"A_TXT_COOMATEXT"
Enabled=INTEGER|-1
Name=STRING|"Comma-separated string -> text"
Params=FOLDER

[Actions\Action3\Params]
kind=STRING|"0"
line00000000=STRING|"{source}"
lines=STRING|"1"
variable=STRING|"txt"

[Actions\Action4]
ActionID=STRING|"A_TXT_NUMBEROFLINES"
Enabled=INTEGER|-1
Name=STRING|"TXT Number of Lines"
Params=FOLDER

[Actions\Action4\Params]
external=STRING|"0"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
variable=STRING|"sz"

[Actions\Action5]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//set values in the loop"
Params=FOLDER

[Actions\Action5\Params]
comment=STRING|"set values in the loop"

[Actions\Action6]
ActionID=STRING|"A_LOOP_SIMPLE"
Enabled=INTEGER|-1
Name=STRING|"Simple Loop"
Params=FOLDER

[Actions\Action6\Params]
begin=STRING|"1"
end=STRING|"{sz}"
variable=STRING|"NUM"

[Actions\Action7]
ActionID=STRING|"A_TXT_EXTRACTLINE"
Enabled=INTEGER|-1
Name=STRING|"TXT Extract Line"
Params=FOLDER

[Actions\Action7\Params]
external=STRING|"0"
line00000000=STRING|"{txt}"
linecount=STRING|"1"
linenum=STRING|"{num}"
variable=STRING|"line"

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

[Actions\Action8\Params]
expand=STRING|"1"
varname=STRING|"VAR{NUM}"
varvalue=STRING|"{Line}"

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

Oleg Yershov
Oleg
Site Admin
 
Posts: 2668
Joined: Thu Jan 01, 1970 1:00 am

Re: Setting multiple variables

Postby juanlu » Tue Aug 20, 2019 12:19 pm

Thanks for your reply.

Your suggestion does not address my original request. I am not talking about setting an array variable, but multiple, different variables.

Think about the scenario where you have multiple global variables used in many different tasks, and one of these tasks is setting those variables. Obviously you don't want to be working with myArray(5) all over the place, but with its own variable that has an intuitive name.

For example, you have information about Employees (e.g. stores in a CSV or a DB). For sure you don't want to be working in multiple different tasks with variables such as Employee(1), Employee(2), Employee(3)... Employee(20), but rather Employee_ID, Employee_Name, Employee_Title, etc. This is something you can easily do today with the Excel Get Cell action today, just with 1 action. If you want to assign variables with Set Variables, you need 20 actions.
juanlu
 
Posts: 32
Joined: Wed Jul 31, 2019 12:33 am


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest

cron