home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / database / 1783 < prev    next >
Encoding:
Text File  |  1993-01-23  |  1.9 KB  |  64 lines

  1. Newsgroups: comp.sys.mac.databases
  2. Path: sparky!uunet!stanford.edu!CSD-NewsHost.Stanford.EDU!Xenon.Stanford.EDU!michaelh
  3. From: michaelh@Xenon.Stanford.EDU (Mike Hennahane)
  4. Subject: Re: 4D Field Incrementing
  5. Message-ID: <michaelh.727751860@Xenon.Stanford.EDU>
  6. Sender: news@CSD-NewsHost.Stanford.EDU
  7. Organization: CS Department, Stanford University, California, USA
  8. References: <1993Jan22.081803.9058@netcom.com>
  9. Distribution: usa
  10. Date: 23 Jan 93 01:17:40 GMT
  11. Lines: 51
  12.  
  13. i think i know what you are asking here.  my solution is to create a
  14. file called Constants consisting of 2 fields, SequenceName and
  15. NextNumber.  when i need a number i get it from this file and
  16. increment the nextNumber for the next time i need it.
  17.  
  18. at the end of this message is a stripped down version of what i use.
  19. i call the function NextNumber, and the call looks like:
  20.  
  21. [Client]ID:=NextNumber("Clients";true;1000)
  22.  
  23. this call gets the next number in the Clients sequence, increments the
  24. next number (true), and starts at 1000 if the sequence must be created.
  25.  
  26. so, in the BEFORE stage of an input layout, the code would be:
  27.  
  28. if (Record Number([Client])=-3) ` new record
  29.      [Client]ID:=NextNumber("Clients";true;1000)
  30. end if  
  31.  
  32. here's the NextNumber code
  33.  
  34. ` NextNumber global proc.->$1=sequence name, $2=true=increment,
  35. ` $3=starting value
  36. C_LONGINT($0;$3)
  37. C_STRING(20;$1)
  38. C_BOOLEAN($2)
  39. READ WRITE([Constants])
  40. SEARCH([Constants];[Constants]SequenceName=$1)
  41. If (Records in selection([Constants])=0)
  42.   CREATE RECORD([Constants])
  43.   [Constants]SequenceName:=$1
  44.   [Constants]NextNumber:=$3
  45. End if 
  46. If (Locked([Constants]))
  47.   While (Locked([Constants]))
  48.     LOAD RECORD([Constants])
  49.   End while 
  50. End if 
  51. $0:=[Constants]NextNumber
  52. If ($2)
  53.   [Constants]NextNumber:=[Constants]NextNumber+1
  54. End if 
  55. SAVE RECORD([Constants])
  56. READ ONLY([Constants])
  57. UNLOAD RECORD([Constants])
  58.  
  59.  
  60. i hope this helps (assuming it was even the problem that you were
  61. asking about).
  62.  
  63. --mike
  64.