Sign in to follow this  
Followers 0
mojehyip

Random ....

3 posts in this topic

#1 ·  Posted (edited)

I found in some threads this script

$pwd = ",besprzesady"
Dim $aSpace[3]
$digits = 5
For $i = 1 To $digits
$aSpace[2] = Chr(Random(48, 57, 1)) ;0-9
$pwd &= $aSpace[Random(0, 2, 1)]
Next
ConsoleWrite("Your password (" & $digits & " digits): " & $pwd & @CRLF)

Now i change it for:

Next
$random2 = "I maked number: "
Dim $aSpace2[3]
$digits2 = 3
For $i2 = 1 To $digits2
    $aSpace2[2] = Chr(Random(48, 57, 1)) ;0-9
    $random2 &= $aSpace2[Random(0, 2, 1)]
If $random2 > 1 Then
$random2 = ("14")
endif
Next

But sometimes its get "0" i tryed change line

$random2 &= $aSpace2[Random(0, 2, 1)]

After this, autoit compile show error:

G:Documents and SettingsSharecashPulpitProgramantdsw.plDOdawanie pytanskrypt.au3 (48) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$random2 &= $aSpace2[Random(1, 3800, 1)]
$random2 &= ^ ERROR

I want get number only from 1 to 3800. But its not working.

I read the HELP and there was information about X & A.

X = Min info

A = Max info

Why its not working ?

Random(X, A, 1)

Min [optional] The smallest number to be generated. The default is 0.

Max [optional] The largest number to be generated. The default is 1.

Did i maked some wrong? Tell me

Edited by mojehyip

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You set the maximum array index to 3 with

Dim $aSpace2[3]

Then with

$random2 &= $aSpace2[Random(1, 3800, 1)]

You have allowed this index to be anywhere between 1 and 3800.

So if random rolls a 5 then you get

$random2 &= $aSpace2[5]

Which exceeds the max index of 3.

Edit: Added Dim keyword

Edited by John

Share this post


Link to post
Share on other sites

You set the maximum array index to 3 with

Dim $aSpace2[3]
Then with
$random2 &= $aSpace2[Random(1, 3800, 1)]
You have allowed this index to be anywhere between 1 and 3800.
So if random rolls a 5 then you get
$random2 &= $aSpace2[5]

Which exceeds the max index of 3.

Edit: Added Dim keyword

btw. I used

$random2 = Random(1, 3000, 1)
= and this work

Share this post


Link to post
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
Sign in to follow this  
Followers 0