Program: Superbase 4 Version: 1.3 Topic: Assigning a unique serial number to a record in a file. Date: August 19, 1992 Summary: The SER function assigns a unique serial number to each record in a file. A serial number can be added to the file definition when a file is created or after a file contains records. This technote explains how to add a field that generates a unique serial number to a new file and to a file with existing records. How Superbase generates the number The SER function generates number based on the number of records added to a file. When you create the first record in a file, the serial number generated is one. This value is incremented by one for each record you add to the file. If records are deleted the serial number is never reissued. Create the serial number field 1. In the File Definition dialog (choose Modify from the File menu), add a numeric field called Sernum. The format should be able to accommodate the maximum number of records your file will hold. 2. To generate the serial number automatically, make the Sernum field a constant. The constant formula is SER("filename"). 3. Save the file modification. All new records are assigned a serial number in the Sernum field. Put serial number values in existing records To add a serial number field to a file that already contains records, follow steps one through three above, then update the existing records. 1. Initialize a counter in the Database Command dialog by typing x% = 0 Click OK. (To access the Database Command dialog, press Alt- F1 or select Command from the DML menu.) 2. Select Update from the Process menu. 3. To update all records, leave the Update Filter dialog empty and click OK. 4. To add an incremental number to each record, the Update Definition is x% = x% + 1: Sernum = x% After this update, all records in the database have a unique value in the Sernum field, and all new records will be assigned a new number.