home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
pcmagazi
/
1990
/
18
/
prevent.prg
< prev
Wrap
Text File
|
1990-09-24
|
3KB
|
79 lines
PROCEDURE Addempl
*
* Demonstrate general logic for checking for duplicate
* keys. Abbreviated version, for illustration
* only, dBASE III Plus tested.
*
adrecno = RECNO() && Save current recno
DO WHILE .T.
STORE SPACE(11) TO M_ssn && Create blank memvars
STORE SPACE(25) TO M_name
STORE SPACE(40) TO M_address
STORE SPACE(20) TO M_city
STORE SPACE(2) TO M_state
STORE SPACE(10) TO M_zip
READ && Display entry screen
IF READKEY() = 12 && ESC means cancel
EXIT
ENDIF
SEEK m_ssn && Check for ssn duplicate
IF FOUND()
@ 8,0 SAY ' Record with that key already exists. Try again.'
@ 9,0 SAY ' Press any key to continue. '
WAIT ""
GOTO adrecno
LOOP
ELSE
APPEND BLANK && No dups, ok to add
REPLACE SSN WITH M_SSN && Replace fields with memvars
REPLACE NAME WITH M_NAME
REPLACE ADDRESS WITH M_ADDRESS
REPLACE CITY WITH M_CITY
REPLACE STATE WITH M_STATE
REPLACE ZIP WITH M_ZIP
adrecno = RECNO() && New record number
EXIT
ENDIF
ENDDO
GOTO adrecno
RETURN
PROCEDURE editempl
*
* Demonstrate general logic for checking for duplicate
* keys. Abbreviated version, for illustration
* only, dBASE III Plus tested.
*
STORE RECNO() to edrecno && Save current position
DO WHILE .T.
STORE ssn TO M_ssn && Create memvars from record
STORE name TO M_name
STORE address TO M_address
STORE city TO M_city
STORE state TO M_state
STORE zip TO M_zip
READ && Display entry screen
IF READKEY() = 12 && ESC means cancel
EXIT
ENDIF
IF M_ssn # ssn && If it's been changed
SEEK m_ssn && Check for ssn duplicate
IF FOUND()
GOTO edrecno && Restore position after seek
@ 8,0 SAY ' Record with that key already exists. Try again.'
@ 9,0 SAY ' Press any key to continue. '
WAIT ""
LOOP
ENDIF
ENDIF
REPLACE SSN WITH M_SSN && Replace fields with memvars
REPLACE NAME WITH M_NAME
REPLACE ADDRESS WITH M_ADDRESS
REPLACE CITY WITH M_CITY
REPLACE STATE WITH M_STATE
REPLACE ZIP WITH M_ZIP
EXIT
ENDDO
GOTO edrecno && Restore position after seek
RETURN