WiSp Posted February 4, 2009 Share Posted February 4, 2009 I've created an INI file with two sections of buttons, one has 18 buttons, one has 23. One section is called "[LocationButtons]" the other "[ActionButtons]". This is the file layout: CODE ### Button = "Button Face Title | Button Hint | Shown in Current Location" [LocationButtons] LButton1 = "Desk|At my desk|At desk" LButton2 = "LButton|LButton Hint|LButton Action" LButton3 = "LButton|LButton Hint|LButton Action" LButton4 = "LButton|LButton Hint|LButton Action" LButton5 = "LButton|LButton Hint|LButton Action" LButton6 = "LButton|LButton Hint|LButton Action" LButton7 = "LButton|LButton Hint|LButton Action" LButton8 = "LButton|LButton Hint|LButton Action" LButton9 = "LButton|LButton Hint|LButton Action" LButton10 = "LButton|LButton Hint|LButton Action" LButton11 = "LButton|LButton Hint|LButton Action" LButton12 = "LButton|LButton Hint|LButton Action" LButton13 = "LButton|LButton Hint|LButton Action" LButton14 = "LButton|LButton Hint|LButton Action" LButton15 = "LButton|LButton Hint|LButton Action" LButton16 = "LButton|LButton Hint|LButton Action" LButton17 = "LButton|LButton Hint|LButton Action" LButton18 = "LButton|LButton Hint|LButton Action" I'm trying to load the buttons by calling a function. This works but, obviously only changes the one button that's hard coded: CODE _FillButtonData("LocationButtons") Func _FillButtonData($ButtonGroup) $ButtonsArray = IniReadSection($GUIConfig,$ButtonGroup) If @error Then MsgBox(4096, "", "Error occurred, can't open INI file.") Else For $i = 1 To $ButtonsArray[0][0] GUICtrlSetData($LButton1,"Changed Label!") ;~ $tempstring = StringReplace($ButtonsArray[$i][1],"""","") ;~ $splitstring = StringSplit($tempstring,"|") ;~ $buttoncomposit = "$" & $ButtonsArray[$i][0] ;~ GUICtrlSetData($buttoncomposit,$splitstring[1]) ;~ GUICtrlSetTip($buttoncomposit,$splitstring[2]) ;;; Debug Info: ;~ msgbox(64,"Button", $buttoncomposit & " " & $splitstring[1] & @CRLF & $buttoncomposit & " " & $splitstring[2]) ;~ MsgBox(4096, "", "Key: " & $ButtonsArray[$i][0] & @CRLF & "Value: " & $ButtonsArray[$i][1]) Next EndIf EndFunc The problem is if I comment out the hard coded info and uncomment the variable lines, it doesn't seem to work. I suspect that it's not taking my button control IDs literally for some reason, but I'm not 100% sure what's going on. Please give me a little help, thanks in advance. Link to comment Share on other sites More sharing options...
wraithdu Posted February 4, 2009 Share Posted February 4, 2009 You are correct about the vars not being interpreted. Try $buttoncomposit = Eval($ButtonsArray[$i][0]) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 4, 2009 Moderators Share Posted February 4, 2009 WiSp,There is a another problem because you are not reading in the full values from the .ini file. When I use your current .ini file structure, all I get is the first element of the value ("Button) repeated for each key. This is because you are using the default separator character (|) to break up your values. If you change it for something else, you get the full value in your array.As an aside, when creating arrays I have always found it helpful to include Array.au3 and then use _ArrayDisplay to see what I am getting as a result. Just do not forget to comment it out later!I also believe you need to remove the "" from around the values in the .ini file. Hope this helps,M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
WiSp Posted February 4, 2009 Author Share Posted February 4, 2009 You are correct about the vars not being interpreted. Try $buttoncomposit = Eval($ButtonsArray[$i][0])oÝ÷ Ûú®¢×¡ë'ßÛlyé£ +Wë-j»h½êðØljeøuÊy©ÝjƦ¦W º,¨ºÈhºW[y¦åzÚ+º{aÀWjY^t¶ìx¬¥u·¢Ø^±©¶*'j̨º»®*m¶*'jw¢{Zw(uæèĶ Maybe that will be helpful? Again thanks for any help you can provide. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 4, 2009 Moderators Share Posted February 4, 2009 WiSp,I hate to contradict wraithdu, but try Execute in place of Eval.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
WiSp Posted February 4, 2009 Author Share Posted February 4, 2009 WiSp,I hate to contradict wraithdu, but try Execute in place of Eval.M23That was it! Learn something new everyday!Thank you everyone who threw out ideas! Link to comment Share on other sites More sharing options...
wraithdu Posted February 4, 2009 Share Posted February 4, 2009 (edited) I didn't say$composit = Eval("$" & $ButtonsArray[$i][0])I said$composit = Eval($ButtonsArray[$i][0])which does work. Execute also works, but for a different reason. Eval() is explicitly the correct function for what you want to do. Edited February 4, 2009 by wraithdu Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 5, 2009 Moderators Share Posted February 5, 2009 wraithdu,Thank you for that clarification. Amazing how you can read what you want to see in a post and not what is actually there.And I had been unclear about the difference between Eval and Execute - I should have followed my own advice and read the Help file more carefully! I withdraw without reservation my comment on your post and humbly agree that Eval is the correct function to use here. ;-)M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
wraithdu Posted February 5, 2009 Share Posted February 5, 2009 No problem. I learn new stuff every day Link to comment Share on other sites More sharing options...
WiSp Posted February 6, 2009 Author Share Posted February 6, 2009 Ahhh... I see. I was just thinking in my head how the heck I'm supposed to get the "$" in front of the "LButton1" in my config file in order to make sure that it tries to use "$LButton1" variable. It did not occur to me that it wasn't necessary for me to put the dollar sign in there. It makes sense to me now, and also makes sense now that I go back over the Eval entry in the help file. I just didn't understand this programming concept before, thanks for clarifying. Oh and I changed my code to use the proper method, but I'm filing the "execute" in the back of my head for those "WTH?!" situations. Thanks again for your time and effort. 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