Announcement

Collapse
No announcement yet.

Exiting a script from a subroutine.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Exiting a script from a subroutine.

    I am looking to standardize the exiting of all my scripts by creating a sub that among other things will update the log file, then exit the script.

    When I want to exit the script, which can happen in various locations, I want to call the "subExit". Currently, in main, I just have the "exit sub" command.

    The VBScript command WScript.Quit does not work, and executing "exit sub" in subExit just puts me back to the main sub.

    Is there a way to make WScript work, or is there some HS exit command I am missing?

    Thanks for all...

    Richard

    #2
    Well, without verifying a few things I can make some suggestions off the top of my head that I think will work...

    1. In Sub Main have it call another sub that is your true "workhorse" subroutine, and then after the call to this sub in Main you can have your exit code. Thus, you said that exit sub kept returning you to Main, so use that knowledge and just make Main a launching point and ending point.
    e.g.
    Sub Main(parm)

      DoItAll parm

      hs.WriteLog "Exiting my script","Exit information here."

    End Sub

    Sub DoItAll(parm)

      ' Doing all my work today, doo dah, doo dah...

      Exit Sub

    End Sub



    Another way I thought of involved On Error handling and raising error events, but I think the above idea is much better so let's see if that works for you.



    Regards,

    Rick Tinker
    HomeSeer Technologies

    Regards,

    Rick Tinker (a.k.a. "Tink")

    Comment


      #3
      Thanks for the reply.

      I would imagine a "wish list" item would be an "HS.Quit".

      The layout you gave looks like it will work fine. Sometimes simplicity is right under your nose.

      Time to start to edit the 80 or so scripts I have... doo daah, doo daah :-)

      Richard

      Comment

      Working...
      X