if not used("ids") use ids in 0 endif select ids
********************************************************************** FUNCTION SERIALNUMBER(tnSequence) * Get serial number. Used mainly to generate primary keys. * The easiest way to achieve this is to call this function from a fields default value. tnSequence = lower(tnSequence) local lnSelect lnSelect = select() if used("serialnumber") select serialnumber else select 0 use serialnumber endif set order to "sequence" seek padr(tnSequence, len(sequence)) if not found() append blank replace sequence with tnSequence, nextnum with 1 endif local lnReturnValue if lock() lnReturnValue = nextnum replace nextnum with nextnum + 1 else lnReturnValue = -1 endif unlock select (lnSelect) return lnReturnValue ENDFUNC