possible to run a random task?
possible to run a random task?
Hello,Is it possible to run a random task?Let's say I have taskSTART, task1, task2, task3, and taskENDI create a new task and inside I add 'taskSTART' and 'taskEND'. Between the two tasks I want to run a random task: task 1 or 2 or 3.Possible?thx
possible to run a random task?
Yes, it's possible.
Your task will be such:
GetRandomValue // basic script, see below
start taskSTART
if RandomVal < 334 then
start task1
else
if RandomVal < 667 then
start task2
else
start task3
end if
end if
start taskEnd
Basic script calculates the random value between 0 and 1000 and assigns it to variable RandomVal. The text of basic script:
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Sub Main
' this function determine random integer
' between 0 and 1000
Dim r As Double
Dim res As Integer
Randomize (GetTickCount) 'initialize random generator
r = Rnd ' 0 <= r < 1
res = Int(r*1000) ' 0 <= res < 1000
RoboTaskApp.SetUserVariable("RandomVal", CStr(res))
End Sub
Your task will be such:
GetRandomValue // basic script, see below
start taskSTART
if RandomVal < 334 then
start task1
else
if RandomVal < 667 then
start task2
else
start task3
end if
end if
start taskEnd
Basic script calculates the random value between 0 and 1000 and assigns it to variable RandomVal. The text of basic script:
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Sub Main
' this function determine random integer
' between 0 and 1000
Dim r As Double
Dim res As Integer
Randomize (GetTickCount) 'initialize random generator
r = Rnd ' 0 <= r < 1
res = Int(r*1000) ' 0 <= res < 1000
RoboTaskApp.SetUserVariable("RandomVal", CStr(res))
End Sub
Last edited by Oleg on Sat Apr 05, 2008 6:57 am, edited 1 time in total.
possible to run a random task?
Please ignore this post as my problem is solved...
Last edited by nick on Sun Apr 27, 2008 7:38 am, edited 1 time in total.