STATEMENT:  Function

Implemented in version 1.0
 
Function . . . End Function
 
The Function statement creates a function, assigns a name, and allows you to list the arguments (if any) which are to be passed into the function.
 
The major difference between a function and a subroutine, is that a function can return a value back to where it was called from. The returned value must be assigned to the function name (or Set if it is an object) somewhere inside the function.
 
However, you do not not have to assign or Set a return value.
 
As an option, functions can be declared Private or Public (the default). One option for leaving a Function is to use Exit statements. You can call other functions or subroutines from within a function (nesting). You must end every function with End Function or you will get an error message.
 
Code:
<%
Function aardvark
   Rem you can place all of the code you desire inside a function
End Function
%>

 
Code:
<% Private Function aardvark
   Rem you can place all of the code you desire inside a function
End Function
%>

 
You can list more than one argument in the function.
 
Code:
<%
Function aardvark(myvar1, myvar2, mynumber, myarray)
   Rem you can place all of the code you desire inside a function
End Function
%>


When you call a function that is assigned to a variable and it has one or more arguments, you must enclosed the arguments inside parentheses, otherwise you will get an error.

Code:
<%
returnval = aardvark(myvar1, myvar2, mynumber, myarray)
%>



Copyright 1999-2004 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information