* Function SerialNumber * 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. FUNCTION SERIALNUMBER(tnSequence) 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 flush select (lnSelect) return lnReturnValue ENDFUNC
* Function for GUID PROCEDURE GetGUID DECLARE INTEGER CoCreateGuid ; IN Ole32.dll ; STRING @lcGUIDStruc cStrucGUID=SPACE(16) cGUID=SPACE(80) nSize=40 IF CoCreateGuid(@cStrucGUID) # 0 RETURN "" ENDIF return cStrucGUID ENDPROC