Re: 4gl Input array question?
Posted in 1997
Matt Brickley wrote: > > 4GL 4.12, SE 5.01, SCO Unix 3.2v4.2 > > I have a table with 8 columns. I want to let the user update, delete, > or insert to a screen array with only 6 of the columns displaying. > How can I do this when the number of variables in the screen array > must match the program array? Matt, I have this situation all the time. Here's my approach: 1. Define a record array consisting of only the columns corresponding to the screen array. 2. Define another record array consisting of the columns in the table that are *not* on the screen. This might be the original record array of like table.*. 3. When you read the array data in you FOREACH loop, read it into the complete record[i].*; then copy those 6 fields into display-rec[i].* . Note that there probably is no shortcut (except MAYBE "thru") here; you need to copy one field at a time. 4. Run the INPUT ARRAY WITHOUT DEFAULTS against the shorter record array. Note that this is especially useful because the original full record array also serves as your backup data in case the user updates every blessed row in the array and then decides to abort the input after all that. BTW, the code generated by FOURGEN is similar to the above algorithm. > For simplicity sake, I want to let 4gl handle the array and when the > user is done modifying the array, I want to delete all of the rows in > the table and insert all of the changed rows from the screen/program > array Simplicity is pleased with your efforts. Sounds reasonable; any other way and you have to figure out if this is an updated row, a new row, or an untouched row in a new position... yucchh! Just make sure you do all that inside a transaction. >TIA MARIA (On the rocks.. ;-) -- -- Jake (In pursuit of undomesticated aquatic avians) +-----------------------------------------------------------+ | Impeccable Logic: A thought process which successfully | | resists chicken bites | +-----------------------------------------------------------+