Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


PS Subroutines

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> Windows PowerShell >> PS Subroutines
  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 >>
 PS Subroutines - 11/22/2006 8:06:04 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
I read in the vbscript_to_powershell.doc from Microsoft site that PS does not support subroutines only functions.  What is used in place of subs then?
 
 
Post #: 1
 
 RE: PS Subroutines - 11/22/2006 6:48:45 PM   
  ginolard


Posts: 1021
Score: 21
Joined: 8/10/2005
Status: offline
Nothing.  There's really no overriding reason to use a Sub instead of a Function

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to esnmb)
 
 
Post #: 2
 
 RE: PS Subroutines - 11/24/2006 12:51:28 AM   
  SAPIENScripter


Posts: 271
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
VBScript is apparently one of the few scripting languages that really differentiates between a sub and a function. In PowerShell, all code blocks that "do something" or return a value are considered functions.  The other big difference is that in a .ps1 script, your functions have to come at the beginning of the script. In VBScript, they could be anywhere. But PowerShell processes the script file sequentially like a batch file and the function has to "exist" before it can be called.

_____________________________

Jeffery Hicks
Windows PowerShell MVP
SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com

Follow Me: http://www.twitter.com/JeffHicks

(in reply to ginolard)
 
 
Post #: 3
 
 RE: PS Subroutines - 11/24/2006 1:05:52 AM   
  esnmb

 

Posts: 441
Score: 0
Joined: 1/11/2005
From: USA
Status: offline
Interesting.  Thanks for the info.

(in reply to SAPIENScripter)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Windows PowerShell >> PS Subroutines 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