Hey all,
Well, all is going well with the customer add\update\delete program...thanks for the help. I have a question about error checking.
My 800-Validate-Fields-rtn checks for many things like no leading spaces, numeric phone and zip code and no special charcters. This is all entered interactively by a user. It doesn't copy and past too well - sorry.
What I was wondering - is there a better way to check for special characters? I tryed defining it in the working storage
01 ws-spec-char pic x value '$#^...etc'.
and checking for all ws-spec-char but it was looking for the whole literal '&*^()...etc'
Also, I'd like to make sure that the first letter of the first name, last name, city, address and if possible the first characters of an address and city with more than one word to it. It seems almost not worth it to go to all of that trouble, but there must be a somewhat easy way. Or do all customer records look like...
joHnSmitH 1888 STREET NAME city IL 60551
Thanks for the help.
-Tyler
800-VALIDATE-FIELDS-RTN.
INITIALIZE OPTION-SWITCHES
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-F-NAME TALLYING SPACES-CT FOR LEADADING SPACES
INSPECT N-CUST-F-NAME TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN FIRST NAME' TO
ERROR-FNAME
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO ERROR-FNAME
ELSE
MOVE '-OK' TO ERROR-FNAME
END-IF
END-IF
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-L-NAME TALLYING SPACES-CT FOR LEADING SPACES
INSPECT N-CUST-L-NAME TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN LAST NAME' TO
ERROR-LNAME
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO ERROR-LNAME
ELSE
MOVE '-OK' TO ERROR-LNAME
END-IF
END-IF
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-ADDRESS TALLYING SPACES-CT FOR LEADING SPACES
INSPECT N-CUST-ADDRESS TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN ADDRESS' TO
ERROR-ADDRESS
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO
ERROR-ADDRESS
ELSE
MOVE '-OK' TO ERROR-ADDRESS
END-IF
END-IF
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-CITY TALLYING SPACES-CT FOR LEADING SPACES
INSPECT N-CUST-CITY TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN CITY' TO ERROR-CITY
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO ERROR-CITY
ELSE
MOVE '-OK' TO ERROR-CITY
END-IF
END-IF
MOVE FUNCTION UPPER-CASE (N-CUST-STATE) TO N-CUST-STATE
SET STATE-SUB TO 1
SEARCH STATES-ALL
AT END
MOVE 'Y' TO ANY-ERRORS
MOVE '*STATE ENTERED DOES NOT EXIST' TO ERROR-STATE
WHEN N-CUST-STATE = STATES-ALL (STATE-SUB)
MOVE '-OK' TO ERROR-STATE
END-SEARCH
IF N-CUST-ZIP IS NOT NUMERIC
MOVE '*ZIP CODE MAY ONLY BE NUMBERS' TO ERROR-ZIP
ELSE
MOVE '-OK' TO ERROR-ZIP
END-IF
IF WS-NEW-PHONE IS NOT NUMERIC
MOVE 'Y' TO ANY-ERRORS
MOVE '*PHONE NUMBER MAY ONLY BE NUMBERS' TO ERROR-PHONE
ELSE
MOVE '-OK' TO ERROR-PHONE
END-IF
IF ERRORS
DISPLAY ERROR-SCREEN
ACCEPT GO-ON AT LINE 1 COL 1 WITH SECURE AUTO
ELSE
MOVE 'N' TO ANY-ERRORS
END-IF.
Well, all is going well with the customer add\update\delete program...thanks for the help. I have a question about error checking.
My 800-Validate-Fields-rtn checks for many things like no leading spaces, numeric phone and zip code and no special charcters. This is all entered interactively by a user. It doesn't copy and past too well - sorry.
What I was wondering - is there a better way to check for special characters? I tryed defining it in the working storage
01 ws-spec-char pic x value '$#^...etc'.
and checking for all ws-spec-char but it was looking for the whole literal '&*^()...etc'
Also, I'd like to make sure that the first letter of the first name, last name, city, address and if possible the first characters of an address and city with more than one word to it. It seems almost not worth it to go to all of that trouble, but there must be a somewhat easy way. Or do all customer records look like...
joHnSmitH 1888 STREET NAME city IL 60551
Thanks for the help.
-Tyler
800-VALIDATE-FIELDS-RTN.
INITIALIZE OPTION-SWITCHES
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-F-NAME TALLYING SPACES-CT FOR LEADADING SPACES
INSPECT N-CUST-F-NAME TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN FIRST NAME' TO
ERROR-FNAME
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO ERROR-FNAME
ELSE
MOVE '-OK' TO ERROR-FNAME
END-IF
END-IF
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-L-NAME TALLYING SPACES-CT FOR LEADING SPACES
INSPECT N-CUST-L-NAME TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN LAST NAME' TO
ERROR-LNAME
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO ERROR-LNAME
ELSE
MOVE '-OK' TO ERROR-LNAME
END-IF
END-IF
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-ADDRESS TALLYING SPACES-CT FOR LEADING SPACES
INSPECT N-CUST-ADDRESS TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN ADDRESS' TO
ERROR-ADDRESS
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO
ERROR-ADDRESS
ELSE
MOVE '-OK' TO ERROR-ADDRESS
END-IF
END-IF
INITIALIZE ERROR-COUNTERS
INSPECT N-CUST-CITY TALLYING SPACES-CT FOR LEADING SPACES
INSPECT N-CUST-CITY TALLYING SPECIAL-CT FOR ALL '*' '(' ')'
'!' '@' '^' '$' '#' '&' '+' '=' '{' '}' '[' ']' ':' ';' '/' '\'
'?' '>' '<' '%' '`' '_' '|'
IF SPACES-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*LEADING SPACES NOT ALLOWED IN CITY' TO ERROR-CITY
ELSE
IF SPECIAL-CT > 0
MOVE 'Y' TO ANY-ERRORS
MOVE '*NO SPECIAL CHARACTERS ALLOWED' TO ERROR-CITY
ELSE
MOVE '-OK' TO ERROR-CITY
END-IF
END-IF
MOVE FUNCTION UPPER-CASE (N-CUST-STATE) TO N-CUST-STATE
SET STATE-SUB TO 1
SEARCH STATES-ALL
AT END
MOVE 'Y' TO ANY-ERRORS
MOVE '*STATE ENTERED DOES NOT EXIST' TO ERROR-STATE
WHEN N-CUST-STATE = STATES-ALL (STATE-SUB)
MOVE '-OK' TO ERROR-STATE
END-SEARCH
IF N-CUST-ZIP IS NOT NUMERIC
MOVE '*ZIP CODE MAY ONLY BE NUMBERS' TO ERROR-ZIP
ELSE
MOVE '-OK' TO ERROR-ZIP
END-IF
IF WS-NEW-PHONE IS NOT NUMERIC
MOVE 'Y' TO ANY-ERRORS
MOVE '*PHONE NUMBER MAY ONLY BE NUMBERS' TO ERROR-PHONE
ELSE
MOVE '-OK' TO ERROR-PHONE
END-IF
IF ERRORS
DISPLAY ERROR-SCREEN
ACCEPT GO-ON AT LINE 1 COL 1 WITH SECURE AUTO
ELSE
MOVE 'N' TO ANY-ERRORS
END-IF.