NET/MASTER Network Control Language (NCL) Programmer's Guide

Calling Procedures and Functions
Procedures and Functions
6–48 106160 Tandem Computers Incorporated
Searching for Procedure
and Function Labels
Searching for and finding the label of an internal procedure or function is governed by
rules that define search order and the labels that NCL can see from any point.
From any point within a procedure or function, that procedure or function sees labels
in the following order:
1. The label(s) of all direct children.
2. Its own label(s) and the labels of its peers.
3. The label(s) of its parent and the labels of its parent’s peers.
4. The label(s) of its grandparent and the labels of its grandparent’s peers, and so on.
A procedure or function cannot see the label(s) of its grandchildren, or the label(s) of
its grandchildren's peers, or the label(s) of its great-grandchildren's peers, and so on.
NCL searches for the label of a procedure or function in the following order:
1. It searches the labels of all procedures or functions that are the direct children of
the current procedure or function.
a. If it finds a matching label, the search has been successful and stops.
b. If it does not find a matching label, it continues to search according to the next
step.
2. If there is an immediate parent of the current procedure or function, it becomes the
current procedure or function, and NCL continues to search according to the
previous step.
3. If there is no immediate parent of the current procedure or function, NCL is at the
top-level procedure or function and looks at all labels at the top level.
a. If NCL finds a matching label, the search has been successful and stops. This
means that NCL executes the procedure or function again.
b. If it does not find a matching label, then the label does not exist within the
scope of the procedure or function that issued the call; the search has been
unsuccessful and stops.
The rules imply that you can call a procedure or function recursively.
Labels of the PROCEDURE statement and the FUNCTION statement must be unique
at the same nesting level; that is, all labels must be peers under a given parent. If NCL
finds a matching label, it is illegal to branch there:
If NCL was looking for a procedure label and it found the label on a function.
If NCL was looking for a function label and it found the label on a procedure.