Dynamic Arrays
Posted in 1992
In X-Informix-List-Id <newsgate.577>, Jacob Salomon of Informix Software, Inc. gave some sample code for using a fixed array to store rowid's from a scroll cursor. This would let users delete a row in the current list and not have it redisplayed when they did a "Fetch Previous." The main problem with the code is that you are limited to selecting no greater number of rows than the number declared for the size of the array DEFINEd in the function. In other words if you defined your array to be 1000 variables in length and your select statement returned 1500 rows, then you couldn't see the last 500 rows (you would have to increase your array size to 1500 and recompile the program). This problem exists with both screens and arrays. The only real solution I found was the db4glgen code generator written by Dave Snyder (at Snide Inc - Folcroft, PA. INTERNET: Dave.Snyder@snide.com). The only problem with Dave's code is that it uses a few "difficult" C functions. I use the word "difficult" for those of us who have little or no C knowledge or experience. (I have one book on C and the memory allocation features that Dave Snyder uses are not in this book; that "advanced" topic is left to the author's sequel!) But Dave's code *does* work. Some year I may have enough C know-how to use it in a 4GL program. I'm looking for a way to handle dynamic arrays without using C code. I need a screen array that can display any number of records and let users add, update, and delete rows (after a query of course). This dynamic array handler could be used indefinitely, no matter how many records are added to the table it queries. There is a very good example of a dynamic array handler in the Summer '89 issue of "Tech Notes," but this example is limited to displaying the rows selected from the table. It uses the following: 1) a SCROLL cursor, 2) the INPUT ARRAY statement with the Noentry attribute and a dummy buffer field on the screen form, and 3) the FETCH ABSOLUTE statement that is used to shuffle the rows up and down each time the user scrolls beyond the ends of the screen array. I've been trying to figure out a way to modify this code. First I tried to let the users delete a row. If they go beyond a deleted row and then return, the "old" deleted row reappears (since it's being Fetched from the current list and not the table). There must be a way to fix this problem without resorting to C code! About five months ago, Jim Gordon of DHL Systems Inc., San Mateo, CA had a message on here about a dynamic array handler that he wrote. Jim if you are reading this message, can you post a copy of that program? If not, please tell us how your program works. Is it merely for viewing (like the Tech Notes program)? This problem seems to occur to just about everyone who uses 4GL for any length of time. If you have a good 4GL dynamic array and/or screen handler, maybe you would be willing to let Walt Hultgren at Emory U. add it to the ftp archive. ----- John Baker =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= John Baker, USAISC-Lex, Lexington - Blue Grass Army Depot, Lexington, KY (jbaker@lexington-emh2.army.mil) Phone: (606) 293-3644, 293-3743 DSN: 745- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=