Im stuck again.
new template to correct section (also check so no other key have the same value).
update selected template.
and delete template.
I managed to write a new template but as soon as I used more lines it broke the ini file...
Code: Select all
/*
iniContent:=
(
"[Template_Common]
Phone=List
Members=A B C
Error=code
[Template_Mail]
Send=Email
Reply=Email
CC=Email
[Template_Request]
Call=Phone number"
)
FileDelete,iniFile.ini
FileAppend,% iniContent,iniFile.ini
*/
oIni:={}
oKeys:={}
IniRead,sectNames,iniFile.ini
for a,b in oSectNames:=StrSplit(sectNames,"`n","`r")
{ oIni[b]:={}
IniRead,Section,iniFile.ini,% b
ddl.=b "|"
for c,d in StrSplit(Section,"`n","`r")
{ RegExMatch(d,"^([^=]*?)=(.*)",match)
if oKeys.HasKey(match1)
MsgBox,% "Key already exits: """ match1 """"
else
{ oKeys[match1]:=match2
oIni[b,match1]:=match2
}
}
}
for a,b in oIni[oSectNames[1]]
Lb.=a "|"
Gui, Add, DropDownList, x12 y9 w150 r3 Choose1 vvSection ggSelectSect,% SubStr(ddl,1,-1) ; List of Section's
Gui, Add, Button, x172 y9 w90 h20 ggNewTemplate vvNewTemplate, New Template
Gui, Add, Button, x292 y9 w90 h20 ggUpdateTemplate vvUpdateTemplate, Update
Gui, Add, Button, x292 y9 w90 h20 ggSaveTemplate vvSaveTemplate, Save
Gui, Add, Button, x412 y9 w90 h20 ggDeleteTemplate vvDeleteTemplate, Delete
Gui, Add, ListBox, x12 y39 w150 h200 vvLb ggInsertVal,% SubStr(Lb,1,-1) ; List of Keys from Section selected in DropDownList.
Gui, Add, Edit, y39 x12 h20 w150 vvNewKey
Gui, Add, Edit, x172 y39 w340 h200 vvEdit ; Key Value based on Key selected in Listbox.
Gui, Show, w526 h254, Untitled GUI
GuiControl, hide, vNewKey
GuiControl, hide, vSaveTemplate
return
gInsertVal:
Gui Submit, NoHide
GuiControl,,vEdit,% oKeys[vLb]
return
gSelectSect:
Gui Submit, NoHide
Lb:="|"
for a,b in oIni[vSection]
Lb.=a "|"
GuiControl,,vLb,% SubStr(Lb,1,-1)
return
gNewTemplate:
if hide {
GuiControl, Show, vLb
GuiControl, hide, vNewKey
GuiControl,,vEdit,% oKeys[vLb]
GuiControl,,vNewTemplate, New Template
GuiControl, Show, vUpdateTemplate
GuiControl, Hide, vSaveTemplate
GuiControl, Show, vDeleteTemplate
}
else {
GuiControl, Hide, vLb
GuiControl, show, vNewKey
GuiControl,,vEdit
GuiControl,,vNewTemplate, Template list
GuiControl, hide, vUpdateTemplate
GuiControl, Show, vSaveTemplate
GuiControl, Hide, vDeleteTemplate
}
hide:=not hide
return
gUpdateTemplate:
Gui, Submit, NoHide
MsgBox, 1,Update Template?, Template: %vLb%`n%vEdit%
IfMsgBox OK
MsgBox You pressed OK.
else
MsgBox You pressed Cancel.
return
gSaveTemplate:
Gui, Submit, NoHide
MsgBox, 1,Save Template?, Category: %vSection%`nKey: %vNewKey%`n%vEdit%
IfMsgBox OK
MsgBox You pressed OK.
else
MsgBox You pressed Cancel.
return
gDeleteTemplate:
Gui, Submit, NoHide
MsgBox, 4,Delete Template?, Are you sure you want to delete template: %vLb%?
IfMsgBox Yes
MsgBox You pressed Yes.
else
MsgBox You pressed No.
return
GuiClose:
ExitApp