Guest joelee Posted April 12, 2005 Posted April 12, 2005 How do i stop a script within the script?I wish for the script to stop if a certain condition is met.I thought it was something like "Close" or "Exit"
DiGGiTY Posted April 12, 2005 Posted April 12, 2005 Never had to do this, but I dug some info up for you.There is IActiveScriptSiteInterruptPoll, with the single method QueryContinue(). Both the VBScript and JScript engines query for it, and when you return S_FALSE from QueryContinue(), the script stops executing.So say you wanted to run a script within a user interface. While the script is running, you display a "please wait" dialog box with a "stop" button on it. When the user presses the button, set your m_bQuit flag to TRUE, and then implement QueryContinue like this. STDMETHOD(QueryContinue)() { // ... pump any windows messages so the stop button can be pressed if (m_bQuit) return S_FALSE; return S_OK; }
IcemanND Posted April 12, 2005 Posted April 12, 2005 wscipt.Quit (interrorcode)intErrorCode Optional. Integer value returned as the process's exit code. If you do not include the intErrorCode parameter, no value is returned.
dman Posted April 12, 2005 Posted April 12, 2005 or you could just set a flag and bypass remaing code if flag is sethere is vbscript language reference.http://msdn.microsoft.com/library/default....oriVBScript.asp
Fredledingue Posted April 12, 2005 Posted April 12, 2005 If MyCondition = XYZ Thenwscipt.Quit MsgBox "Action canceled"End IfI don't know what else you would need...
Guest joelee Posted April 13, 2005 Posted April 13, 2005 I forgot to mention that there won't be any user interaction as it's a script set to run in the night/morningNever had to do this, but I dug some info up for you.There is IActiveScriptSiteInterruptPoll, with the single method QueryContinue(). Both the VBScript and JScript engines query for it, and when you return S_FALSE from QueryContinue(), the script stops executing.So say you wanted to run a script within a user interface. While the script is running, you display a "please wait" dialog box with a "stop" button on it. When the user presses the button, set your m_bQuit flag to TRUE, and then implement QueryContinue like this. STDMETHOD(QueryContinue)() { // ... pump any windows messages so the stop button can be pressed if (m_bQuit) return S_FALSE; return S_OK; }<{POST_SNAPBACK}>
Guest joelee Posted April 13, 2005 Posted April 13, 2005 iceman - cheers mate, works a treatall - thnaks for helpwscipt.Quit (interrorcode)intErrorCode Optional. Integer value returned as the process's exit code. If you do not include the intErrorCode parameter, no value is returned.<{POST_SNAPBACK}>
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