BlackDawn187 Posted January 20, 2014 Share Posted January 20, 2014 (edited) So to elaborate on the title of this topic, I'm having issues displaying array elements inside of a For loop that contain duplicate strings. For example: $List2[2][1] = 1.0 -- If 1.0 is repeated in the For loop at any point, AutoIt ignores it an prints the next "non-duplicated" string To illustrate my problem, I'll use this sample code, Which is very raw in nature; Func List($Origin, $Destination, $Destination2, $Message) $FuncName = "List" $DestFunc = "Console" FileDelete("" & @TempDir & "\list.ini") $LocalAddress = IniRead("Config.ini", "Global Settings", "Address", "") InetGet("" & $LocalAddress & "list.ini", "" & @TempDir & "\list.ini", 1, 0) $List = IniReadSectionNames("" & @TempDir & "\list.ini") For $i = 1 To $List[0] GUICtrlSetData($Console, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] [" & $Title & " v" & $Version & "]: [" & $List[$i] & "]") $List2 = IniReadSection("" & @TempDir & "\list.ini", "" & $List[$i] & "") If @error Then $ConsoleMessage = "[" & $Title & " v" & $Version & "]: Error" $DestFunc2 = "Idle" Call("Console", $FuncName, $DestFunc, $DestFunc2, $ConsoleMessage) FileDelete("" & @TempDir & "\list.ini") Else GUICtrlSetData($Console, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] [" & $Title & " v" & $Version & "]: Version - " & $List2[2][1] & "") GUICtrlSetData($Console, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] [" & $Title & " v" & $Version & "]: Developed By - " & $List2[1][1] & "") _ArrayDelete($List2, 1) _ArrayDelete($List2, 2) EndIf Next Call("Idle") FileDelete("" & @TempDir & "\list.ini") EndFunc In theory, This code should write to the GUI List Control named $Console, Which it does. The problem exists where duplicate elements exist, Rather than showing the elements, AutoIt automatically parses them out an doesn't display anything. Except for the next non-duplicate element. I've tried deleting the array/element all together as you'll see in the code. But, I can't seem to get it to display regardless. Other than this issue, The code works for what I need it to do. If anyone could offer any suggestions or work arounds for displaying the elements that have duplicate strings, It would greatly be appreciated. Edit: Including example of list.ini [Example] Version=1.0 Author=Test [Example2] Version=1.0 Author=Test [Example3] Version=2.0 Author=Test2 [Example4] Version=3.0 Author=Test3 In regards to the list.ini -- The section names will be displayed correctly. But, Example and, Example2 have identical values, Which will not display. Example3 and, Example4 have unique values, Which do display. My problem lies within displaying identical values. Though I can't determine if the problem is caused from my code or, with GUICtrlSetData. Which states: For Combo or List controls : If the "data" corresponds to an already existing entry it is set as the default. If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed. Edited January 20, 2014 by BlackDawn187 Link to comment Share on other sites More sharing options...
jchd Posted January 20, 2014 Share Posted January 20, 2014 In your code, $List is a 1D array, so your remark about "$List[2][1] = 1.0 -- If 1.0 is repeated in the For loop at any point" doesn't make sense. What seem to confuse you is that .INI files don't allow for duplicate sections or duplicate keys in the same section. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
BlackDawn187 Posted January 20, 2014 Author Share Posted January 20, 2014 (edited) In your code, $List is a 1D array, so your remark about "$List[2][1] = 1.0 -- If 1.0 is repeated in the For loop at any point" doesn't make sense. What seem to confuse you is that .INI files don't allow for duplicate sections or duplicate keys in the same section. Sorry for the confusion, In the midst of using similar variables I used the wrong one in that statement. It's supposed to read as: For example: $List2[2][1] = 1.0 -- If 1.0 is repeated in the For loop at any point, AutoIt ignores it an prints the next "non-duplicated" string Notice, It was supposed to read $List2[2][1] not $List[2][1], Where $List2 is a 2D array. Updated OP, Thanks for the observation. There are no duplicate sections. Edited January 20, 2014 by BlackDawn187 Link to comment Share on other sites More sharing options...
BrewManNH Posted January 20, 2014 Share Posted January 20, 2014 From the help file. Remarks For Combo or List control : If the "data" corresponds to an already existing entry it is set as the default. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
BlackDawn187 Posted January 20, 2014 Author Share Posted January 20, 2014 From the help file. Any suggestions on how to get past that? Link to comment Share on other sites More sharing options...
jchd Posted January 20, 2014 Share Posted January 20, 2014 What would be the purpose of a combo with several identical values, like "A, A, A, pick any one". This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
BlackDawn187 Posted January 20, 2014 Author Share Posted January 20, 2014 What would be the purpose of a combo with several identical values, like "A, A, A, pick any one". My purpose of a list, That contains identical values under different .Ini Section Names. Is to display version and, author values of loaded scripts in a GUI. Which is obtained through list.ini located on a web server. Though, I can't find a work around for bypassing; For Combo or List control :If the "data" corresponds to an already existing entry it is set as the default. Link to comment Share on other sites More sharing options...
BrewManNH Posted January 20, 2014 Share Posted January 20, 2014 Try building the list data before setting it to the list control, then you can have duplicate entries. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $MESSAGE = "The following buttons have been clicked" Local $add, $clear, $mylist, $close, $msg GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $mylist = GUICtrlCreateList("", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) Local $Text = "" For $I = 1 to 100 $Text &= "List data|" Next GUICtrlSetData($mylist, $Text) GUISetState(@SW_SHOW) $msg = 0 ; Loop until the user exits. While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $close Exit EndSelect WEnd EndFunc ;==>Example If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Solution BlackDawn187 Posted January 20, 2014 Author Solution Share Posted January 20, 2014 Try building the list data before setting it to the list control, then you can have duplicate entries. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $MESSAGE = "The following buttons have been clicked" Local $add, $clear, $mylist, $close, $msg GUICreate("My GUI list") ; will create a dialog box that when displayed is centered $mylist = GUICtrlCreateList("", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $MESSAGE) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) Local $Text = "" For $I = 1 to 100 $Text &= "List data|" Next GUICtrlSetData($mylist, $Text) GUISetState(@SW_SHOW) $msg = 0 ; Loop until the user exits. While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $close Exit EndSelect WEnd EndFunc ;==>Example So with that, I built $ListVersion & $ListAuthor variables, Then SetData accordingly below. $ListVersion = "" & $List2[2][1] & "|" $ListAuthor = "" & $List2[1][1] & "|" GUICtrlSetData($Console, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] [" & $Title & " v" & $Version & "]: Version - " & $ListVersion & "") GUICtrlSetData($Console, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] [" & $Title & " v" & $Version & "]: Developed By - " & $ListAuthor & "") GUI Output is now what was expected. Problem resolved. Thanks everyone. 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