Jump to content

Recommended Posts

Posted

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.

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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̨º»®**'jw¢{Zw(uæèÄ­¶

Maybe that will be helpful? Again thanks for any help you can provide.

  • Moderators
Posted

WiSp,

I hate to contradict wraithdu, but try Execute in place of Eval.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

WiSp,

I hate to contradict wraithdu, but try Execute in place of Eval.

M23

That was it! Learn something new everyday!

Thank you everyone who threw out ideas!

Posted (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 by wraithdu
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...