FUNCTION        Begin a function declaration

Top  Previous  Next

Syntax:

FUNCTION

[ func name ] [ arg1 … arg9 ]

Arguments:

[ func name ]

Variable or string specifying a previously declared function name.

 

[ arg1 … arg9 ]

Up to nine variables that are assigned when the function is called.

Options:

None

 

 

 

This script directive is used within the function declaration section of a script file to define a function named [ func name ] and enable it to be called during execution of the script file. You may define multiple functions in the function declaration section (between the BEGINFUNCTIONS and ENDFUNCTIONS commands) but the individual function declarations must not be nested.

 

Function names may be whatever the script developer chooses as long as the names do not conflict with script command identifiers.

 

Up to 32 input arguments may be passed to a function. Argument names may be whatever the script developer chooses as long as the names do not conflict with script command identifiers.

 

Function input arguments go out of scope (become undefined) when the function returns. The only exception to this behavior is when a function input argument has the exact same name as an existing variable.  In this case, the argument will continue to behave as a global variable and if its value is changed inside the function that change will persist after the function returns.

 

It is possible for a script to contain multiple function declaration sections but if an existing function is subsequently redefined, then the new definition replaces the original function definition. In other words, Robo-FTP does not support function overloading.

 

Consider the following example of a function declaration section containing a single function. The example also contains a line after the function declaration section that calls the function.

 

;; declaration for the function named "MyFunction"

BEGINFUNCTIONS

;; an example function

FUNCTION MyFunction

 ;; function body is here

 DISPLAY %date

ENDFUNCTION

ENDFUNCTIONS

 

MyFunction ;; call function here

 

 

Please see the Using Functions topic under the Script Programming section for manual for additional examples and discussion of functions.

 

 

Related command(s): BEGINFUNCTIONS, ENDFUNCTION, ENDFUNCTIONS, RETURN

See also: Using Functions