Information Technology Reference
In-Depth Information
What we are doing is going through each character of the string and verifying it
against the string of acceptable characters. As soon as we find that a character is not in the
string, we can stop the search since we know that the first name keyed is invalid. This is
handled by the statement
if index ( c-element ( i-sub ), alpha-string ) = 0 ,
which will end the checking. Note that when
process-sw
is 1, the name meets the requirements but a value of 2 for the variable
process-sw
means that we have encountered a character that is not in the variable
alpha-string .
We do the checking as many as 15 times because first name can have as many as
15 characters. Note that if the name is only 6 characters, the remaining 9 will be spaces
but that is a valid character so the test will be satisfied. This procedure is a bit more work
that using the keyword
index
as we originally described but it will get us the result that we desire. The statement
perform check-string until process-sw > 0
keeps doing the procedure
check-string
until
process-sw
is no longer 0. This is achieved in one of two ways as we discussed previously. Note that
i-sub
starts out as 0 but will be 1 next and then could eventually be 15, but not any more than
that.
Now suppose that we didn't have the keyword
index
at all, but still needed to do character validity checking. It could be done by using the
the
perform
statement. The statements to do this are
define work-array character (15) element c-element character
occurs 15 times
define c-string character (56) element t-char character value
“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .-‟”
define i-sub integer( 2)
define t-sub integer( 2)
define process-sw integer
define first-name character (15)
i-sub = 0
process-sw = 0
work-array = first-name
Search WWH ::




Custom Search