I need help regarding adding a value to a variable.

Discuss RoboTask here
Post Reply
cacatnow
Posts: 10
Joined: Thu May 05, 2016 2:17 am

I need help regarding adding a value to a variable.

Post by cacatnow »

So first of all, is there a way to add value to a variable instead of replacing it? Lets say I have "game" variable and it contains 1.exe and 2.exe as values, how do I add 3.exe without replacing those two values?

Also how does the custom input dialog work? I am trying to do the above using it but if I input any value it just replaces the value to "{". Surely I am doing something wrong here.

Lastly will "wait for process" trigger work correctly if I put variable such as "game" which contains more than 1 value?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: I need help regarding adding a value to a variable.

Post by Oleg »

Lets say I have "game" variable and it contains 1.exe and 2.exe as values, how do I add 3.exe without replacing those two values?
Look at my example below. Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
Also you can simply copy task text and paste it into the task list.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1163085779
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task17"
Hide=INTEGER|0
ID=INTEGER|-2060714014
LogOnAsUser=INTEGER|1
Name=STRING|"add value to variable"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
expand=STRING|"0"
linecount=STRING|"2"
varkind=STRING|"1"
varname=STRING|"game"
varvalue=STRING|"1.exe"
varvalue00000001=STRING|"2.exe"

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

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

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

[Actions\Action3\Params]
expand=STRING|"1"
linecount=STRING|"2"
varname=STRING|"game"
varvalue=STRING|"{game}"
varvalue00000001=STRING|"3.exe"

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

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"{game}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"
Oleg Yershov
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: I need help regarding adding a value to a variable.

Post by Oleg »

Also how does the custom input dialog work? I am trying to do the above using it but if I input any value it just replaces the value to "{". Surely I am doing something wrong here.
Look next example below. It shows how it work

Code: Select all

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

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_CUSTOM_INPUT_DIALOG"
Enabled=INTEGER|-1
Name=STRING|"Custom Input Dialog"
Params=FOLDER

[Actions\Action1\Params]
dialog_caption=STRING|"Input Dialog"
dialog_height=STRING|"400"
dialog_width=STRING|"400"
field_count=STRING|"3"
field0=STRING|"{""type"":""CustomInputDialog"",""version"":""1.0"",""fieldGroups"":[{""caption"":""Field Properties"",""showCaption"":false,""fields"":[{""type"":""Simple Edit"",""labelText"":""Field Name:"",""name"":""name"",""value"":""TextEdit""},{""type"":""Simple Edit"",""labelText"":""Caption:"",""name"":""labelText"",""value"":""Enter someting:""},{""type"":""Simple Edit"",""labelText"":""Default Value:"",""name"":""value"",""value"":""""},{""type"":""Checkbox"",""labelText"":""Password Input"",""name"":""passwordInput"",""value"":false},{""type"":""Checkbox"",""labelText"":""Numbers only"",""name"":""numbersOnly"",""value"":false},{""type"":""Checkbox"",""labelText"":""Required"",""name"":""required"",""value"":false}]}],""className"":""Text Edit"",""fieldName"":""TextEdit""}"
field1=STRING|"{""type"":""CustomInputDialog"",""version"":""1.0"",""fieldGroups"":[{""caption"":""Field Properties"",""showCaption"":false,""fields"":[{""type"":""Simple Edit"",""labelText"":""Field Name:"",""name"":""name"",""value"":""CheckBox""},{""type"":""Simple Edit"",""labelText"":""Caption:"",""name"":""labelText"",""value"":""Check this if you want""},{""type"":""CheckBox"",""labelText"":""Default Value"",""name"":""value"",""value"":false}]}],""className"":""CheckBox"",""fieldName"":""CheckBox""}"
field2=STRING|"{""type"":""CustomInputDialog"",""version"":""1.0"",""fieldGroups"":[{""caption"":""Field Properties"",""showCaption"":false,""fields"":[{""type"":""Simple Edit"",""labelText"":""Field Name:"",""name"":""name"",""value"":""FileSelect""},{""type"":""Simple Edit"",""labelText"":""Caption:"",""name"":""labelText"",""value"":""Select a file if you need:""},{""type"":""File Select"",""labelText"":""Default Value:"",""name"":""value"",""value"":""""},{""type"":""Checkbox"",""labelText"":""Required"",""name"":""required"",""value"":false}]}],""className"":""File Select"",""fieldName"":""FileSelect""}"
grid_lines=STRING|"0"
label_column_width=STRING|"140"
save_to=STRING|"DialogResult"
stop_if_cancel=STRING|"1"
vertical_layout=STRING|"1"

[Actions\Action2]
ActionID=STRING|"A_DIALOG_SHOWTEXT"
Enabled=INTEGER|-1
Name=STRING|"Show Text"
Params=FOLDER

[Actions\Action2\Params]
autoclose=STRING|"0"
fromfile=STRING|"1"
line00000000=STRING|"Dialog result (raw value):"
line00000001=STRING|"{DialogResult}"
line00000003=STRING|"Text value: {json:DialogResult.TextEdit}"
line00000004=STRING|"Check box: {json:DialogResult.CheckBox}"
line00000005=STRING|"File: {json:DialogResult.FileSelect}"
linecount=STRING|"6"
timeout=STRING|"10"
title=STRING|"Results"

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

Re: I need help regarding adding a value to a variable.

Post by Oleg »

Lastly will "wait for process" trigger work correctly if I put variable such as "game" which contains more than 1 value?
Wait for process is an action. Maybe you mean Process watcher trigger?

The trigger can monitor only one process. If you variable contain many values the trigger will not work.
If you want to monitor 3 different processes you must attach to the task three triggers Process watcher with different parameters.
Oleg Yershov
cacatnow
Posts: 10
Joined: Thu May 05, 2016 2:17 am

Re: I need help regarding adding a value to a variable.

Post by cacatnow »

Oleg wrote: Sat Apr 08, 2023 10:47 am
Lastly will "wait for process" trigger work correctly if I put variable such as "game" which contains more than 1 value?
Wait for process is an action. Maybe you mean Process watcher trigger?

The trigger can monitor only one process. If you variable contain many values the trigger will not work.
If you want to monitor 3 different processes you must attach to the task three triggers Process watcher with different parameters.
I don't know how to multiquote in this forum so I'll just quote the last one, but I think I explained my situation poorly. What I mean is I want to create a dialog box to add a value to existing variable. For example variable game has game1.exe and game2.exe as values, I want to add game3.exe using a dialog box/input dialog. The 1st example does not do that.

So that is the result of 2nd example?? How to assign/add values to a variable using it then? Not possible I guess? Adding any value using custom input dialog will only end up with { to a variable because it starts with {. I was thinking of using custom input dialog to add multiple game process name to a variable.

Yes I meant process watcher. Well this is a bummer because I want to watch processes that I assign to game variable. That means wait for process action does not support multiple values too I assume?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: I need help regarding adding a value to a variable.

Post by Oleg »

How to assign/add values to a variable using it then? Not possible I guess?
This is possible. Look at the screenshot below and 1-st example (step #3). I don't think you saw it...
variable.png
variable.png (17.5 KiB) Viewed 4679 times
"Expand value" option means that the action calculates result before assigning. In this case you can use this variable in expression.
Oleg Yershov
cacatnow
Posts: 10
Joined: Thu May 05, 2016 2:17 am

Re: I need help regarding adding a value to a variable.

Post by cacatnow »

Oleg wrote: Sat Apr 08, 2023 12:30 pm
How to assign/add values to a variable using it then? Not possible I guess?
This is possible. Look at the screenshot below and 1-st example (step #3). I don't think you saw it...
variable.png
"Expand value" option means that the action calculates result before assigning. In this case you can use this variable in expression.
I think you misunderstood, I want a text box to appear (meaning I assign the value inside the texbox, not assigning it in the task steps) so I can input the value once i run the task, not when i set up the task.
Post Reply