Shark007 Posted December 18, 2019 Posted December 18, 2019 Is it possible to tell a script to complete a function call (no longer actively executing anything) before moving on the the next directive in the script?
Nine Posted December 18, 2019 Posted December 18, 2019 Not exactly but very close, read how to run a script from another script in this : https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Danp2 Posted December 18, 2019 Posted December 18, 2019 Isn't that "standard" behavior, ie: the script won't proceed to the next command until the function returns? Latest Webdriver UDF Release Webdriver Wiki FAQs
Shark007 Posted December 18, 2019 Author Posted December 18, 2019 Thanks Nine, but not quite getting there. I have worked around the issue by copy the contents of the Func Called to the current executing function but the reason it is in a function in the 1st place is that the Func Called is used in several places throughout the script but being the the Func Called is not completed consecutively, but concurrently, it is interacting with latter functions within the script and ultimately causing the script to crash. Danp2, that is not my experience (in the case that I describe above)
Danp2 Posted December 18, 2019 Posted December 18, 2019 Sorry... but I'm not getting the issue. Maybe you could post a short reproducer? Latest Webdriver UDF Release Webdriver Wiki FAQs
Shark007 Posted December 18, 2019 Author Posted December 18, 2019 my script is 3500 lines and just to complex (includes several non-official UDF's) to just tear apart and create a reproducer my workaround woks OK but I'd have preferred to keep it wrapped in a function for neatness (aprox 100 lines) and also the removal of duplicate code. As my title suggests, "is something like RunWait(Func()) possible"; I was just looking for a way to force the function to complete before the parent function moved on Maybe the real issue here is that I am discussing a function within a function
Danp2 Posted December 18, 2019 Posted December 18, 2019 For me, the real issue is that I haven't grasped the actual issue yet. 😄 Here's a simple example from the help file where I added the Test function. #include <Date.au3> #include <Math.au3> #include <MsgBoxConstants.au3> Example() Test("main") Func Example() ; Sample script with two user-defined functions. ; Notice the use of variables, ByRef and Return. Local $iFoo = 2 Local $iBar = 5 MsgBox($MB_SYSTEMMODAL, "", "Today is " & Today() & @CRLF & "$iFoo equals " & $iFoo) Swap($iFoo, $iBar) MsgBox($MB_SYSTEMMODAL, "", "After swapping $iFoo and $iBar:" & @CRLF & "$iFoo now contains " & $iFoo) MsgBox($MB_SYSTEMMODAL, "", "Finally:" & @CRLF & "The larger of 3 and 4 is " & _Max(3, 4)) Test("func") EndFunc ;==>Example Func Swap(ByRef $vVar1, ByRef $vVar2) ; Swap the contents of two variables. Local $vTemp = $vVar1 $vVar1 = $vVar2 $vVar2 = $vTemp EndFunc ;==>Swap Func Today() ; Return the current date in mm/dd/yyyy form. Return @MON & "/" & @MDAY & "/" & @YEAR EndFunc ;==>Today Func Test($sText) MsgBox($MB_SYSTEMMODAL, "Test", $sText) EndFunc This demonstrates that the Example() function will finish executing in it's entirety before the subsequent line (Test("main")) is executed. I known you asked about RunWait, but you haven't demonstrated (to me at least) why this would be needed. What an I missing? 🤔 Latest Webdriver UDF Release Webdriver Wiki FAQs
Shark007 Posted December 18, 2019 Author Posted December 18, 2019 @Danp2 Thanks for taking the time to try and understand my question and assist me. I thought I'd play with your posted script a little bit and reproduce my dilemma in a simple manner. I was not able to reproduce it (as it exists in my mind at least) Thanks for the eye opener to the fact that I perceived my issue with an incorrect hypothesis.
Danp2 Posted December 18, 2019 Posted December 18, 2019 @Shark007 No problem. Let us know if you hit another snag. 🙂 Latest Webdriver UDF Release Webdriver Wiki FAQs
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