home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
d_b_a
/
87_01
/
validate.prg
< prev
Wrap
Text File
|
1986-12-05
|
7KB
|
200 lines
* VALIDATE.PRG 08/26/86
*
* this program is a set of GETFILE validation procedures
*
PROCEDURE STATEVAL.PRG
* STATEVAL.PRG
*
* written by: Bob Green date : 04/26/86
* modified: 08/24/86
*
* this is a GETFILE program to validate that the entry of a
* field contains a valid U.S.P.S. two-letter state abbreviation.
* the calling program must use a statement as follows:
*
* @ xx,yy SAY "desired input text" GET variable PICTURE "!!" ;
* GETFILE stateval.prg
*
* this routine works with dBMAN V2.0 or later
* set up a getfile-routine field containing the name of
* the field `get' field that was `read' by the calling program
STORE GETNAME() TO y.getfld
* set up a variable that contains the valid state abbrev's
STORE "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|"+;
"KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NY|"+;
"NC|ND|OH|OK|OR|PA|PR|RI|SC|SD|TN|TX|UT|VT|VA|WA|"+;
"WV|WI|WY" TO y.valid_st
* use a macro substitution for the field name when determining
* if the field READ was valid
IF INSET("|",&y.getfld,y.valid_st) = 0
* the field entered is not valid, write an error message on the
* screen, and perform your standard validation error routine
STORE "'"+&y.getfld+"' IS NOT A VALID STATE" TO m_errmsg
DO errmsg.prg
* force the same field to be READ again
ASSIGN USERSTAT(0)
ENDIF
RETURN
PROCEDURE STRNGVAL.PRG
* STRNGVAL.PRG
*
* written by: Bob Green date: 08/14/86
* modified:
*
* this getfile program validates the entered string is among the
* valid strings for this variable. The calling program must have
* the following two statements:
* 1) y.YYYYYYYYYX = "valid |strings |separated|by bars "
*
* where - `YYYYYYYYY' is up to the first 9 characters of the
* GET variables name. An `X' is appended to the GET
* variable name to make it unique.
* - the valid strings must be the same length as the GET
* variable and separated by bars (`|')
.
*
* 2) @ xx,yy SAY "desired input text" GET variable PICTURE "!!" ;
* GETFILE strngval.prg
*
* this routine works with dBMAN V2.0 or later
* set up a getfile-routine field containing the name of
* the field `get' field that was `read' by the calling program
STORE GETNAME() TO y.getfld
* set up a variable containing the string validation variable name
STORE SUBSTR(TRIM(y.getfld),1,9)+"X" TO y.valid_str
* use a macro substitution for the field name when determining
* if the field READ was valid
IF INSET("|",&y.getfld,&y.valid_str) = 0
* the field entered is not valid, write an error message on the
* screen, and perform your standard validation error routine
STORE "`"+&y.getfld+"' IS NOT A VALID RESPONSE" TO m_errmsg
DO errmsg.prg
* force the same field to be READ again
ASSIGN USERSTAT(0)
ENDIF
RETURN
PROCEDURE FILEVAL.PRG
* FILEVAL.PRG
*
* written by: Bob Green date: 08/14/86
* modified:
*
* this getfile program validates the variable entered is a key on
* the master index of a file. Since dBMAN does not require a file
* be SELECTed to be used, the file validation can be on any open
* file. The calling program must have the following two statements:
*
* 1) y.zzzzzzzzzX = "Fi"
*
* where - `zzzzzzzzz' is up to the first 9 characters of the
* GET variables name. An `X' is appended to these
* characters to make a new, unique variable.
* - `Fi' is the file id of file to validate against. The
* file id must be for a valid, open file (`FJ' - `FS')
*
* 2) @ xx,yy SAY "desired input text" GET variable PICTURE <fmt> ;
* GETFILE fileval.prg
*
* this routine works with dBMAN V2.0 or later
* set up a getfile-routine field containing the name of
* the `get' field that was `read' by the calling program
STORE GETNAME() TO y.getfld
* set up a variable that contains the file id to validate against
STORE SUBSTR(TRIM(y.getfld),1,9)+"X" TO y.valid_file
* use a macro substitution for the field name and the file id to
* determine if the field READ was valid
STORE "FIND "+&y.valid_file+" '"+ ;
&y.getfld+"'" TO y.cmd
&y.cmd
STORE "IF EOF("+&y.valid_file+")" to y.cmd
&y.cmd
* the field entered is not valid, write an error message on the
* screen, and perform your standard validation error routine
STORE "`"+&y.getfld+"' IS NOT ON FILE" TO m_errmsg
DO errmsg.prg
* force the same field to be READ again
ASSIGN USERSTAT(0)
ENDIF
RETURN
PROCEDURE RANGE.PRG
* RANGE.PRG
*
* written by: Bob Green date: 08/14/86
* modified:
*
* this getfile program validates the entered number is within the
* valid range for this variable. The calling program must have
* the following two statements:
* 1) y.YYYYYYYYYX = "LLLL.L|HHHH.HHH"
*
* where - `YYYYYYYYY' is up to the first 9 characters of the
* GET variables name. An `X' is appended to the GET
* variable name to make it unique.
* - LLLL is the lower limit allowed for the variable
* HHHH is the upper limit allowed for the variable
*
* 2) @ xx,yy SAY "desired input text" GET variable PICTURE "99" ;
* GETFILE range.prg
*
* this routine works with dBMAN V2.0 or later
* set up a getfile-routine field containing the name of
* the field `get' field that was `read' by the calling program
STORE GETNAME() TO y.getfld
* set up a variable containing the string validation variable name
STORE SUBSTR(TRIM(y.getfld),1,9)+"X" TO y.valid_str
* use a macro substitution for the field name when determining
* lower and upper limits for the variable entered
STORE VAL($(&y.valid_str,1,AT("|",&y.valid_str)-1)) TO y.low
STORE VAL($(&y.valid_str,AT("|",&y.valid_str)+1)) TO y.high
* if the field READ was valid
IF &y.getfld < y.low OR &y.getfld > y.high
* the field entered is not valid, write an error message on the
* screen, and perform your standard validation error routine
STORE "ENTRY MUST BE BETWEEN " + ;
$(&y.valid_str,1,AT("|",&y.valid_str)-1) + " AND " + ;
$(&y.valid_str,AT("|",&y.valid_str)+1) TO m_errmsg
DO errmsg.prg
* force the same field to be READ again
ASSIGN USERSTAT(0)
ENDIF
RETURN
PROCEDURE ERRMSG.PRG
* ERRMSG.PRG 11/23/84 BOB GREEN
@ 23,INT((64-LEN(m_errmsg))/2) SAY "*** ERROR - "+m_errmsg+" ***"
@ 24,27 SAY "PRESS ANY KEY TO CONTINUE"
BEEP
SET CONSOLE OFF
WAIT
SET CONSOLE ON
@ 23,0
@ 24,0
RETURN