i want create variable for random text

Discuss RoboTask here
Post Reply
elwaleed
Posts: 3
Joined: Sat Nov 06, 2021 3:59 pm

i want create variable for random text

Post by elwaleed »

i want create variable for random text

i created variable

{MYVAR} = " John" , "Edi Forad " , " Donald Boka"

i want random for this text

i add {MYVAR(1 or 2 or 3)}

but not work its show first name every time

sorry for my bad english
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: i want create variable for random text

Post by Oleg »

Look at my example.
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|1163085779
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task50"
Hide=INTEGER|0
ID=INTEGER|-605196879
LogOnAsUser=INTEGER|1
Name=STRING|"Random name"
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
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""names"" with value """"John"" , ""Edi Forad "" , "" Donald Boka"", ""Marty"", ""James Bond"""""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"names"
varvalue=STRING|"""John"" , ""Edi Forad "" , "" Donald Boka"", ""Marty"", ""James Bond"""

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

[Actions\Action2\Params]
begin=STRING|"1"
end=STRING|"10"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|0
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action3\Params]
message=STRING|"{RandomValue(3)}"
type=STRING|"3"

[Actions\Action4]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Random name:"""
Params=FOLDER

[Actions\Action4\Params]
icon=STRING|"1"
msg0=STRING|"Random name:"
msg2=STRING|"{names({RandomValue(5)})}"
msgcount=STRING|"3"
playsound=STRING|"0"
showmessage=STRING|"1"

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

Oleg Yershov
elwaleed
Posts: 3
Joined: Sat Nov 06, 2021 3:59 pm

Re: i want create variable for random text

Post by elwaleed »

sorry if i ask you again

i can use variables with my task

but how can i use this task with my main task
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: i want create variable for random text

Post by Oleg »

Set variable MyVar with this value
"John" , "Edi Forad " , " Donald Boka", "Marty", "James Bond"

To get random name use the expression
{MyVar({RandomValue(N)})}
N - the number of elements in variable
In this case N=5

{MyVar({RandomValue(5)})}
Oleg Yershov
Post Reply