Thanks:  0
Likes:  0
Dislikes:  0

1. ## Random

Hello!

I need to have a script that press on different buttons in any order for a bib number of iterations.

So, I tried that:

While i < 10000

ret = Random( 1, 8)

Switch ret
Case 1
Button "Play", 'Left SingleClick'

Case 2
Button "Pause", 'Left SingleClick'

Case 3
Button "Rewind10", 'Left SingleClick'

Case 4
Button "Forward10", 'Left SingleClick'

Case 5
Button "Rewind30", 'Left SingleClick'

Case 6
Button "Forward30", 'Left SingleClick'

Case 7

Case 8
RadioButton "Part de marché", 'Left SingleClick'

End Switch

i = i+1

Wend

I have two problems:

1/I get only 2 iterations (instead of 10000) what I can't understand.

2/ I is always the same 2 digits.

Can someone help me?

Thanks

------------------

2. ## Re: Random

We've found that the qarun random feature isn't exactly random.

It will produce the exact same numbers each time you run the script.

Not sure about your first point though, have you specifically set i=1 before entering the loop?

------------------

3. ## Re: Random

AS SReilly pointed out, I have found that if you do not explicitly tell a variable that it is = Integer (ie - X = 1, JustAVar = 0) that it will always = ""/NULL.

So much like VB, and yet....

------------------

[This message has been edited by TxMutual (edited 07-30-2002).]

4. ## Re: Random

Ok, thanks.

But, is there a way to create a "real" random fonction??

Thanks

------------------

5. ## Re: Random

Are you guys using the RandomSeed() function before calling Random??? Random() will always return the same numbers if you don't use RandomSeed first.

I never used it but will some day. Why do you all say it doesn't work? What doesn't work about it?

------------------
"If your not part of the solution, there's good money to be made in prolonging the problem."

6. ## Re: Random

I tried that:
for i =1 to 20

RandomSeed(10000)
ret = Random( )

MsgBox("Info", ret)

Next

and always get 32694

The same with RandomSeed (1) gives me always 41

so ...

------------------

7. ## Re: Random

The seed value needs to change or the number will always be the same. The best way to seed the random number is to pass in time, seconds works best, or you could do minutes and seconds.

RandomSeed(secs( ))
for i =1 to 5
ret = Random( )
MsgBox(i, ret)
Next

-OR-

RandomSeed(secs( ) + mins())
for i =1 to 5
ret = Random( )
MsgBox(i, ret)
Next

You want to call RandomSeed OUTSIDE the loop because the numbers will follow sequence if you call it inside the loop.

------------------
"If your not part of the solution, there's good money to be made in prolonging the problem."

8. ## Re: Random

(Secs * Hours) works pretty well from my recollection (product not in front of me).

------------------

9. ## Re: Random

Computers have a problem when trying to select random numbers. This is because they do not have that kind of intelligence. They can only perform specific calculations.

I tend to use curtime () for random (ish) numbers.

This will return the number of seconds since 01-01-1970.

Provided your script does not take exactly 10 seconds every time it runs, you can use the right most digit as the random number.

eg.

For iIteration = 1 to 10000

iRandomNum = Right (CurTime (), 1) ; Random number between 0 and 9

Switch iRandomNum
Case "1"
;Do this
Case "2"
;Do that
Case "3"
;Do the other
Case "4"
;Do something completely different
End Switch

iIteration = iIteration + 1

Next

------------------
Automation and Test Consultancy

Testing@archiemoore.co.uk

**************************************

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.