 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Tue Nov 17, 2009 10:50 pm Post subject: SOLVED: How to wait for multiple IniWrite commands... |
|
|
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
---------------------------
|
Last edited by samhnky on Thu Nov 19, 2009 5:49 pm; edited 1 time in total |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1158 Location: San Diego, California
|
Posted: Tue Nov 17, 2009 11:20 pm Post subject: |
|
|
The first parameter of IniRead is a variable, correct the problem line to read like this | Code: | | IniRead, Save_Finished, %servicedeskini%, GUI, Save_Finished |
Now that you have someone telling you the solution, please read the error message again. Perhaps it will make more sense now. |
|
| Back to top |
|
 |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Tue Nov 17, 2009 11:40 pm Post subject: Dee, dee, dee |
|
|
| Leef_me wrote: | The first parameter of IniRead is a variable, correct the problem line to read like this | Code: | | IniRead, Save_Finished, %servicedeskini%, GUI, Save_Finished |
Now that you have someone telling you the solution, please read the error message again. Perhaps it will make more sense now. |
Have you ever had one of those days where the whole day was like banging your head against a wall....? Now end that day with the realization that you built the you've been banging you head against trying to figure out why it is there! Thank you for your kind words in helping me see the error, for probably the last 3-4 hours at work I've been trying to fix my problem with the script writing empty variables to the ini file randomly and probably the last 2 hours was spent trying to get this "check" in place to mak sure the script didn't kill the variables before it finished writing to the file... I feel so sheepish now seeing what the problem is, everytime I read the error I thought it must have been a problem with accessing the file and it could not right any data to the variable...
Thanks again,
Sam (wanting to remove this thread to hide my stupidity just a little bit longer)  |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 1158 Location: San Diego, California
|
Posted: Wed Nov 18, 2009 12:21 am Post subject: |
|
|
Mr. Sam,
Please don't be so hard on yourself.
Look at the post states on the left side of our messages: Leef_me 904 samhnky 32
I have 30 times as many posts as you do. Probably half of those are trying to help others. Possibly 1/5 of those I gave poor advice.
In the last few days I was starting to think, "me not newbie" and then helping someone out took 8 replies from me, 2 wrong, 3 better, and 3 on the definition of "IS"
Because of that thread I realized I'm still a newbie and I learned about groupadd, and about using both program title & ahk_class in the "wintitle" parameter in various commands
Enjoy being a newbie while you can, it only lasts a lifetime.  |
|
| Back to top |
|
 |
samhnky
Joined: 29 Sep 2009 Posts: 43
|
Posted: Thu Nov 19, 2009 5:48 pm Post subject: Thanks again... this issue is solved. |
|
|
| After returning to work I removed the % signs from around the variable in my IniRead command and this has solved the error, and my IniRead loop has solved my problem with the GUI destroying all the new settings before the IniWrites are able to finish updating the file. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|