Syntax: function

A function is a list of codes that can be defined once and then used repeatedly. In OpusScript, it is good practice to write functions in the Script Object and refer to it from a Script Action.

A function can only be seen on the page with the script containing it. If you want it available to all pages in your publication place the script object containing it on a master page and use that master page for all relevant pages.

Syntax: To create (i.e. define) a function

function functionName( parameters )
{
 list of statements
}

Remarks:

function – is a keyword, it declares the function.

functionName – the name you will give the function.

parameters – the additional parameters you can pass the function from a calling function.

list of statements – the lines of code that will run when the function is called.

{ } – the lines of code must be surrounded by curly brackets, to indicate the start and end of the statements within the function.

 

Syntax: To call a function

functionName( parameters )

Remarks:

functionName – the name of the function.

parameters – a list of parameters, separated by commas that are passed to the function for processing.

( ) – the parameters must be surrounded by round brackets.

image\Script_Button.jpgExamples