Jump to content

array incorrect number of subscripts ? works sometimes sometimes not ?


Recommended Posts

hey guys, 

im using a shuffle function to shuffle the lines read in a textdocument . sometimes i get the number of subscripts error, sometimes not although i dont change the script. where is the mistake ?

#include <Array.au3>
#include <File.au3>
start()

Func start() 
FileOpen("zuueberpruefendenummern.txt")

Global $zeilen = _FileCountLines( "C:\users\edon\desktop\registrierungsueberpruefer v1.1\zuueberpruefendenummern.txt")
Dim $in[$zeilen]


For $s = 0 to ($zeilen-1)

    $in[$s] =FileReadLine("zuueberpruefendenummern.txt",($s+1))

Next

FileClose("zuueberpruefendenummern.txt")

$out = _Shuffle($in)

EndFunc



Func _Shuffle($aIn)
    Dim $aOut[UBound($aIn)]

    Dim $iRand
    Dim $iNext = 0

    While UBound($aIn) > 1
        $iRand = Random(0,UBound($aIn)-1,1)

        $aOut[$iNext] = $aIn[$iRand] 
        $iNext += 1

        _ArrayDelete($aIn,$iRand)
    WEnd

    $aOut[$iNext] = $aIn[0]

    Return $aOut
EndFunc

the error points at the line where the $ain[$iRand] value gets stored to the $aout array... 

Edited by sonic208
Link to comment
Share on other sites

Nothing jumping out at me at first glance, but I am curious...did you see or try the _ArrayShuffle function in the UDF?  If so, did it not handle your needs?

Link to comment
Share on other sites

so the first problem was the path because it didnt work at all . i  changed it now and it works after the second start.  

this is not such a big problem, but its very interesting for me why it wont work at the first start and give me the error. ill investigate more in this and try to get more information when it occurs and when not, now ill try if the error occurs when i build it to an exe

Link to comment
Share on other sites

1 minute ago, LeCarre said:

#include <File.au3>
#include <Array.au3>

Global $in

_FileReadToArray("C:\users\edon\desktop\registrierungsueberpruefer v1.1\zuueberpruefendenummern.txt",$in,0)
_ArrayShuffle($in)
_ArrayDisplay($in)
 

so i can use these 3 lines instead of that shuffle function? are you sure ? thxxxx !

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...