sonic208 Posted March 23, 2017 Share Posted March 23, 2017 (edited) 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 ? expandcollapse popup#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 March 23, 2017 by sonic208 Link to comment Share on other sites More sharing options...
Joboy2k Posted March 23, 2017 Share Posted March 23, 2017 possibly, its coming up with an error when reading the lines in the FileReadLine. Try put an "if @error then return: or maybe in the _shuffle func put "If IsArray($aIn) then" or something like that. sonic208 1 Link to comment Share on other sites More sharing options...
spudw2k Posted March 23, 2017 Share Posted March 23, 2017 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? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
LeCarre Posted March 23, 2017 Share Posted March 23, 2017 #include <File.au3> #include <Array.au3> Global $in _FileReadToArray("C:\users\edon\desktop\registrierungsueberpruefer v1.1\zuueberpruefendenummern.txt",$in,0) _ArrayShuffle($in) _ArrayDisplay($in) Link to comment Share on other sites More sharing options...
sonic208 Posted March 23, 2017 Author Share Posted March 23, 2017 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 More sharing options...
sonic208 Posted March 23, 2017 Author Share Posted March 23, 2017 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 More sharing options...
LeCarre Posted March 23, 2017 Share Posted March 23, 2017 Glad to help sonic208 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now