Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!apple!agate!garnet.berkeley.edu!bmug From: bmug@garnet.berkeley.edu (BMUG) Newsgroups: comp.sys.mac Subject: Re: 4D 2.0 question Message-ID: <1989Oct3.145614.24672@agate.berkeley.edu> Date: 3 Oct 89 14:56:14 GMT References: <35206@apple.Apple.COM> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: bmug@garnet.berkeley.edu (BMUG) Organization: University of California, Berkeley Lines: 24 In article <35206@apple.Apple.COM> chuq@Apple.COM (Chuq Von Rospach) writes: >Here's a question for the folks who are using 4D. I've got a file with a >unique key. I'm going to be generating that key in a procedure, and I want >to check for the previous existence of that key programmatically. What is >the most efficient way of doing that? > The way I'd do it would be to enter the key into a variable, do a PUSH RECORD, search for the key (should take a few milliseconds if the key field is indexed), do a POP RECORD if the search comes up empty (and continue entering your record), or bring up an appropriate alert or dialog if the key already exists, and give the user the opportunity to enter a new key (then search, etc.) before POPping the RECORD. 4D will automatically catch an attempted entry into a unique field where a key already exists, but if you'll be generating field contents procedurally, this will give the user some added control, with an extremely small sacrifice in speed. John Heckendorn /\ BMUG ARPA: bmug@garnet.berkeley.EDU A__A 1442A Walnut St., #62 BITNET: bmug@ucbgarne |()| Berkeley, CA 94709 Phone: (415) 549-2684 | |