Main program, User-defined procedures – Ocean Optics Jaz Scripting Language and Scripting Engine User Manual

Page 14

Advertising
background image

2: Jaz Scripting Engine Architecture

6

013-RD000-000-12- 201010

Symbol

Name

Type

>

Greater than

Boolean

<

Less than

Boolean

:=

Assignment

Arithmetic

Main Program

The Main Program section typically defines the main logic flow of the script. The Main Program begins
with the keyword START and is terminated with the keyword END. The keyword STOP marks the end of

the script and is logically paired with the keyword SCRIPT. Labels can be placed before a statement to
make that statement a destination for a GoTo statement.

User-defined Procedures

You can define routines to carry out repetitive tasks or other repeatedly used tasks. User-defined
procedures are declared after the body of the main program (i.e., after the END of the Main Program
section). The syntax is:

[Process ProcessName]

and is terminated with the keyword END.

To invoke a user-defined procedure, use the following:

CALL ProcessName

A procedure shares the same variables as the main section but it may have its own labels to avoid
confusion. A procedure may not execute a GoTo to a label outside itself. For example, if the Main
Program section has a label ‘A’ and the procedure has a GoTo A then the procedure must also have a
label ‘A’, or it is an error.

Flow Control

Control flow is achieved with GOTO and CALL statements. All loop iteration structures may be realized
with judicious use of labels and GOTO statements. For example a FOR loop might be coded in the
following way:

I := 0

Label FORLOOP

if(I >= N) GOTO ENDFOR

(your calculations here)

I := I + 1

GOTO FORLOOP

Label ENDFOR

(rest of program)

Advertising