burger Posted January 11, 2007 Share Posted January 11, 2007 I'm attempting to re-use an array for reading multiple text files. The following code fails after the first time thru the loop. Is this because I am attempting to recreate an array already in memory? Is it possible to clear the array after each loop? expandcollapse popupDim $aArray[18] While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $GS For $nsig = 1 to 6 If $nsig = 1 Then $sigfile = "C:\ft\sig\ruttrft.sig" $sig = "RuttrFT" EndIf If $nsig = 2 Then $sigfile = "C:\ft\sig\EEV4.sig" $sig = "EEV4" EndIf If $nsig = 3 Then $sigfile = "C:\ft\sig\ruttr17.sig" $sig = "ruttr17" EndIf If $nsig = 4 Then $sigfile = "C:\ft\sig\bbmc.sig" $sig = "bbmc" EndIf If $nsig = 5 Then $sigfile = "C:\ft\sig\ndxrsi51.sig" $sig = "ndx51" EndIf If $nsig = 6 Then $sigfile = "C:\ft\sig\ndx5.sig" $sig = "ndx5" EndIf _FileReadToArray($sigfile, $aArray) $sig1 = ($aArray[$aArray[0]-1]) $Label1 = GUICtrlCreateListViewItem ( $sig & "|" & StringMid ($sig1, 3), 3 ) If StringLeft ($sig1, 1) = "S" Then GUICtrlSetBkColor(-1, 0xFF0000) EndIf If StringLeft ($sig1, 1) = "B" Then GUICtrlSetBkColor(-1, 0x00FF00) EndIf Next EndSelect WEnd Link to comment Share on other sites More sharing options...
nitekram Posted January 11, 2007 Share Posted January 11, 2007 I'm attempting to re-use an array for reading multiple text files. The following code fails after the first time thru the loop. Is this because I am attempting to recreate an array already in memory? Is it possible to clear the array after each loop? expandcollapse popupDim $aArray[18] While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $GS For $nsig = 1 to 6 If $nsig = 1 Then $sigfile = "C:\ft\sig\ruttrft.sig" $sig = "RuttrFT" EndIf If $nsig = 2 Then $sigfile = "C:\ft\sig\EEV4.sig" $sig = "EEV4" EndIf If $nsig = 3 Then $sigfile = "C:\ft\sig\ruttr17.sig" $sig = "ruttr17" EndIf If $nsig = 4 Then $sigfile = "C:\ft\sig\bbmc.sig" $sig = "bbmc" EndIf If $nsig = 5 Then $sigfile = "C:\ft\sig\ndxrsi51.sig" $sig = "ndx51" EndIf If $nsig = 6 Then $sigfile = "C:\ft\sig\ndx5.sig" $sig = "ndx5" EndIf _FileReadToArray($sigfile, $aArray) $sig1 = ($aArray[$aArray[0]-1]) $Label1 = GUICtrlCreateListViewItem ( $sig & "|" & StringMid ($sig1, 3), 3 ) If StringLeft ($sig1, 1) = "S" Then GUICtrlSetBkColor(-1, 0xFF0000) EndIf If StringLeft ($sig1, 1) = "B" Then GUICtrlSetBkColor(-1, 0x00FF00) EndIf Next EndSelect WEnd Is it possible to clear the array after each loop? Yes you can either delete each index or you can set the array to ZERO, but you may have to recreate the variable as an array. Your code shows $GS - is this a button or something? That might explain a little. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator 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