Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


calling subroutine within subroutine, passing parent name

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49707
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> calling subroutine within subroutine, passing parent name
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 calling subroutine within subroutine, passing parent name - 7/19/2007 6:58:28 AM   
  itismike

 

Posts: 42
Score: 0
Joined: 7/7/2007
Status: offline
Hi again,

Been too long since I bugged people here.  I want to create a subroutine that handles error codes for several different - well - subroutines.

Here's the basic idea:

      

So my question is: is there a property that exists that contains the name of the parent subroutine that I could use to display it as "subRoutineName"?

TIA,
Mike
 
 
Post #: 1
 
 RE: calling subroutine within subroutine, passing paren... - 7/19/2007 8:03:48 AM   
  DiGiTAL.SkReAM


Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
No, vbs doesn't support that kind of introspection.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to itismike)
 
 
Post #: 2
 
 RE: calling subroutine within subroutine, passing paren... - 7/19/2007 8:27:05 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
Why don't you pass subRoutineName as a variable to your DisplayErr function?

DisplayError (subRoutineDoesSomethingCool)

_____________________________

Fred

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 3
 
 RE: calling subroutine within subroutine, passing paren... - 7/19/2007 8:43:24 AM   
  itismike

 

Posts: 42
Score: 0
Joined: 7/7/2007
Status: offline
Nice - that should work! Thanks Fredledingue

(in reply to Fredledingue)
 
 
Post #: 4
 
 RE: calling subroutine within subroutine, passing paren... - 7/20/2007 10:01:13 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
quote:

ORIGINAL: Fredledingue

Why don't you pass subRoutineName as a variable to your DisplayErr function?

DisplayError (subRoutineDoesSomethingCool)


Now, I'm thinking the above code is worng, this should be correct:
DisplayError ("subRoutineDoesSomethingCool")
 

Even worse: it could trigger your subroutine an infinite number of time! (or cause an error or some wierd effect)
The subroutine name is not a special object, it's merely a text string.
I don't know if there is a sub.name method so you will have to hardcode the sub name when calling the function.

< Message edited by Fredledingue -- 7/20/2007 10:04:16 AM >


_____________________________

Fred

(in reply to Fredledingue)
 
 
Post #: 5
 
 RE: calling subroutine within subroutine, passing paren... - 7/20/2007 11:18:28 AM   
  itismike

 

Posts: 42
Score: 0
Joined: 7/7/2007
Status: offline
No worries Fred.  I set two variables to pass into the function, and simply echoed them when necessary:


      

I haven't debugged it yet, so please tell me, but go easy on me if you see any blatant errors. ;-)
The "'  DESCRIBE???" comments are where I want to put in more comments, but I have absolutely no idea what those commands do.  All in good time.
Thanks for getting back to me,
-Mike

(in reply to Fredledingue)
 
 
Post #: 6
 
 RE: calling subroutine within subroutine, passing paren... - 7/20/2007 11:32:34 AM   
  DiGiTAL.SkReAM


Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
quote:

ORIGINAL: Fredledingue
I don't know if there is a sub.name method so you will have to hardcode the sub name when calling the function.


http://www.visualbasicscript.com/fb.aspx?m=49710


_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to Fredledingue)
 
 
Post #: 7
 
 RE: calling subroutine within subroutine, passing paren... - 7/20/2007 2:18:43 PM   
  itismike

 

Posts: 42
Score: 0
Joined: 7/7/2007
Status: offline
mmmm yeah... speaking of redundancy... thanks for your insight, SkReAM.

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 8
 
 RE: calling subroutine within subroutine, passing paren... - 7/20/2007 6:39:43 PM   
  DiGiTAL.SkReAM


Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
Sorry, I couldn't resist.

I should have, but I couldn't.

_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to itismike)
 
 
Post #: 9
 
 RE: calling subroutine within subroutine, passing paren... - 7/20/2007 9:07:21 PM   
  itismike

 

Posts: 42
Score: 0
Joined: 7/7/2007
Status: offline
WOW!! - Someone actually "got" my sarcasm, and wasn't deeply offended! You must have a much healthier sense of humor than my colleagues at work!
Cheers,

Mike

(in reply to DiGiTAL.SkReAM)
 
 
Post #: 10
 
 RE: calling subroutine within subroutine, passing paren... - 7/21/2007 9:24:00 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
Some comments:

- "pause 5" (if you mean pausing 5 seconds, it's "sleep 5000") is useless.
- Use "On error resume next" and "On error Goto 0" to toggle error mode on and off, so that you can still debug errors, if any, with the internal error debugging.
- I added code numbers refering to icons (16, 48 etc)
- Functions must finish with "End Function"

HTH


      

_____________________________

Fred

(in reply to itismike)
 
 
Post #: 11
 
 RE: calling subroutine within subroutine, passing paren... - 7/21/2007 10:49:38 AM   
  itismike

 

Posts: 42
Score: 0
Joined: 7/7/2007
Status: offline
Cool - thanks for the tips!

In full context, I think it would make more sense to you why I choose wscript.echo for the non-fatal errors and msgBox for the fatal error. I'm using a 'forceCscript' subroutine to provide the output to the user in a DOS box, so the only reason to create a msgBox is if I need to alert the user and terminate execution.

'Pause' is the name of a sub in the program. Sorry I didn't explain that:

      

(in reply to Fredledingue)
 
 
Post #: 12
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> calling subroutine within subroutine, passing parent name Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts