NET/MASTER Network Control Language (NCL) Programmer's Guide
Declaring Procedures and User-Written Functions
Procedures and Functions
6–10 106160 Tandem Computers Incorporated
The following screen shows the results of executing the procedure:
(13:54) --------------------- OPERATOR CONTROL SERVICES ----------------------
START ZEX0604N
PROFILE MONMSG=NO
PROFILE UNSOL=NO
PROFILE EMS=NO
PROFILE CMDKEEP=NO
PROFILE TRUNC=NO
NNM0357 PROFILE HAS CHANGED
NNM0357 PROFILE HAS CHANGED
NNM0357 PROFILE HAS CHANGED
NNM0357 PROFILE HAS CHANGED
NNM0357 PROFILE HAS CHANGED
NNM1005 START ZEX0604N PROCESSING COMPLETE. NCLID 002038
_____________________________________________________________________________
---------- ------------------ NonStop NET/MASTER D30 ---------------- --------
=>
The following example shows an explicitly declared user-written function within an
explicitly declared internal procedure:
zex0605n: PROCEDURE
/* Explicitly declared user-written function */
SAY "The square root of "&1" is "sqroot(&1)
sqroot: FUNCTION
/* Check validity of arguments */
IF TYPECHK(NUM,&1) \= NUM THEN
RETURN("using invalid arguments")
ELSE
RETURN(&1**0.5)
END sqroot
END zex0605n
This NCL procedure assumes that you enter a single parameter when you execute it.
The parameter is placed in the variable &1 and is passed to the SQROOT function
when the function is called. The SQROOT function uses the built-in function,
TYPECHK, to determine whether the parameter is a number. If the parameter is a
number, it calculates its square root and returns the result using a RETURN statement;
if not, it returns an error message using a RETURN statement. The SAY statement
displays the result of the SQROOT function in the OCS message display area.