IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#19008 - 01/18/06 09:46 AM quitting a script
stuartg Offline
OL Expert

Registered: 03/06/03
Posts: 713
Loc: Swindon, England
Hi
How can I quit from a VBscript in PP?
When running the script manually I just call Wscript.quit, but this is not available within scripts running in PP.
Any ideas?
Stuart

Top
#19009 - 01/18/06 10:44 AM Re: quitting a script
cosimo Offline
OL Expert

Registered: 10/31/01
Posts: 1286
Loc: montreal
Hi,

If I understand correctly, you want to quit the VBS while the PlanetPress Watch service is running.
If that is the case, you cannot quit while the service is running, it will end when the VBS is finished executing.
On the other hand if you are in a loop, you can put some code there that will quit or exit if it is in a loop.

Thanks
Cosimo
Team OL

Top
#19010 - 01/18/06 11:16 AM Re: quitting a script
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1984
Loc: Objectif Lune, Montreal, Qc
Stuart,

There's an easy way around it. You need to encapsulate your entire script within a Sub(). Then, you add a line at the very top of the script that calls this new Sub. And within the Sub itself, you simply use an Exit Sub command to interrupt processing.

For instance, let's say your original code looks something like this:
Code:
Dim x
for x=1 to 10
   ' do some processing here
   ' ...
   ' if somecondition then
        wscript.quit
     end if
   ' do some further processing here
   ' ...
next
you could change it to read like this:
Code:
Main

Sub Main()
  Dim x
  for x=1 to 10
     ' do some processing here
     ' ...
     ' if somecondition then
          exit sub
       end if
     ' do some further processing here
     ' ...
  next
end sub
Hope that helps.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#19011 - 01/19/06 07:11 AM Re: quitting a script
stuartg Offline
OL Expert

Registered: 03/06/03
Posts: 713
Loc: Swindon, England
Thanks Phillipe
That idea works OK so far.

But if the script already has subroutines, this method won't quit from inside the subroutine. I think I will have to set a global flag and keep checking it.

Thanks for your help
Stuart

Top