cal Posted October 11, 2013 Share Posted October 11, 2013 I've run into a problem. Before I rewrite a function to take this into account I thought I'd ask if there is an easier way. I use Opt("GUIOnEventMode", 1) because it just makes more sense to me. I don't know if that is related but since its not the default I thought I'd mention it. I have a script does a few things but the issue I have is a particular function. This function fills out forms on a web page in a loop as it works though the data in an array. Sometimes the form errors out (server issue, not my script) and the data does not make it though. I then delete that corrupt record and let the script redo it. For this purpose I have a simple mesg box that pops up so I can hit retry or continue. The script fills the form and pops up a mesg box. If all went good I press continue and the next record is loaded. If it errored out, I fix it and hit retry. It will reload and refill the form with the same data. It works fine. This method works but is not ideal as the mesg box pops up in the center of of my main screen and the gui is running is off in a corner of a different monitor. The problem is that I can't seem to put buttons on the gui that serves this same purpose. In fact the button does not get recognized as being pressed. With a bit of playing around I see that its because the function that is running the form fill routine was called from a button. If the fill form routine is not running, then the button press is recognized fine. No button that calls functions will do anything when another function is in progress. I kind of thought that what "onEventMode" ment. Any called func would interrupt whatever was running, do its own thing and when done, the orig running code would continue. Guess not. I had thought I'd be able to make the form fill routine go into a tight loop and wait for a var to change. This other "continue/retry" buttons would simply set that var and the original routine would then see the change and continue its job. This does not work. I can rewrite the form fill func so that it kicks out on an error and does some checking, so that the next time it runs it continues with the array data from where it left off. I suppose this might be better in the long run. But it seems there is likely a simple way for a func to get some sort of user input via the gui that called it part way though its job without resorting to a mesg box. I'd like the data being shown to me to stay over in the gui box on the other monitor. If I created a secondary gui that popped up beside the main one when I wanted to pause, would that work. Or would it have the same problem? Ideas??? Or am I looking at reworking the logic in my form fill function. I suppose I could use AdlibRegister to check for the existence of my mesg box and move it as soon as it appears. I don't know why I never thought of that at work today. That should be simple. I'm taking a 4 day weekend so I'll be back to try whatever on Tuesday. So what is the best way to handle this? Move the mesg box and move on (assuming that works). rework the logic in the function. Something else? Cal. Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted October 11, 2013 Moderators Solution Share Posted October 11, 2013 cal,I suggest reading the Interrupting a running function tutorial in the Wiki - that shows you how you can get controls to break into your function. If you are still stuck then please post a short reproducer script so that we can decide how to integrate one of the interruption strategies into your specific code. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
cal Posted October 11, 2013 Author Share Posted October 11, 2013 Very interesting. I did not know functions were queued like that. I never noticed that in my own testing as my form filling func was running a long loop and I never actually let it complete fully when I was testing. Thank you very much for the link. The first method shown of calling the first func from main code via a flag will definitely work for my purposes. I want it to run, do some work and then go into a tight loop waiting for flag2 before continuing and taking action based on the second flag. Flag2 will be set via buttons on the gui and since the first func will now be initiated from the main code, the buttons should be able to interrupt it to set flag2. I'll give it a try on Tuesday when I'm back in the office and report back with my results. The other methods look interesting as well. Hotkeys I understand, but I've run into issue with conflicts with other scripts and tend to avoid them if possible nowadays. Accelerator keys look promising but I need a better understanding of them first. I have never used "Windows message handlers" so I think I'll go through the other tutorial mentioned as well. Thanks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 11, 2013 Moderators Share Posted October 11, 2013 cal,Do not hesitate to come back if you have any questions. Message handlers are not really that difficult to understand - honest! M23 Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
cal Posted October 15, 2013 Author Share Posted October 15, 2013 Just had a chance to try the stuff at the link you gave me. That works perfectly. Thanks. Cal. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 15, 2013 Moderators Share Posted October 15, 2013 cal,Delighted that I (and my tutorials) could help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now