Page 1 of 1
While statement
Posted: Tue Jan 26, 2010 12:06 pm
by 218014437
This is probably an easy one for you techies, so it shouldnt take you too long to answer these questions. I am running a task that prompts the user for several inputs. If "ok" is clicked, then it moves along. I would like to be able to end the task when "cancel" is clicked at any of the various input screens. How do I accomplish this? I'm thinking the While statement but havent figured out how to properly use it. Please help.
While statement
Posted: Wed Jan 27, 2010 3:38 am
by Oleg
Look at the example below. Probably this is that you want
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1380072790
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task914"
Hide=INTEGER|0
ID=INTEGER|2083185850
LocalVariables=STRING|"lastinput"
LogOnAsUser=INTEGER|1
Name=STRING|"While loop test"
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
Action9=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""LASTINPUT"" with value """""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"LASTINPUT"
[Actions\Action2]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER
[Actions\Action2\Params]
case=STRING|"0"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{lastinput}"
value2=STRING|"none"
[Actions\Action3]
ActionID=STRING|"A_DIALOG_INPUTBOX"
Enabled=INTEGER|-1
Name=STRING|"Input Box"
Params=FOLDER
[Actions\Action3\Params]
default=STRING|"none"
password=STRING|"1"
prompt=STRING|"Input some value (cancel to stop)"
variable=STRING|"LASTINPUT"
[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action4\Params]
case=STRING|"0"
operator=STRING|"0"
type=STRING|"0"
value1=STRING|"{lastinput}"
value2=STRING|"none"
[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""cancel pressed..."""
Params=FOLDER
[Actions\Action5\Params]
icon=STRING|"0"
msg0=STRING|"cancel pressed..."
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action6]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"
[Actions\Action7]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action8]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""[{Time}, {DayOfWeek}, {Date}]"""
Params=FOLDER
[Actions\Action8\Params]
icon=STRING|"1"
msg0=STRING|"[{Time}, {DayOfWeek}, {Date}]"
msg1=STRING|"You have entered string ""{lastinput}"""
msgcount=STRING|"2"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action9]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
While statement
Posted: Mon Feb 01, 2010 8:54 am
by 218014437
Ok this gives me a better understanding on how to use the while statement. In your example though, it only contains one variable, therefore when cancel is pressed, lastinput will be defined as "none" and the program will stop. In my task, I have at least 50 user variables, does this mean I have to create a while statement for each input? Maybe I'm missing something with the task you sent me and it does encompass my entire task. I dont understand, please help.
While statement
Posted: Thu Feb 04, 2010 12:21 am
by Oleg
While loop must contain the comparison (like in "If..then" action). You can compare two values (first operand and second operand).
The loop is working while the comparison returns TRUE.
If comparison returns FALSE the loop terminates.