Article
· Jul 7, 2016 2m read

NewBie's Corner Session 11 Routine Line Types and Gotos

NewBie's Corner Session 11 Routine Line Types and Gotos

Welcome to NewBie's Corner, a weekly or biweekly post covering basic Caché Material.

InterSystems Caché provides a GUI (Graphical User Interface) based Integrated Development Environment (IDE) called Caché Studio. Developers can use Studio to create and maintain applications.

In this session we will cover Routine Line types; which are Label lines, Executable code lines and the Routine Header line as well as Gotos.


Routine Line types
Labels and Executable Code lines

Executable Code lines starts in column two, or many developers just hit the tab.
Label lines start in column one. Labels are the targets of the Do and Goto commands.


For Example:


START            ; Label
    Set X=5        ; Executable Code line


The first line containing the word START is an example of a Label line. The line containing the string "Set X=5" is an example of an Executable code line. It is possible to have a Label and Executable code on the same line.


For Example:


START    Set X=5

 

Here we have both a Label and Executable code on the same line. At least one space or tab separates the Label from the Executable code.


Routine Header line
All routines should start with the routine name on the first line in the first column.


For Example:


ROUTINEA            ; name of the routine on the first line
Start                        ; Label line
    Set X=1             ; Executable Code line
    ; more code
    Quit


The above example shows the Routine Header line, the first line of a routine, as well as a Label line and Executable Code line.


As stated above, Labels are the targets of the Do and Goto commands.
Here is a simple loop you can code and run.


ROUTINELOOP
    Set X=1
LoopLabel
    Set X=X+1
    Write !,"X: ",X
    If X < 5 Goto LoopLabel
    Write !,"End of Routine."
    Quit

 

--Mike Kadow
PaulMikeKadow@gmail.com
If you have a comment, please respond through the InterSystems Developer Community, don't send me private email, unless of course you wish to address me only.

See NewBie Index for an index of all NewBie Corner posts.

Discussion (0)0
Log in or sign up to continue