Article View: comp.sys.mac.databases
Article #648Re: 4D Field Incrementing
From: Mike Hennahane
Date: Sat, 23 Jan 1993 01:17
Date: Sat, 23 Jan 1993 01:17
51 lines
1993 bytes
1993 bytes
i think i know what you are asking here. my solution is to create a
file called Constants consisting of 2 fields, SequenceName and
NextNumber. when i need a number i get it from this file and
increment the nextNumber for the next time i need it.
at the end of this message is a stripped down version of what i use.
i call the function NextNumber, and the call looks like:
[Client]ID:=NextNumber("Clients";true;1000)
this call gets the next number in the Clients sequence, increments the
next number (true), and starts at 1000 if the sequence must be created.
so, in the BEFORE stage of an input layout, the code would be:
if (Record Number([Client])=-3) ` new record
[Client]ID:=NextNumber("Clients";true;1000)
end if
here's the NextNumber code
` NextNumber global proc.->$1=sequence name, $2=true=increment,
` $3=starting value
C_LONGINT($0;$3)
C_STRING(20;$1)
C_BOOLEAN($2)
READ WRITE([Constants])
SEARCH([Constants];[Constants]SequenceName=$1)
If (Records in selection([Constants])=0)
CREATE RECORD([Constants])
[Constants]SequenceName:=$1
[Constants]NextNumber:=$3
End if
If (Locked([Constants]))
While (Locked([Constants]))
LOAD RECORD([Constants])
End while
End if
$0:=[Constants]NextNumber
If ($2)
[Constants]NextNumber:=[Constants]NextNumber+1
End if
SAVE RECORD([Constants])
READ ONLY([Constants])
UNLOAD RECORD([Constants])
i hope this helps (assuming it was even the problem that you were
asking about).
--mike
Technical Details
Message-ID:
<michaelh.727751860@Xenon.Stanford.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!michaelhReferences:
<1993Jan22.081803.9058@netcom.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.mac.databases Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!michaelh From: michaelh@Xenon.Stanford.EDU (Mike Hennahane) Subject: Re: 4D Field Incrementing Message-ID: <michaelh.727751860@Xenon.Stanford.EDU> Sender: news@CSD-NewsHost.Stanford.EDU Organization: CS Department, Stanford University, California, USA References: <1993Jan22.081803.9058@netcom.com> Distribution: usa Date: 23 Jan 93 01:17:40 GMT Lines: 51