The code below works, but I'm asking this question specifically to reduce code redundancy since the GUI I'm working on will repeat this pattern about 36 times and writing a subroutine for each one won't look very pretty.
Code: Select all
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
IniRead, VarX1, Example.ini, Section1, Var
IniRead, VarX2, Example.ini, Section2, Var
IniRead, VarX3, Example.ini, Section3, Var
Gui Add, GroupBox, x8 y8 w116 h90, Group 1
Gui Add, Text, x16 y53 w32 h23, Var X:
Gui Add, Edit, x16 y68 w45 h21 vVarX1 gVarX1, %VarX1%
Gui Add, UpDown, gVarX1 Range0-999, %VarX1%
Gui Add, GroupBox, x128 y8 w116 h90, Group 2
Gui Add, Text, x136 y53 w32 h23, Var X:
Gui Add, Edit, x136 y68 w45 h21 vVarX2 gVarX2, %VarX2%
Gui Add, UpDown, gVarX2 Range0-999, %VarX2%
Gui Add, GroupBox, x248 y8 w116 h90, Group 3
Gui Add, Text, x256 y53 w32 h23, Var X:
Gui Add, Edit, x256 y68 w45 h21 vVarX3 gVarX3, %VarX3%
Gui Add, UpDown, gVarX3 Range0-999, %VarX3%
Gui Show, w373 h106, Example
Return
VarX1:
Gui, Submit, NoHide
IniWrite, %VarX1%, Example.ini, Section1, Var
Return
VarX2:
Gui, Submit, NoHide
IniWrite, %VarX2%, Example.ini, Section2, Var
Return
VarX3:
Gui, Submit, NoHide
IniWrite, %VarX3%, Example.ini, Section3, Var
Return
Code: Select all
[Section1]
Var=7
[Section2]
Var=5
[Section3]
Var=3