`
ABC: Implementing a Drop List in Edit-In-Place in C5A 1999-04-02 -- Jay Guengerich Newsgroups: topspeed.products.c5ee Implementing a Drop List in Edit-In-Place for C5EEA, ABC Templates Note: I tend to use filename.fieldname rather than PRE:fieldname so I'm sure I know which file I'm referring to. The templates use the PRE:fieldname style, so I left them that way in embed point references and generated code I have copied below. I use long key names so I remember which fields are in the key. Files used in this example: defcalc FILE,DRIVER('TOPSPEED'),NAME(DefcalcFileName),PRE(DCAL),CREATE,BINDABLE,THREAD testtypecalcorderkey KEY(DCAL:testtype,DCAL:calcorder),NOCASE,OPT,PRIMARY calcidtesttypekey KEY(DCAL:calcid,DCAL:testtype),DUP,NOCASE,OPT Record RECORD,PRE() testtype ULONG calcorder USHORT calcid ULONG END END calclist FILE,DRIVER('TOPSPEED'),NAME(CalclistFileName),PRE(CAL),CREATE,BINDABLE,THREAD calcidkey KEY(CAL:calcid),NOCASE,OPT,PRIMARY Record RECORD,PRE() calcid ULONG calcname STRING(50) END END Relationship: defcalc <<-> calclist based on the calcid field, which causes the browse template to generate this view (I have added the comments): BRW1::View:Browse VIEW(defcalc) PROJECT(DCAL:testtype) !Col 1 PROJECT(DCAL:calcorder) !Col 2 PROJECT(DCAL:calcid) !Col 3 JOIN(CAL:calcidkey,DCAL:calcid) PROJECT(CAL:calcid) PROJECT(CAL:calcname) !Col 4 END END Goal: Create a browse with 4 columns; defcalc.testtype, defcalc.calcorder, defcalc.calcid, and calclist.calcname. Use default EIP for testtype and calcorder, and a DropList for calcid. The DropList should be a list of all the records in calclist. For example, one line in the DropList might be "2 Maximum", indicating there is a record in the calclist file with a calcid of 2 and a calcname of 'Maximum'. When inserting a record, prime calcid to 1. Implementation: 1. Variables declared (STRING(13) is used for calcid instead of a ULONG so I can remove the leading spaces from the @n13 format): CalcQ QUEUE,PRE() calcid STRING(13) calcname STRING(50) END CurrentlyUsed LONG 2. Configure Edit in Place: Click Colum Specific, Insert. For Field, choose DCAL:calcid. Uncheck "Use Default…". Check 'Use Application Builder Class?". For "Base Class:", choose EditDropListClass. 3. Embeds: BRW1.PrimeRecord, after parent call: defcalc.calcid = 1 EditInPlace::DCAL:calcid.Init, after parent call: SELF.FEQ{PROP:From} = CalcQ SELF.FEQ{PROP:Text} = '@s13' SELF.FEQ{PROP:Drop} = RECORDS(CalcQ) SELF.FEQ{PROP:Width} = 96 SELF.FEQ{PROP:Format} = '16L@s13@80L@s50@' ! Next section sets DropList to match existing calcid field CurrentlyUsed = 0 LOOP CurrentlyUsed += 1 GET(CalcQ,CurrentlyUsed) UNTIL ERRORCODE() OR CalcQ.calcid = defcalc.calcid SELECT(SELF.FEQ, CurrentlyUsed) ThisWindow.Init, after OpenFiles CLEAR(CalcQ) Access:calclist.UseFile() SET(CAL:calcidkey) LOOP UNTIL Access:calclist.Next() !The next line removes leading spaces CalcQ.calcid = LEFT(FORMAT(CAL:calcid,@n13)) CalcQ.calcname = CAL:calcname ADD(CalcQ) END ThisWindow.Kill, before Parent Call FREE(CalcQ) I think that covers everything. I'm always open to suggestions for improvement. Actually, all the end user would really need to see (for my application anyway) is the defcalc.testtype field and the calclist.calcname field. However, I haven't spent time to figure out how to get EIP to work for a field that is not in the primary file. Also, I didn't include much error checking; for example UseFile() returns a value indicating if the file is ready for use. Jay Guengerich Printed November 23, 2024, 6:42 am This article has been viewed/printed 35429 times. Google search has resulted in 63 hits on this article since January 25, 2004. |