Array of integer

Discuss RoboTask here
Post Reply
Alex007
Posts: 3
Joined: Fri Mar 08, 2013 5:40 pm

Array of integer

Post by Alex007 »

Hi

Can somebody help me please
I am trying to create an array of integers and then use the increment function for each one of the array cells with loop, each time i am getting an error "not valid integer value" or "Illegal name of variable"

Thank you
Alex
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Array of integer

Post by Oleg »

Send your example please.
It seems you made a mistake, but I can say nothing without your task
Oleg Yershov
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Array of integer

Post by Oleg »

Generally an array is a comma-separated string, like this:
1,2,3,4,5,22,35,0,100

You can make indexed variables: MyVar1, Myvar2, etc.
See 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|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task53"
Hide=INTEGER|0
ID=INTEGER|1375023030
LogOnAsUser=INTEGER|1
Name=STRING|"Usage of Indexed Variables"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"CNT"

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

[Actions\Action2\Params]
begin=STRING|"1"
end=STRING|"5"
variable=STRING|"CNT"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""MYVAR{CNT}"" with value ""{cnt}"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"1"
varkind=STRING|"1"
varname=STRING|"MYVAR{CNT}"
varvalue=STRING|"{cnt}"

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

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""{MyVar1}"""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"{MyVar1}"
msg1=STRING|"{MyVar2}"
msg2=STRING|"{MyVar3}"
msg3=STRING|"{MyVar4}"
msg4=STRING|"{MyVar5}"
msgcount=STRING|"5"
playsound=STRING|"0"
showmessage=STRING|"1"

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

[Actions\Action6\Params]
begin=STRING|"1"
end=STRING|"5"
variable=STRING|"CNT"

[Actions\Action7]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Desktop Alert"
Params=FOLDER

[Actions\Action7\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"5"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"{MyVar{cnt}}"
position=STRING|"3"
title=STRING|"MyVar{cnt}"
width=STRING|"330"

[Actions\Action8]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg Yershov
Alex007
Posts: 3
Joined: Fri Mar 08, 2013 5:40 pm

Re: Array of integer

Post by Alex007 »

Thank you

I am attaching my task but basically I just trying to use "set variable function" for existing array of integers, and getting an error "Illegal name of variable" .

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|1
ExternalName=STRING|"Task6"
Hide=INTEGER|0
ID=INTEGER|422428419
LocalVariables=STRING|"I=0,J=0,L=0,""SITES_IP=10.50.125.14, 192.168.115.254, 10.50.200.6, 10.50.160.1, 10.50.160.10, 10.50.80.10, 192.168.102.254, 192.168.177.254, 10.50.80.126, 192.168.117.254, 10.50.119.97, 10.50.119.206, 192.168.104.254, 172.16.147.254, 192.168.106.1, 10.50.80.74, 10.50.80.78, 192.168.101.254, 192.168.103.254, 172.16.135.8"",""SITES_SWEEP=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"""
LogOnAsUser=INTEGER|1
Name=STRING|"Routers ping sweep test (imported)"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER

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

[Actions\Action1\Params]
begin=STRING|"0"
end=STRING|"19"

[Actions\Action2]
ActionID=STRING|"A_INET_PING"
Enabled=INTEGER|-1
Name=STRING|"Ping {SITES_IP({I})}"
Params=FOLDER

[Actions\Action2\Params]
default=STRING|"-1"
host=STRING|"{SITES_IP({I})}"
timeout=STRING|"300"
variable=STRING|"PING"

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

[Actions\Action3\Params]
case=STRING|"0"
operator=STRING|"5"
type=STRING|"1"
value1=STRING|"{PING}"
value2=STRING|"0"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""SITES_SWEEP({I})"" with value ""1"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varname=STRING|"SITES_SWEEP({I})"
varvalue=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action6]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""I"""
Params=FOLDER

[Actions\Action6\Params]
incement=STRING|"1"
vaiable=STRING|"I"

[Actions\Action7]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Array of integer

Post by Oleg »

Unfortunately you can't assign array element directly.
I recommend you to use indexed variables.
See my corrections below:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|2099193306
Comment=STRINGLIST
ContinueOnError=INTEGER|1
ExternalName=STRING|"Task253"
Hide=INTEGER|0
ID=INTEGER|422428419
LocalVariables=STRING|"I=0,J=0,L=0,""SITES_IP=10.50.125.14, 192.168.115.254, 10.50.200.6, 10.50.160.1, 10.50.160.10, 10.50.80.10, 192.168.102.254, 192.168.177.254, 10.50.80.126, 192.168.117.254, 10.50.119.97, 10.50.119.206, 192.168.104.254, 172.16.147.254, 192.168.106.1, 10.50.80.74, 10.50.80.78, 192.168.101.254, 192.168.103.254, 172.16.135.8"",txt"
LogOnAsUser=INTEGER|1
Name=STRING|"Routers ping sweep test"
OnErrorTaskID=INTEGER|0
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
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_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""PING"" with value """""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"PING"

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

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

[Actions\Action11\Params]
begin=STRING|"0"
end=STRING|"19"
variable=STRING|"I"

[Actions\Action12]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TXT"" with value ""{txt}{Sites_IP({i})} -> {Sites_Sweep_{i}}{eol}"""
Params=FOLDER

[Actions\Action12\Params]
expand=STRING|"1"
varname=STRING|"TXT"
varvalue=STRING|"{txt}{Sites_IP({i})} -> {Sites_Sweep_{i}}{eol}"

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

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

[Actions\Action14\Params]
icon=STRING|"1"
msg0=STRING|"{txt}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

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

[Actions\Action2\Params]
begin=STRING|"0"
end=STRING|"19"

[Actions\Action3]
ActionID=STRING|"A_INET_PING"
Enabled=INTEGER|-1
Name=STRING|"Ping {SITES_IP({I})}"
Params=FOLDER

[Actions\Action3\Params]
default=STRING|"-1"
host=STRING|"{SITES_IP({I})}"
timeout=STRING|"300"
variable=STRING|"PING"

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

[Actions\Action4\Params]
case=STRING|"0"
operator=STRING|"5"
type=STRING|"1"
value1=STRING|"{PING}"
value2=STRING|"0"

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

[Actions\Action5\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"SITES_SWEEP_{I}"
varvalue=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action7]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""SITES_SWEEP_{I}"" with value ""0"""
Params=FOLDER

[Actions\Action7\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"SITES_SWEEP_{I}"
varvalue=STRING|"0"

[Actions\Action8]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action9]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""I"""
Params=FOLDER

[Actions\Action9\Params]
incement=STRING|"1"
vaiable=STRING|"I"
Oleg Yershov
Alex007
Posts: 3
Joined: Fri Mar 08, 2013 5:40 pm

Re: Array of integer

Post by Alex007 »

Thank you
is that possible to add assign array element directly function in the future?

and thank you again, great software.
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Array of integer

Post by Oleg »

We'll discuss this, thank you
Oleg Yershov
Post Reply