home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- FUNCTION NODUPL (key_mvar, look_index, key_field, user_func)
- *****************************************************************
-
- * Tests key field and displays message if duplicate value exists
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- # include "inkey.ch"
-
- LOCAL old_help := IF(TYPE('helpcode') = 'C', helpcode, ''), ;
- old_ndx := INDEXORD(), old_recd := RECNO(), ;
- ret_value := .T.
-
- IF PCOUNT() < 3
- * Error in calling syntax
- RETURN(.F.)
- ENDIF
-
- IF PCOUNT() = 4
- * If a user function is passed, execute it
- &user_func()
- ENDIF
-
- IF TYPE('helpcode') = 'C' .AND. UPPER(helpcode) = 'EDIT' ;
- .AND. key_mvar = key_field
- * Allow key variable to remain unchanged when editing
- RETURN(.T.)
- ENDIF
-
- * Check for a duplicate key value
- SET ORDER TO look_index
- SEEK key_mvar
-
- IF FOUND()
- * We have a duplicate keyfield
- ret_value = .F.
- ERRORBEEP()
- helpcode = "DUPLICATE"
-
- * If AEDBAR is in use, display "duplicate" message, and
- * ask operator if reentry of data is desired.
-
- IF TYPE('aedbar') = 'L' .AND. aedbar
- * Display the "duplicate" message
- AEDMSG('mw_dupkey')
-
- IF OPCONFIRM()
- * Operator wants to reenter
- AEDMSG('mw_pgdn')
- ret_value = .F.
- ELSE
- * Operator wants to abort
- AEDMSG('mw_init')
- * Stuff keyboard with Esc to abort READ
- KEYBOARD CHR(K_ESC)
- ENDIF
- ENDIF
- ENDIF
-
- helpcode = old_help
- GOTO old_recd
- SET ORDER TO old_ndx
- RETURN(ret_value)
-
-