18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong> <strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong><br />

Function<br />

Description Declares the name, arguments, and code that <strong>for</strong>m the body of a Function procedure<br />

Usage [Public [Default] | Private] Function name [(arglist)]<br />

[statements]<br />

[name = expression]<br />

[Exit Function]<br />

[statements]<br />

[name = expression]<br />

End Function<br />

Arguments Public<br />

Indicates that the Function procedure is accessible to all other procedures in all scripts.<br />

Default<br />

Used only with the Public keyword in a Class block to indicate that the Function procedure<br />

is the default method <strong>for</strong> the class. An error occurs if more than one Default procedure is<br />

specified in a class.<br />

Private<br />

Indicates that the Function procedure is accessible only to other procedures in the script<br />

where it is declared or if the function is a member of a class, and that the Function<br />

procedure is accessible only to other procedures in that class.<br />

name<br />

Name of the Function; follows standard variable naming conventions.<br />

arglist<br />

List of variables representing arguments that are passed to the Function procedure when it<br />

is called. Commas separate multiple variables.<br />

The arglist argument has the following syntax and parts:<br />

[ByVal | ByRef] varname[( )]<br />

ByVal<br />

Indicates that the argument is passed by value.<br />

ByRef<br />

Indicates that the argument is passed by reference.<br />

varname<br />

Name of the variable representing the argument; follows standard variable<br />

naming conventions.<br />

statements<br />

Any group of statements to be executed within the body of the Function procedure.<br />

expression<br />

Return Value of the Function.<br />

Remarks If not explicitly specified using either Public or Private, Function procedures are public by<br />

default, that is, they are visible to all other procedures in your script. The value of local variables<br />

in a Function is not preserved between calls to the procedure.<br />

You cannot define a Function procedure inside any other procedure (e.g. Sub or Property Get).<br />

The Exit Function statement causes an immediate exit from a Function procedure. Program<br />

execution continues with the statement that follows the statement that called the Function<br />

procedure. Any number of Exit Function statements can appear anywhere in a Function<br />

procedure.<br />

Like a Sub procedure, a Function procedure is a separate procedure that can take arguments,<br />

per<strong>for</strong>m a series of statements, and change the values of its arguments. However, unlike a Sub<br />

procedure, you can use a Function procedure on the right side of an expression in the same way<br />

you use any intrinsic function, such as Sqr, Cos, or Chr, when you want to use the value<br />

returned by the function.<br />

You call a Function procedure using the function name, followed by the argument list in<br />

parentheses, in an expression. See the Call statement <strong>for</strong> specific in<strong>for</strong>mation on how to call<br />

Function procedures.<br />

<strong>InduSoft</strong>, Ltd. 181

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!