Can this INI write code be reduced

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Aperry91
Posts: 6
Joined: 30 Jun 2017, 19:11

Can this INI write code be reduced

20 Jul 2017, 17:46

I am working on a GUI with many fields that will be saved into an INI. It bugs me that I have to specify line by line each value I want saved. Is there a way to somehow loop an the variables so that I only have to use the INI write command once. It would look much cleaner, but this is a little beyond my knowledge.

Code: Select all

#SingleInstance, force

Sections = 
(
A = Project Name
B = Project Description
c = Remarks
d = Status
)

 Fields =
 (
 %field1%
 %field2%
 %field3%
 %Status%
 )

LIST1 = Yes|No|Maybe|Whatever||

sort, List1
;Gui +Delimiter`n
Gui, Add, Text, x10 w90 h20 , Project Name
Gui, Add, Text, x+10 w120 h20 , Project Description
Gui, Add, Text, x+80, Remarks
Gui, Add, Text, x+70 w90 h20 , Project Status
Gui, Add, Edit, vField1 x10 y+10 w90 h20 , %Field1% Project Name
Gui, Add, Edit, vField2 x+10 y34 w180 h20 , %Field2% Project Description
Gui, Add, Edit, vField3 X+5, %field3% Project Remarks
Gui, Add, DropDownList, vSTAT x+10 w130 h110 CHOOSE1, % LIST1
Gui, Add, Button, gwrite x10 Y+5 w70 h20 , Write
Gui, Show 
return

Write:
GUI, Submit, Nohide
IniWrite, %Field1%, myfile.ini, %Field1%, PROJECT 
IniWrite, %Field2%, myfile.ini, %Field1%, DESCRIPTION 
IniWrite, %Field3%, myfile.ini, %Field1%, DESCRIPTION 
IniWrite, %stat%, myfile.ini, %Field1%, STATUS 
return

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Can this INI write code be reduced

21 Jul 2017, 03:52

What about to check out INIWrite's > pairs < parameter, OR looping through the keys ... ? :)
Spoiler

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Nerafius, RandomBoy and 187 guests