Helo, I'm trying to generate a random number between 0 and X
where X could be any number stored in a variable, but when I use Evaluate and the system variable RandomValue in something like this:
x=6
{RandomValue({X})}
or this:
{RandomValue(5+1)}
I always get the default behavior of 0 to 1000, is this a bug? Is there a workaround?
Thank you!
randomvalue
Re: randomvalue
Try the example below.
It works
If you use incorrect or non-integer value in parameter this variable use default parameter (1000)
It works
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1778412004
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task120"
Hide=INTEGER|0
ID=INTEGER|16042901
LogOnAsUser=INTEGER|1
Name=STRING|"Random value"
OnErrorTaskID=INTEGER|-1
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
[Actions\Action1]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//set value at step 1"
Params=FOLDER
[Actions\Action1\Params]
comment=STRING|"set value at step 1"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NUM"" with value ""6"""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varname=STRING|"NUM"
varvalue=STRING|"6"
[Actions\Action3]
ActionID=STRING|"A_LOOP_SIMPLE"
Enabled=INTEGER|-1
Name=STRING|"Simple Loop"
Params=FOLDER
[Actions\Action3\Params]
begin=STRING|"1"
end=STRING|"10"
[Actions\Action4]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER
[Actions\Action4\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"5"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"{RandomValue({num})}"
position=STRING|"3"
title=STRING|"RandomValue"
width=STRING|"330"
[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Oleg Yershov
Re: randomvalue
Thank you, what I was trying to do was:
{RandomValue({num})}+1
But wasn't working. This works:
({RandomValue({num})})+1

{RandomValue({num})}+1
But wasn't working. This works:
({RandomValue({num})})+1




Re: randomvalue
Use "JS Evaluate" action for simple arithmetic operations.
This actions designed for this.
This actions designed for this.
Oleg Yershov
Re: randomvalue
Also you can save the value into variable and use "Increment Variable" action
Oleg Yershov