From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-26-2017 07:40 AM
Hello,
i got a problem. In main script im including secondary script, in which im calling autoquit. The secondary script returns to main script and continue executing the rest of commands in main script.
How can i kill the script in included scripts?
Main.vbs
LogfileWrite "start" Call ScriptStart(CurrentScriptPath & "Secondary.vbs") LogfileWrite "im still living"
Secondary.vbs
LogfileWrite "im in and dying" autoquit LogfileWrite "i will not execute this command"
When i run Main.vbs, i got following result:
start
im in and dying
i am still living
Solved! Go to Solution.
04-26-2017 08:02 AM
Hi,
You can use this in a subscript:
call Err.Raise(1,"","")
Regards
04-26-2017 08:17 AM
I tested it and it has the same behavior as autoquit. it kills following instructions in a subscript, but returns to main script and continue.
04-26-2017 08:36 AM
Sorry I misunderstood your question 🙂
I'm not sure if there is anything like this.
The only workaround I know is creating a global variable with globaldim command, set this variable inside the subscript when it's cancelled and check it in the calling script.
Main script:
call GlobalDim("Cancelled") Cancelled = false call ScriptStart(CurrentScriptPath & "SubScript.vbs") if not Cancelled then 'continue here if sub script was not cancelled call MsgBox("End") end if
Sub script:
Cancelled = true
04-26-2017 09:05 AM
Yep, this is the solution i was thinking about as well, but i wanted to know if there is some "ultimate autoquit" function 🙂
thanks
04-27-2017 02:02 AM
I would use
err.raise
like sugested, because it is the default VBS way to transport errors.
Main.vbs
LogfileWrite "start" on error resume next Call ScriptStart(CurrentScriptPath & "Secondary.vbs") if 0 <> err.number then LogfileWrite "Error occured in Secondary: " & err.Description end if on error goto 0 LogfileWrite "im still living"
Secondary.vbs
LogfileWrite "im in and dying" call err.Raise(100, currentScriptName, "Secondary failed") LogfileWrite "i will not execute this command"