Information Technology Reference
In-Depth Information
times .
This is how we configure the array and note that the above statement not only defines but
also give our array values. The subscript turns out to be the variable
date-switch
and it must be a numeric field. In this case it is between 1 and 6 inclusive since we have
only 7 possible values for this field, 0, 1, 2, 3, 4, 5 or 6 and
if date-switch > 0
screen (24,20) message-array(date-switch)
end-if
guarantees that our subscript does fall within this range of 6 positive numbers. A value of
0 indicates no error at all.
Let us return to the index keyword we used earlier. This was needed to verify that
the letters in the name fell within a certain range of letters and symbols. It worked rather
well but suppose it didn't work as we described and it could only look at one character at
a time to see if it was found in a different string. If the variable
alpha-string
represents the set of valid characters for first name mentioned earlier, namely the letters
of the alphabet, both lower case and capital letters, as well as certain special symbols,
then
index (“A”, alpha-string )
would result in the value 1 since A is certainly in the string but
index (“3”, alpha-string)
would give a value of 0 since the number 3 is not in the string. With that in mind, we
could still do character validity checking using these statements:
define i-sub integer( 2)
define work-array character (15) element c-element character
occurs 15 times
define process-sw integer
i-sub = 0
process-sw = 0
work-array = first-name
perform check-string until process-sw > 0
check-string: i-sub = i-sub + 1
if index ( c-element ( i-sub ), alpha-string ) = 0
process-sw = 2
end-if
if i-sub = 15 and process-sw = 0
process-sw = 1
end-if
Search WWH ::




Custom Search