Information Technology Reference
In-Depth Information
field character (30) value “day out of range”
field character (30) value “month out of range”
field character (30) value “zero is invalid for the year”
field character (30) value “invalid day for February”
field character (30) value “that month has only 30 days”
We now can replace all our
if
statements related to these errors by the three statements
if date-switch > 0
screen (24,20) t-element ( date-switch )
end-if
with
t-element ( date-switch )
producing one of six message based on the variable in parentheses.
date-switch
will be between 1 and 6, inclusive, since there are only that many error possibilities. We
could even add other messages to the array not related to date checking. If we did, we
would have to adjust the size of the array, in this case 180. In addition, the count spelled
out by the keyword
occurs
would have to be larger. Then we can add error messages as we need them with only a
few modifications.
In summary, the statements,
define message-array character (180) element t-element character (30)
occurs 6 times structure
field character (30) value “date not numeric”
field character (30) value “day out of range”
field character (30) value “month out of range”
field character (30) value “zero is invalid for the year”
field character (30) value “invalid day for February”
field character (30) value “that month has only 30 days”
simply define an area of 180 characters for our array, broken down into 6 pieces or
messages, each one being referred to as the variable,
t-element,
which consists of 30 characters each and we shall refer to these messages by subscripting.
The new keywords are
element ,
occurs
and
Search WWH ::




Custom Search