Function and Sub Procedures: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
Procedures are blocks of program statements that can be conditionally and repeatedly executed ("called") from other statements in a program, with optional values (arguments) passed in. When a procedure is called, it behaves like the Functions and Statements that make up the NSB/App Studio language. FUNCTION procedures return a value, which can be stored in a variable or used in another expression. SUB procedures execute without returning a value. If a FUNCTION procedure is called and the return value is not used, NSB/App Studio executes it as a SUB procedure.
Procedures are blocks of program statements that can be conditionally and repeatedly executed ("called") from other statements in a program, with optional values (arguments) passed in. When a procedure is called, it behaves like the Functions and Statements that make up the NSB/App Studio language. FUNCTION procedures return a value, which can be stored in a variable or used in another expression. SUB procedures execute without returning a value. If a FUNCTION procedure is called and the return value is not used, NSB/App Studio executes it as a SUB procedure.


To pass in multiple arguments to a FUNCTION procedure, use a comma-separated list, enclosed in parenthesis. To pass in multiple arguments to a SUB procedure, use a comma-separated list with no parenthesis. When a single argument is passed in to either a FUNCTION or a SUB procedure, parenthesis may be used; NS Basic/App Studio uses parenthesis around a single argument to evaluate an expression, not to denote an argument list.
To pass in multiple arguments to a FUNCTION procedure, use a comma-separated list, enclosed in parenthesis. To pass in multiple arguments to a SUB procedure, use a comma-separated list with no parenthesis. When a single argument is passed in to either a FUNCTION or a SUB procedure, parenthesis may be used; NSB/App Studio uses parenthesis around a single argument to evaluate an expression, not to denote an argument list.


Arguments are passed by value for numbers, strings and arrays. Objects are passed by reference.
Arguments are passed by value for numbers, strings and arrays. Objects are passed by reference.

Revision as of 13:15, 2 September 2012

Procedures are blocks of program statements that can be conditionally and repeatedly executed ("called") from other statements in a program, with optional values (arguments) passed in. When a procedure is called, it behaves like the Functions and Statements that make up the NSB/App Studio language. FUNCTION procedures return a value, which can be stored in a variable or used in another expression. SUB procedures execute without returning a value. If a FUNCTION procedure is called and the return value is not used, NSB/App Studio executes it as a SUB procedure.

To pass in multiple arguments to a FUNCTION procedure, use a comma-separated list, enclosed in parenthesis. To pass in multiple arguments to a SUB procedure, use a comma-separated list with no parenthesis. When a single argument is passed in to either a FUNCTION or a SUB procedure, parenthesis may be used; NSB/App Studio uses parenthesis around a single argument to evaluate an expression, not to denote an argument list.

Arguments are passed by value for numbers, strings and arrays. Objects are passed by reference.