Rockwell Automation 2708-NAG Application Generation Software User Manual

Page 27

Advertising
background image

Chapter 3
Using Application Generator

3 – 17

F6 – GoSub (Call Subroutine)

: A GOSUB is a way of calling a

subroutine. The subroutine can do its job and then return to the line
immediately after the GOSUB statement. This makes it easier to write
programs that have the kind of structure found in high level languages such
as A-B VBASIC.

F7 – Return (From Subroutine)

: When you write the subroutine that is

called by the GOSUB statement, you must be sure to put a RETURN
operation at the last line of the GOSUB. If you execute too many GOSUBs
without returning you will get a stack overflow error.

F8 – Label

: Line numbers work well for writing simple programs that you

will not have to change often. For better structured programs you should use
labels. A label is a name for a line in your program. The advantage is that the
GOTO or GOSUB will have a name that makes sense instead of a
meaningless line number.

You can place a label anywhere in your program using the LABEL option in
the OTHER OPERATIONS menu. When you key in a GOTO, you can use
the label name instead of a line number.

When you are prompted for the line/label name, if you key in a label name
that does not currently exist, you will be asked if you would like to put the
label somewhere in your program. This is a nice shortcut for entering the
labels.

F9 – ON Event GoTo Line/Label

Operations: The ON event operation is

a way of branching to more than one place depending on the condition of a
previous operation. If the condition is met then the program will branch to
the line number or label you define. The previous operation is defined from
the following menu selections:

Figure 3.18
AG On Condition Menu

Advertising