Information Technology Reference
In-Depth Information
will clear the entire line 24. If you just wanted to clear the part of the line beginning in
column 41, you would use
screen (24,41) erase
which does that. The reason we need this line is to clear a previous error message in the
bottom line. When we print an error message, as stated earlier, we have to make sure that
we don't delete it too soon. After all, the user should have a chance to see and read it.
Otherwise, why even print it?
The way I determine when to clear an error message is to always do it after the
next input statement. Since this stops everything until something is keyed, this assures
that it will stay on the screen long enough. So what you need to do is print the error
message and have it cleared after the next input statement encountered in the flow. If you
have a statement to erase the message line right after each
input
statement, you shouldn't have any problems.
The next line
update-switch = 1
sets
update-switch
to 1, meaning that we need to eventually update the account file because a change has
been made to last name. We will also set this variable to 1 if we change balance or first
name. The next line
if index ( new-last-name , name-string ) = 1
uses the new keyword
index
which checks to see if every character found in the variable
new-last-name
can be found in the variable
name-string .
If you recall,
name-string
is nothing more than the entire possible set of values for the last name, letters of the
alphabet and certain other special characters. Note that the space is included, along with
the hyphen, the period and the single quote.
So if the characters keyed into the variable for the changed last name can be found
in this string of values, the result will be 1. If there is even one character input for the
name that is not in
name-string ,
the value of this expression will be 0. This is how we restrict entry to specific characters.
If the data entered satisfies our requirements, this means that we have valid input,
so we set the appropriate variable to 1 by the statement
valid-input = 1
and we are through with the paragraph
input-last-name .
Otherwise we give the user a message with the line
Search WWH ::




Custom Search