Information Technology Reference
In-Depth Information
Another disadvantage is that you may have a long list of fields in a record when
all you really cared about was one or two. These you could have gotten by simply
defining the fields needed and not worrying about the others. The same could apply to a
copy member that has a list of statements that are used for some group of routines, like
file access. Say the copy member contains all the code for reading, writing, deleting and
rewriting records to a file but you only need to read the records. You still would have all
the code including lines that you didn't need. This tends to make the program longer and
the more statements in a program, the more difficult is it to decipher and maintain.
As an example of a copy member that has executable statements rather than
merely the layout of a file record, consider a routine that we use repeatedly to verify that
dates are valid. We will assume that all the dates are eight characters and the date should
represent a valid date in the format yyyymmdd. We will have to verify that it is numeric.
The copy member to do this will consist of the main procedure
check-date,
along with three others. These are the statements you see below.
check-date:
if date-work >= “00000000” and <= “99991231”
if date-work not = “00000000”
perform range-check
end-if
else
date-switch = 1
end-if
range-check:
if date-yyyy > 0
if date-mm > 0 and <= 12
if date-dd > 0 and <= 31
perform validity-check
else
date-switch = 2
end-if
else
date-switch = 3
end-if
else
date-switch = 4
end-if
validity-check:
if work-dd > 28
if date-mm = 2
perform february-check
else
if work-mm = 4 or 6 or 9 or 11
if work-dd > 30
date-switch = 6
end-if
Search WWH ::




Custom Search