home *** CD-ROM | disk | FTP | other *** search
- /* Make a unique ID number
- * ARrexx script for db that makes a unique ID if nothing is entered in the
- * current field or searches for duplicates if something IS entered.
- * The script will never reuse a previously removed ID.
- *
- * By David Ekholm 1995
- * $VER: unique.db 1.0 (26.9.95)
- *
- */
-
- Options Results
-
- CurrentRecord
- newrec = result
-
- GetField
- keyval = result
- BlockInput
-
- if keyval ~= "" then do /* Check for duplicates */
- Mode 'Find'
- Kill
- PutField keyval
- FindFirst
- if result == newrec then FindNext
- matchrec = result
- CurrentRecord newrec
- FreeInput
- if matchrec ~= newrec then do /* This record is a duplicate */
- DisplayBeep
- Okay1 "There is already a record with this key!"
- PutField ""
- RetryInput
- end
- end
- else do /* Make a unique ID instead */
- maxID = 1
- FirstRecord
- do while rc == 0
- GetField
- if result >= maxID then maxID = result + 1
- NextRecord
- end
- CurrentRecord newrec
- FreeInput
- PutField maxID
- end
-