zeroZshadow Posted February 9, 2005 Share Posted February 9, 2005 why doesn't my script works?? i added the file needed to this post Dim $buffer[5000] $line = 1 $timer = TimerInit() While 1 $buffer[$line] = FileReadLine ("menu2.txt",$line) If @error = -1 then $dif = TimerDiff($timer) $time = Round($dif,-1) MsgBox(0,"Done","Line nr."&$line&" has been reached in "&$time&" milliseconds") ExitLoop EndIf $line = $line+1 Wend Dim $buffer2[$line] for $line2=1 to $line $Buffer2[$line2] = StringSplit($buffer[$line2],";" ) MsgBox(4096, "Test",$Buffer2[$line2][1]) Next thanks for help *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
SlimShady Posted February 9, 2005 Share Posted February 9, 2005 This has been discussed before. When you declare an array, you specify the number of elements you're going to use. Example Dim $Arr[5] is For $i = 0 To 4 $Arr[$i] = "your value" Next You don't believe me? count yourself: 0 1 2 3 4 Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 9, 2005 Author Share Posted February 9, 2005 ????????? could you update that part of the code, because i really don't get what ur saying this way. sorry *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
SlimShady Posted February 9, 2005 Share Posted February 9, 2005 It's ok. Your script is incomplete and totally not working. I updated your script. expandcollapse popupDim $buffer[5] $buffer = _FileReadToArray("menu2.txt", $buffer) $lines = $buffer[0] Dim $buffer2[$lines] for $lines2 = 1 to $lines - 1 $Line = $Buffer2[$lines2] $Buffer2[$lines2] = StringSplit($Line, ";" ) ;MsgBox(4096, "Test",$Buffer2[$lines2][1]) ;<--- This will not work! Next ;=============================================================================== ; ; Description: Reads the specified file into an array. ; Syntax: _FileReadToArray( $sFilePath, $aArray ) ; Parameter(s): $sFilePath - Path and filename of the file to be read ; $aArray - The array to store the contents of the file ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets @error = 1 ; Author(s): Jonathan Bennett <jon at hiddensoft com> modified by SlimShady ; Note(s): None ; ;=============================================================================== Func _FileReadToArray($sFilePath, ByRef $aArray) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $hFile, $Content $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $Content = FileRead($hFile, FileGetSize($sFilePath)) $aArray = StringSplit(StringStripCR($Content), @LF) FileClose($hFile) Return 1 EndFunc ;==>_FileReadToArray Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 9, 2005 Author Share Posted February 9, 2005 is gives an error... C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\jaap\slimsscript.au3 (4) : ==> Subscript used with non-Array variable.: $lines = $buffer[0] $lines = $buffer^ ERROR >Exit code: 0 Time: 0.863 *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
SlimShady Posted February 9, 2005 Share Posted February 9, 2005 (edited) Yeah I was just rechecking the code. Hold on... expandcollapse popupDim $buffer[5] _FileReadToArray("menu2.txt", $buffer) $lines = $buffer[0] Dim $LineArr Dim $buffer2[$lines] for $lines2 = 1 to $lines - 1 $LineArr = StringSplit($buffer[$line2], ";") $Buffer2[$lines2] = $LineArr MsgBox(4096, "Test",$LineArr[1]) Next ;=============================================================================== ; ; Description: Reads the specified file into an array. ; Syntax: _FileReadToArray( $sFilePath, $aArray ) ; Parameter(s): $sFilePath - Path and filename of the file to be read ; $aArray - The array to store the contents of the file ; Requirement(s): None ; Return Value(s): On Success - Returns 1 ; On Failure - Returns 0 and sets @error = 1 ; Author(s): Jonathan Bennett <jon at hiddensoft com> modified by SlimShady ; Note(s): None ; ;=============================================================================== Func _FileReadToArray($sFilePath, ByRef $aArray) ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $hFile, $Content $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $Content = FileRead($hFile, FileGetSize($sFilePath)) $aArray = StringSplit(StringStripCR($Content), @LF) FileClose($hFile) Return 1 EndFunc ;==>_FileReadToArray Edited February 9, 2005 by SlimShady Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 9, 2005 Author Share Posted February 9, 2005 again an error: C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\jaap\slimsscript.au3 (9) : ==> Variable used without being declared.: $LineArr = StringSplit($buffer[$line2], ";") $LineArr = StringSplit($buffer[^ ERROR >Exit code: 0 Time: 0.981 *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
zcoacoaz Posted February 9, 2005 Share Posted February 9, 2005 $line2 isnt declared. [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font] Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 9, 2005 Author Share Posted February 9, 2005 again an error:C:\Documents and Settings\zeroZshadow\Mijn documenten\autoitscripts\jaap\slimsscript.au3 (9) : ==> Variable used without being declared.: $LineArr = StringSplit($buffer[$line2], ";") $LineArr = StringSplit($buffer[^ ERROR>Exit code: 0  Time: 0.981<{POST_SNAPBACK}> $line2 isnt declared. <{POST_SNAPBACK}>that what the error said.you don't have to spam that again. *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 9, 2005 Author Share Posted February 9, 2005 anyway...i made it work. but now the msgboxes gives a number everytime!! instead of the string *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Link to comment Share on other sites More sharing options...
SlimShady Posted February 9, 2005 Share Posted February 9, 2005 What string? What do you expect to see? Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 10, 2005 Author Share Posted February 10, 2005 if you look in the menu2.txt you will see allot of lines. the first part will put every line in a array ($buffer[1] till $buffer[allot]) then stringspliw has to plit EVERY array again to get every word separated by the ";" so i'll get ($buffer[1][1]/$buffer[1][2]/$buffer[1][3]) ($buffer[2][1]/$buffer[2][1]/$buffer[3][1]) and so on..... so i can put them in a list and then convert it to a tree. *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... 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