dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Thu Mar 16, 2006 9:50 am Post subject: Random number problem |
|
|
Hi
I have written an agent that sits on the taskbar and polls a file
server at a set interval to carry out various scripted tasks. The
poll period is stored in a LOCAL ini file. In order to avoid the
agents polling in waves I have built in a randomize function of
the poll period to spread the agents out during the day. When
I tested the randomize function in the IDE it worked fine but,
when the agents out in the 'wild' try it they don't appear to very
random at all. Here are the code snippets..
| Code: |
:evloop
gosub info
gosub pollPeriod
wait event,%%time
%%event = @event()
goto %%event
|
| Code: |
:pollPeriod
rem generate a RAND No. between 1 & 3
%a = @random(1,4)
rem adjust poll interval according to RAND No.
if @equal(%a,1)
%%time = @fint(@fmul(%%poll,0.75))
exit
end
if @equal(%a,2)
%%time = %%poll
exit
end
if @equal(%a,3)
%%time = @fint(@fmul(%%poll,1.333))
exit
else
rem if no RAND No. just use poll interval
%%time = %%poll
end
exit
|
The poll period is normally set to 300 seconds. When I
tested it in the IDE it spread the %%time out nicely but
the agents just seem to settle on 300 seconds.
Is the @random() function somehow using the clock on
the file server? I thought as the agent is running locally
it would use the local PC's clock?
Any ideas?
Thanks
David.M |
|