Jump to content

Do until test


Recommended Posts

Hi guys,

In one of my scripts I've to generate 5 numbers that are ALL differents.

I've tried to do something like that :

Do

        $p = Random(1, 10, 1)
        $p1 = Random(1, 10, 1)
        $p2 = Random(1, 10, 1)
        $p3 = Random(1, 10, 1)
        $p4 = Random(1, 10, 1)

Until ($p <> $p1 <> $p2 <> $p3 <> $p4)

But it doesn't work.

The only way I've found is to do all the tests :sweating:  like this :

Do

        $p = Random(1, 10, 1)
        $p1 = Random(1, 10, 1)
        $p2 = Random(1, 10, 1)
        $p3 = Random(1, 10, 1)
        $p4 = Random(1, 10, 1)
Until ($p <> $p1 And $p <> $p2 And $p <> $p2 And $p <> $p3 And $p <> $p4 And $p1 <> $p2 And $p1 <> $p3 And $p1 <> $p4 And $p2 <> $p3 And $p2 <> $p4 And $p3 <> $p4)

... imagine if I've to generate 50 numbers between 1 to 1000, the test should be difficult to write : !

It's there a best way to do this ???

Edited by akorx

AkorxMail akorx@yahoo.fr

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...