cypher175 Posted March 7, 2009 Share Posted March 7, 2009 Is there anyway to use _FileReadToArray on a txt file and then do a FOR statement that uses the lines read into the array in a random order..?? Link to comment Share on other sites More sharing options...
James Posted March 7, 2009 Share Posted March 7, 2009 #include <File.au3> Dim $fleText = @ScriptDir & '\text.txt' _ReadRandom($fleText) Func _ReadRandom($ioFile) Local $fleLines = _FileCountLines($ioFile) Local $arrFile, $rnd _FileReadToArray($ioFile, $arrFile) For $i = 0 To UBound($arrFile) - 1 $rnd = Random($arrFile[1], UBound($arrFile) - 1) ConsoleWrite($arrFile[$rnd] & @CRLF) Next EndFunc That's a start. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Andreik Posted March 7, 2009 Share Posted March 7, 2009 (edited) Is there anyway to use _FileReadToArray on a txt file and then do a FOR statement that uses the lines read into the array in a random order..??Something like this (could be the same line more times) $SELECT = FileOpenDialog("SELECT",@ScriptDir,"All (*.*)",1) Dim $FILE[1] _FileReadToArray($SELECT,$FILE) If IsArray($FILE) For $INDEX = 1 To $FILE[0] $RANDOM = Random(1,$FILE[0],1) MsgBox(0,"",$FILE[$RANDOM]) Next EndIf or like this: #include <Array.au3> #include <File.au3> $SELECT = FileOpenDialog("SELECT",@ScriptDir,"All (*.*)",1) Dim $FILE[1] _FileReadToArray($SELECT,$FILE) _ArrayDisplay($FILE) If IsArray($FILE) Then For $INDEX = 1 To $FILE[0]*3 _ArraySwap($FILE[Random(1,$FILE[0],1)],$FILE[Random(1,$FILE[0],1)]) Next _ArrayDisplay($FILE) EndIf Edited March 7, 2009 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
cypher175 Posted March 7, 2009 Author Share Posted March 7, 2009 well what im trying to do is: I have a FOR statement running from a _FileReadToArray from a .txt file and for every line in that .txt file i am performing a few functions .. but I need to have a variable in this FOR statement that randomly changes for each new line in the _FileReadToArray and this random variable will be coming from another _FileReadToArray from a diff .txt file.. So if yer still with me on what i just described, then how would i code something like this..?? Link to comment Share on other sites More sharing options...
Aceguy Posted March 7, 2009 Share Posted March 7, 2009 Try coding it yourself.... the helpfile, is errr, very helpfull [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock 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