NET/MASTER Network Control Language (NCL) Programmer's Guide
Debugging an NCL Process From Start to Finish
Debugging an NCL Process
9–60 106160 Tandem Computers Incorporated
Debugging an NCL
Process From Start to
Finish
This subsection shows how to debug an NCL process from start to finish. To do so, it
uses the ZEX0904N NCL procedure, shown later. The ZEX0904N NCL procedure has
a single bug that you are going to locate.
Purpose of the NCL
Procedure
The purpose of the ZEX0904N NCL procedure is to display the (Gregorian) calendar of
a specified month in a specified year. When executed, the ZEX0904N NCL procedure
accepts two parameters—a month (01 through 12) and a year (1583 through 2999). It
then displays a calendar for that month and year in the OCS message display area. For
example, the following command displays a calendar for February 2020 (a leap year,
that is, a year containing 366, rather than 365, days):
START ZEX0904N 02 2020
The symptom of the bug is incorrect output: the bug causes the calendar to be
displayed incorrectly on an OCS window.
Source Code of the NCL
Procedure
The source code of the ZEX0904N NCL procedure is shown next. Before reading the
rest of this subsection, you should examine this source code carefully, especially the
comments. It is helpful to think of this source code in four sections:
The first section checks the parameters you enter are correct.
The second section is an array that initializes variables with the correct number of
days in each month.
The third section is a table that obtains the numeric value of the first day of a
month.
The fourth section draws the calendar.
zex0904n: PROCEDURE
/************************************************/
/* Calendar display for a month in a given year */
/* &1 = month (01-12) */
/* &2 = year (1583-2999) (Gregorian calendar) */
/* Example: START ZEX0904N 02 2020 */
/************************************************/
&month = &1
&year = &2
/* Check the parameters are correct */
IF &month = "" OR &year = "" OR,
&month < 1 OR &year < 1583 OR,
&month > 12 OR &year > 2999 OR,
LENGTH( &month ) \= 2 OR,
LENGTH( &year ) \= 4 THEN DO
SAY "Reenter number(s): month 01-12; year 1583-2999"
FLUSH
END /*do*/
/* Array to set days in each month */
&days.01 = 31; &days.02 = 28; &days.03 = 31
&days.04 = 30; &days.05 = 31; &days.06 = 30
&days.07 = 31; &days.08 = 31; &days.09 = 30
&days.10 = 31; &days.11 = 30; &days.12 = 31
/* February has 29 days in a leap year */