Page 1 of 1

possible to run a random task?

Posted: Fri Apr 04, 2008 4:09 pm
by nick
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?

Posted: Sat Apr 05, 2008 2:48 am
by Oleg
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

possible to run a random task?

Posted: Sat Apr 05, 2008 5:32 pm
by nick
thanks! 

possible to run a random task?

Posted: Sun Apr 27, 2008 3:32 am
by nick
Please ignore this post as my problem is solved...