Trying to create a Settings manager for my AHK program.
I have an Apply and OK button that Should commit changes to the INI file(s).
Code:
Gui2OK:
IniWrite, 0, %servicedeskini%, GUI, Save_Finished
Sleep, 100
GoSub, Gui2Apply
Gui2OKRepeat:
IniRead, %Save_Finished%, %servicedeskini%, GUI, Save_Finished
If (%Save_Finished% = )
{
Sleep, 100
GoSub, Gui2OKRepeat
}
Gui, Destroy
Gui2Apply:
GuiControlGet, SalwaysOnTop
Salwaysontop = %SalwaysOnTop%
IniWrite, %SalwaysOnTop%, %preferencesini%, Gui, alwaysontop
GuiControlGet, SRemedy_Name
Remedy_Name = %SRemedy_Name%
IniWrite, %Remedy_Name%, %preferencesini%, Agent, remedy_name
GuiControlGet, SEmail_Name
Email_Name = %SEmail_Name%
IniWrite, %Email_Name%, %preferencesini%, Agent, email_name
GuiControlGet, SAgent_Initials
Agent_Initials = %SAgent_Initials%
IniWrite, %Agent_Initials%, %preferencesini%, Agent, initials
GuiControlGet, ST2_queue
T2_queue = %ST2_queue%
IniWrite, %T2_queue%, %preferencesini%, Agent, t2_queue
GuiControlGet, SAgent_Title
Agent_Title = %SAgent_Title%
IniWrite, %Agent_Title%, %preferencesini%, Agent, agent_title
GuiControlGet, Sqc_signature
qc_signature = %Sqc_signature%
IniWrite, %qc_signature%, %preferencesini%, Agent, qc_signature
GuiControlGet, Savailable_HK
available_HK = %Savailable_HK%
IniWrite, %Savailable_HK%, %preferencesini%, Hotkeys, available
GuiControlGet, Savailable_w_TP_HK
available_w_TP_HK = %Savailable_w_TP_HK%
IniWrite, %Savailable_w_TP_HK%, %preferencesini%, Hotkeys, available_w_TP
GuiControlGet, Savailable_no_acd_HK
available_no_acd_HK = %Savailable_no_acd_HK%
IniWrite, %Savailable_no_acd_HK%, %preferencesini%, Hotkeys, available_no_acd
GuiControlGet, Scallers_tickets_HK
callers_tickets_HK = %Scallers_tickets_HK%
IniWrite, %Scallers_tickets_HK%, %preferencesini%, Hotkeys, callers_tickets
GuiControlGet, Semail_caller_HK
email_caller_HK = %Semail_caller_HK%
IniWrite, %Semail_caller_HK%, %preferencesini%, Hotkeys, email_caller
GuiControlGet, Sresolve_qc_HK
resolve_qc_HK = %Sresolve_qc_HK%
IniWrite, %resolve_qc_HK%, %preferencesini%, Hotkeys, resolve_qc
GuiControlGet, Swip_ticket_HK
wip_ticket_HK = %Swip_ticket_HK%
IniWrite, %wip_ticket_HK%, %preferencesini%, Hotkeys, wip_ticket
GuiControlGet, St2_day1_HK
t2_day1_HK = %St2_day1_HK%
IniWrite, %t2_day1_HK%, %preferencesini%, Hotkeys, t2_day1
GuiControlGet, St2_day2_HK
t2_day2_HK = %St2_day2_HK%
IniWrite, %t2_day2_HK%, %preferencesini%, Hotkeys, t2_day2
GuiControlGet, St2_day4_HK
t2_day4_HK = %St2_day4_HK%
IniWrite, %t2_day4_HK%, %preferencesini%, Hotkeys, t2_day4
;GuiControlGet, activate_outlook_HK
;IniWrite, %activate_outlook_HK%, %preferencesini%, Hotkeys, activate_outlook
;GuiControlGet, activate_remedy_HK
;IniWrite, %activate_remedy_HK%, %preferencesini%, Hotkeys, activate_remedy
;Save_Finished is to help ensure that the Gui does not get destroyed until the Program has finished saving the settings.
IniWrite, 1, %servicedeskini%, GUI, Save_Finished
Return
Clicking the Apply button in my GUI jumps to the Gui2Apply Label Which records all the settings to the INI files and then returns to the Settings GUI thread. Clicking "OK" calls the Gui2OK which Records 0 to my Save_Finished setting in the INI then Calls the Gui2Apply. The last command in the Gui2Apply is to change the Save_Finished setting in my INI to 1. The next command in the Gui2OK label is to check if the Save_Finished is set to 1 and only proceed to Destroy the GUI once the Variable has changed. As you can see from my code here I'm trying to use an If statement along with a GoSub command to continue checking the INI file waiting for the change. I've also tried using a While loop... No matter which way I go I run into the same problem I get an error that the dynamic variable in my IniRead command, %Save_Finished%
Quote:
---------------------------
3sT.ahk
---------------------------
Error: This dynamic variable is blank. If this variable was not intended to be dynamic, remove the % symbols from it.
Specifically: %Save_Finished%
Line#
295: Gui,+AlwaysOnTop -SysMenu +Owner
296: Return
299: Gui,Destroy
300: Return
304: IniWrite,0,%servicedeskini%,GUI,Save_Finished
305: Sleep,100
306: Gosub,Gui2Apply
---> 308: IniRead,%Save_Finished%,%servicedeskini%,GUI,Save_Finished
309: if (%Save_Finished% = 0)
310: {
311: Sleep,100
312: Gosub,Gui2OKRepeat
313: }
314: Gui,Destroy
318: GuiControlGet,SalwaysOnTop
---------------------------
OK
---------------------------