Jump to content

Array Errors Intermittent


Recommended Posts

Soo this script appears to work sometimes, but other times it returns an array error at line 22. I'm not sure what's going on, anyone want to take a stab at it?

#include <Array.au3>

Dim $kSpace[36]



For $i = 0 To 9; Fill numbers 0-9

    $kSpace[$i] = $i

Next

For $i = 10 To 35; Fill Letters A-Z

    $kSpace[$i] = Chr($i + 55)

Next



$n = 3



Dim $k[$n]

If $n > 0 Then

    $n = $n - 1

EndIf

For $m = 0 To $n

    For $i = 0 To 5

            $k[$m] = $k[$m] & $kSpace[Random(0, 36, 1)]

    Next

Next



_ArrayDisplay($k)

Error:

.au3 (22) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$k[$m] = $k[$m] & $kSpace[Random(0, 36, 1)]

$k[$m] = $k[$m] & ^ ERROR

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Hi. remember autoit array start in index 0.

$kSpace[Random(0, 35, 1)]

Edit:

 

maybe this can Help too.

#include <Array.au3>

Dim $kSpace[1000]


for $i=0 to UBound($kSpace)-1

$kSpace[$i]=RNDA_Z_0_9()

next



_ArrayDisplay($kSpace)


Func RNDA_Z_0_9()
Local $cadena,$char

local $string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
local $i=1
for $i= 1 to 5
   $char = stringmid($string,Random(1,stringlen($string),1),1)
    $cadena &= $char
next
return $cadena
EndFunc

saludos

Edited by Danyfirex
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...