Thread View: comp.sys.mac.databases
2 messages
2 total messages
Started by Jeff
Fri, 22 Jan 1993 08:18
4D Field Incrementing
Author: Jeff
Date: Fri, 22 Jan 1993 08:18
Date: Fri, 22 Jan 1993 08:18
38 lines
1511 bytes
1511 bytes
I want to increment ad integer in an Input Layout starting @ 1000. I created a "dummy" file with one record that has the value of 1000. Then I added a script to the individual fields that have the same name in a different file, as in the dummy file. So I want to assign a the number to the field once, but I don't want it to update as the value in the Dummy field increments for Adding Records later on... If I have a [Clients]ClientNumber field, and a [Dummy]ClientNumber place holder field, can I assign the value and increment it like this?: $RecNum:=Record number If ($RecNum=-3) vClientNum:=([Dummy];[Dummy]ClientNum)+1 ([Dummy];[Dummy]ClientNum):=vClientNum [Clients]Client_Num:=vClientNum End If I think something like this in the [Clients]ClientNumber field would work, but I tried it and it doesn't work... Or is this better for some reason?: If ([Clients]Client Number=0) [Clients]Client Number:=[Dummy]Client Number SAVE RECORD([Clients]) [Dummy]Client Number:=([Dummy]Client Number + 1) Save Record([Dummy]) End if If you see obvious syntax errors, feel free to point them out (other than field names). Thanks, Jeff-
Re: 4D Field Incrementing
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads