Jump to content

Recommended Posts

Posted

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)

Posted

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

Posted

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? 🤔

Posted

@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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...