Information Technology Reference
In-Depth Information
perform
check-string
until
process-sw
> 0
check-string:
i-sub
=
i-sub
+ 1
perform
check-character
varying
t-sub
from
1
by
1
until
t-sub
> 56
if
i-sub
= 15 and
process-sw
= 0
process-sw
= 1
end-if
check-character:
if
c-element
(
i-sub
) =
t-char
(
t-sub
)
t-sub
= 57
else
if
t-sub
= 56
process-sw
= 2
end-if
end-if
Before looking at the statements, consider what we have to do to validate the
characters of the name. We must take one letter at a time starting with the leftmost
position and check it against the string of valid symbols. That string is
c-string
and if the character is in the string, we then take the next character and proceed in a
similar manner. If we find that each character is in
c-string
,
the name passes the validity check. However, if we find any character that is not in
c-string
,
we can stop the checking and need go no further since all other parts of the name don't
have to be verified. Once again the space is a valid character so it will not result in an
invalid name.
With that in mind, the statement
perform
check-string
until
process-sw
> 0
will result in either a value of 1, which means the name is valid or 2 which indicates that
it is not since at least one character is unacceptable. Note that as soon as we get through
any character whether it is the first one, the last one or any other and it is not valid, the
process will stop. The statements,
if
t-sub
= 56
process-sw
= 2
end-if
enable that to happen since this indicates that we are at the very last position in
c-string
and we have yet to get a match.
In the
check-character
paragraph note that