fhSemaphore = fopen("d:\path\file",12) if fhSemaphore > 0 nKey2Use = VAL( fread(fhSemaphore,128) ) + 1 insert into TARGET (field1,field2,fieldPK) values (cVar1, cVar2, nKey2Use) nWrote = fwrite(fhSemaphore, str( nKey2Use )) =fclose(fhSemaphore) else =messagebox("File not available for appending",0,"Try again") endif