Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 12-14-2005, 12:10 PM
rjones0604 rjones0604 is online now
Registered User
 
Join Date: 12-02-2005
Posts: 4
Exit VBScript

I'm writing a VBScript step, and need to exit the script prematurely. However, WScript.Quit is not supported. So, how does one exit a script?

Rob
Reply With Quote
  #2  
Old 12-14-2005, 01:02 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
Use structured programming or put your code in a subroutine and exit the subroutine:

MySub ' call the subroutine

Sub MySub()

' some code

Exit Sub

' some more code

End Sub
Reply With Quote
  #3  
Old 12-14-2005, 01:08 PM
rjones0604 rjones0604 is online now
Registered User
 
Join Date: 12-02-2005
Posts: 4
So what you're really saying is that there is no way to exit a script, the script 'code' must completely execute. If I want to stop execution, I have to enclose the entire remainder of the script inside an 'If' test...

BTW, putting code in a subroutine and using the sub's 'Exit Sub' call does not shutdown a script, it merely exits the subroutine.
Reply With Quote
  #4  
Old 12-14-2005, 01:15 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
How would "exiting the script" be different from exiting the subroutine before the end? An Exit Sub statement within a subroutine prevents the remainder of the subroutine code from executing, which has the same effect as calling WScript.Quit in a .vbs file (preventing the remainder of the code in the .vbs file from executing).
Reply With Quote
  #5  
Old 12-14-2005, 01:16 PM
rjones0604 rjones0604 is online now
Registered User
 
Join Date: 12-02-2005
Posts: 4
Actually, the VBP online help says this about WScript:

A helper object to provide compatibility with WSH script code. It's actually an alias for the Builder object, so all methods on each object are available on both.


So, that means that the .Quit method is supposed to be available, right?
Reply With Quote
  #6  
Old 12-14-2005, 01:30 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,003
Actually, only the WScript CreateObject, Sleep, and Echo methods are supported (we'll update the docs to be explicit about that). But, again, there are other ways to exit a script "prematurely." Also, if you want to stop the build with an error from within script code, use

Err.Raise 1, Step.Name, "error description"
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 08:01 AM.


Copyright © 1999-2023 Kinook Software, Inc.