possible to run a random task?

Discuss RoboTask here
Post Reply
nick
Posts: 7
Joined: Fri Apr 04, 2008 3:59 pm

possible to run a random task?

Post 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
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

possible to run a random task?

Post 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
Last edited by Oleg on Sat Apr 05, 2008 6:57 am, edited 1 time in total.
nick
Posts: 7
Joined: Fri Apr 04, 2008 3:59 pm

possible to run a random task?

Post by nick »

thanks! 
nick
Posts: 7
Joined: Fri Apr 04, 2008 3:59 pm

possible to run a random task?

Post by nick »

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.
Post Reply