|
EndPsub | ||
Psub <.PsubName.>[(ParamList)] ... [Return] ... EndPsub | ||
Parameters: NONE | ||
Returns: NONE | ||
Psubs (protected sub-routines) can be called from different locations in a program. A Psub is a routine that returns a value after it executes. For example: I = MyPsub() calls MyFunction and assigns the result to I. Psub calls cannot appear on the left side of an assignment statement. Psubs that don't return a value can be used as complete statements. For example, calls the MyPsub routine. Psubs can call themselves recursively. A Psub is declared with the Psub keyword, followed by the psub name and a list of optional parameters (seperated my commas). The Psub ends with the EndPsub statement that can be followed by a value or expression that will be returned. You can exit a Psub from anywhere in the code with Return, but you cannot return a value or expression this way. FACTS: * Protected Subroutine declaration keywords (Psub & EndPsub) can not be indented. * You can return multiple values from a Psub. To do so, list the variables or arrays after the EndPsub statement. * All local variables declared within Protected Subroutines are STATIC, so they retain their value between calls. * See the Functions&PSub tutorial for more details about Functions and Psubs. Mini Tutorial: This example demonstrates calling PSUB's.
This example would output.
|
Related Info: | EndFunction | Function | Functions&Psub | Gosub | Psub | Return : |
|
|||||||||||||||||||||||||||||||||||||||
(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com |