jerem488 Posted November 1, 2008 Share Posted November 1, 2008 Hello, I would like change a suite of numbers but he must read this numbers in a text file my text file is like this : 3, 12, 34, 89, 109, 35 489, 184, 890, 7, 18 I have about 1000 lines. And my varaible is $numbers[5] = How to do this ? thanks in advance Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Valuater Posted November 1, 2008 Share Posted November 1, 2008 How do you want to change them? 8) Link to comment Share on other sites More sharing options...
jerem488 Posted November 1, 2008 Author Share Posted November 1, 2008 I want recover the numbers in my text file. per line there is firsts numbers for the varaible. for example, I have this numbers in my text file : line 1 : 3, 12, 34, 89, 109, 35 line 2 : 489, 184, 890, 7, 18 so I do a loop with the "while" command and my first variable would $numbers[5] = [3, 12, 34, 89, 109, 35] is it explicit ? Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Valuater Posted November 1, 2008 Share Posted November 1, 2008 I want recover the numbers in my text file. per line there is firsts numbers for the varaible. for example, I have this numbers in my text file : line 1 : 3, 12, 34, 89, 109, 35 line 2 : 489, 184, 890, 7, 18 so I do a loop with the "while" command and my first variable would $numbers[5] = [3, 12, 34, 89, 109, 35] is it explicit ? Actually... No That part I can manage.. it's "what are you going to do ( want to do ) after that?" 8) Link to comment Share on other sites More sharing options...
jerem488 Posted November 1, 2008 Author Share Posted November 1, 2008 After i use this numbers to do an operation. How can you mange this ? Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
Zedna Posted November 1, 2008 Share Posted November 1, 2008 Look at FileRead,StringSplit, For/Next loop Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Valuater Posted November 1, 2008 Share Posted November 1, 2008 Look at FileRead,StringSplit, For/Next loopYep....Ya know, had you given more info Zedna or myself would have been able to help you with code8)_ Link to comment Share on other sites More sharing options...
jerem488 Posted November 3, 2008 Author Share Posted November 3, 2008 So first I can't use fileread but also filereadline bacause my numbers suite are lines. Stringsplit ? Why ? between what ? and for/next... I think the while function is better than for/next for reading a file who can change. Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
SoulA Posted November 3, 2008 Share Posted November 3, 2008 Why not just give a further explanation of what it is you are trying to do these numbers in the file? What are you trying to change about them? Link to comment Share on other sites More sharing options...
jerem488 Posted November 3, 2008 Author Share Posted November 3, 2008 Thank you I am doing like this : $File = FileOpen(@homedrive & "\Numbers_MAJ.txt", 0) If $File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf While 1 $LignePair = FileReadLine($File) If @error = -1 Then ExitLoop $Separation = StringSplit($LignePair,",",0) Dim $numbers[8] = [$Separation[1],$Separation[2],$Separation[3],$Separation[4],$Separation[5],$Separation[6],$Separation[7],$Separation[8]] Wend Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
SoulA Posted November 3, 2008 Share Posted November 3, 2008 (edited) With what you have the $numbers array is getting overwritten every time it goes through the loop. Why not put them in a 2d array. The first dimension being the line number and the second being the numbers on that line? #include <file.au3> $sPath = @homedrive & "\Numbers_MAJ.txt" $iLineNum = _FileCountLines($sPath) Dim $numbers = [$iLineNum][8] $File = FileOpen($sPath, 0) If $File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $i = 0 to $iLineNum - 1 $LignePair = FileReadLine($File) If @error = -1 Then ExitLoop $Separation = StringSplit($LignePair,",",0) $numbers[$i][8] = [$Separation[1],$Separation[2],$Separation[3],$Separation[4],$Separation[5],$Separation[6],$Separation[7],$Separation[8]] Next For $i = 0 to UBound($numbers, 1) - 1 $sString = "" For $i1 = 0 to UBound($numbers, 2) - 1 $sString &= $numbers[$i][$i1] & @CRLF Next MsgBox(0, "Line " & $i + 1, $sString) Next Edited November 3, 2008 by SoulA Link to comment Share on other sites More sharing options...
jerem488 Posted November 3, 2008 Author Share Posted November 3, 2008 (edited) Thank you but there are two errors #include <file.au3> $sPath = @homedrive & "\Numbers_MAJ.txt" $iLineNum = _FileCountLines($sPath) Dim $numbers = [$iLineNum][8] $File = FileOpen($sPath, 0) If $File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $i = 0 to $iLineNum - 1 $LignePair = FileReadLine($File) If @error = -1 Then ExitLoop $Separation = StringSplit($LignePair,",",0) $numbers[$i][8] = [$Separation[1],$Separation[2],$Separation[3],$Separation[4],$Separation[5],$Separation[6],$Separation[7],$Separation[8]] Next For $i = 0 to UBound($numbers, 1) - 1 $sString = "" For $i1 = 0 to UBound($numbers, 2) - 1 $sString &= $numbers[$i][$i1] & @CRLF Next MsgBox(0, "Line " & $i + 1, $sString) Next Syntax error. --------------------------------------------------------------------------------------------- H:\Bureau\ser_3.au3(5,16) : ERROR: syntax error Dim $numbers = [ ~~~~~~~~~~~^ H:\Bureau\ser_3.au3(18,23) : ERROR: syntax error $numbers[$i][8] = [ ~~~~~~~~~~~~~~^ --------------------------------------------------------------------------------------------- Edited November 3, 2008 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
SoulA Posted November 3, 2008 Share Posted November 3, 2008 (edited) hrm can try this I guess. I probably should try and make my own test file to do this with but I am lazy so I'm not sure how well all this is working. #include <file.au3> $sPath = "test.txt" $iLineNum = _FileCountLines($sPath) Dim $numbers[$iLineNum][8] $File = FileOpen($sPath, 0) If $File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf For $i = 0 to $iLineNum - 1 $LignePair = FileReadLine($File) If @error = -1 Then ExitLoop $Separation = StringSplit($LignePair,",",0) For $i1 = 0 to $Separation[0] - 1 $numbers[$i][$i1] = $Separation[$i1 + 1] Next Next For $i = 0 to UBound($numbers, 1) - 1 $sString = "" For $i1 = 0 to UBound($numbers, 2) - 1 $sString &= $numbers[$i][$i1] & @CRLF Next MsgBox(0, "Line " & $i + 1, $sString) Next Edited November 3, 2008 by SoulA Link to comment Share on other sites More sharing options...
jerem488 Posted November 15, 2008 Author Share Posted November 15, 2008 (edited) Hi Soula ! I just try and it works ! ! and in addition it is very useful for others programs Very good, very thanks. Edited November 15, 2008 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] 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