Code: Select all
; ------------------------------------------------------------------------------
; Read the INI file into an array
Menus := []
Loop, %BtnCount%
{
IniRead, Menu, %IniFile%, %A_Index%, Menu, %A_Index%
IniRead, Price, %IniFile%, %A_Index%, Price, %A_Space%
IniRead, Options, %IniFile%, %A_Index%, Options, %A_Space%
Menus[A_Index] := {Name: Menu, Price: Price, Options: Options}
}
Code: Select all
; ##############################################################################
Gui, 7:Margin, 10, 10
Gui, 7:Add, Text, h20 0x0200 Section, Enter new name:
Gui, 7:Add, Text, xs hp 0x0200, Enter new price:
W := BtnW - 10
Gui, 7:Add, Edit, ys w%W% h20 Limit vNewName
Gui, 7:Add, Edit, xp y+m wp h20 Limit vNewPrice
GuiControlGet, P, 7:Pos, NewPrice
Gui, 7:Add, Text, xm, Options:
W := PW + PX - 10
Gui, 7:Add, Edit, xm y+2 w%W% r5 vNewOptions
Gui, 7:Add, Button, xm w80 gWriteIni, Apply
X := PX + PW - 80
Gui, 7:Add, Button, x%X% yp wp g7GuiClose, Cancel
; ##############################################################################
Code: Select all
; ##############################################################################
WriteIni:
Gui, Submit, NoHide
; MsgBox, 0, New Values, Name:`t%NewName%`n`nPrice:`t%NewPrice
GuiControl, 6:, Btn%BtnNumber%, %NewName%
Iniwrite, %NewName%, %IniFile%, %BtnNumber%, Menu
Iniwrite, %NewPrice%, %IniFile%, %BtnNumber%, Price
Options := StrReplace(Trim(RTrim(NewOptions, "`n")), "`n", "|")
Iniwrite, %Options%, %IniFile%, %BtnNumber%, Options
Menus[BtnNumber, "Name"] := NewName
Menus[BtnNumber, "Price"] := NewPrice
Menus[BtnNumber, "Options"] := Options
Gosub, 7GuiClose
Return
; ##############################################################################
Set:
BtnNumber := SubStr(A_GuiControl, 4)
GuiControl, 7:, NewName, % Menus[BtnNumber, "Name"]
GuiControl, 7:, NewPrice, % Menus[BtnNumber, "Price"]
GuiControl, 7:, NewOptions, % StrReplace(Menus[BtnNumber, "Options"], "|", "`n")
Gui, +Disabled
Gui, 7:Show, , Button %BtnNumber%
Return
; ##############################################################################