Re: Advanced use of 'DISPLAY ARRAY', or 'aiming too high?'
Posted in 1994
whudace@bgsu.edu (Bill Hudacek) writes: >... >I'm using 'DISPLAY ARRAY' to present a list of choices to the user; >this may run to hundreds of choices, in a 5- to 10- line scroll >area... >Page up/down and scroll keys are unacceptable. >Minimal 'incremental matching' would be great <:), but I'd be >willing to be able to read ANY char except those in the >ON KEY clause, and apply it to move pointers (so the 'next' element >in the array that started with that character was visible...) Below is my picklist code, which uses a temp table and allows jump matching, multiple picking, and a bunch of other stuff. I use INPUT ARRAY because of its versitility over DISPLAY ARRAY. I hope it's commented well enough so you can figure it out. The example can be broken into three files: ptest.4gl shows how to fold the picker into your other 4gl code; pick.per is the perform screen for the picker, and pick.4gl is the pick functions themselves. Let me know if you need further details. ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed Senior Consultant -------------------- are mine, and do not Informix Software Inc Voice: 303-850-0210 necessarily reflect Denver Colorado USA Fax: 303-779-4025 those of my employer. ------------------------ CUT HERE FOR ptest.4gl ------------------------ # Module: %M% SCCS: %I% %P% # Program: *.4gi DATABASE budget MAIN DEFINE arr SMALLINT DEFINE x SMALLINT DEFINE r SMALLINT DEFINE l_pick RECORD # record for the select jump CHAR(10), descr CHAR(45), cod CHAR(10) END RECORD DEFINE seltxt CHAR(500) DEFER INTERRUPT # put init_pick in the MAIN of the program that calls pick CALL init_pick() # use this method to fill the picker if you can't create a # SELECT statement like the code following FOR arr = 1 TO 50 LET l_pick.jump = jump_vlu(arr) LET l_pick.cod = arr USING "<&", arr USING "&&&&&&&&" LET l_pick.descr = "PICK VALUE ", l_pick.jump CLIPPED, " ", l_pick.cod CLIPPED CALL ins_pick(l_pick.*) END FOR # use this method to fill the picker if possible. # It fills the temp table with the results of the SELECT. # it has to provide three values exactly. # Other details are commented on in pick.4gl ##LET seltxt = "SELECT titles.tnm, issues.inm, issues.iid", ## " FROM titles, issues WHERE issues.tid = titles.tid", ## " ORDER BY titles.tnm, issues.iid" ## ##CALL sel_pick(seltxt) CLEAR SCREEN WHILE TRUE PROMPT "HOW MANY TO PICK? " FOR arr IF int_flag THEN EXIT WHILE END IF IF arr > 20 THEN ERROR "GET SERIOUS" CONTINUE WHILE END IF # this does the actual picking. # Pass a 0 to let them pick up to all values in the temp table CALL inp_pick(arr) CURRENT WINDOW IS SCREEN IF arr = 0 THEN LET arr = 20 END IF FOR x = 1 TO arr # this gets the values back from the picker CALL rtv_pick(x) RETURNING l_pick.cod, l_pick.descr IF LENGTH(l_pick.cod) = 0 THEN EXIT FOR END IF CALL vld_pick(l_pick.cod) RETURNING l_pick.descr LET r = x+2 DISPLAY x USING "#&", ": ", l_pick.cod CLIPPED, " ", l_pick.descr CLIPPED AT r, 1 END FOR END WHILE END MAIN FUNCTION jump_vlu(arr) DEFINE arr SMALLINT DEFINE x SMALLINT DEFINE jump CHAR(10) LET x = arr WHILE x > 26 LET x = x - 26 END WHILE CASE WHEN x = 1 LET jump = "A" WHEN x = 2 LET jump = "B" WHEN x = 3 LET jump = "C" WHEN x = 4 LET jump = "D" WHEN x = 5 LET jump = "E" WHEN x = 6 LET jump = "F" WHEN x = 7 LET jump = "G" WHEN x = 8 LET jump = "H" WHEN x = 9 LET jump = "I" WHEN x = 10 LET jump = "J" WHEN x = 11 LET jump = "K" WHEN x = 12 LET jump = "L" WHEN x = 13 LET jump = "M" WHEN x = 14 LET jump = "N" WHEN x = 15 LET jump = "O" WHEN x = 16 LET jump = "P" WHEN x = 17 LET jump = "Q" WHEN x = 18 LET jump = "R" WHEN x = 19 LET jump = "S" WHEN x = 20 LET jump = "T" WHEN x = 21 LET jump = "U" WHEN x = 22 LET jump = "V" WHEN x = 23 LET jump = "W" WHEN x = 24 LET jump = "X" WHEN x = 25 LET jump = "Y" WHEN x = 26 LET jump = "Z" END CASE LET jump = jump CLIPPED, "OOO" RETURN jump END FUNCTION ------------------------- CUT HERE FOR pick.per ------------------------ { ======================================================== Module: %M% SCCS: %I% %P% Program: *.4gi (pick.4gl) Purpose: Generic Pick Screen Author: Dennis J. Pimple Date: %G% %U% ======================================================== } DATABASE FORMONLY SCREEN { =PICK========================================================== [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] [a|a001 |a002 ] =============================================================== } ATTRIBUTES a = FORMONLY.pck TYPE CHAR, UPSHIFT, AUTONEXT, COMMENTS = "Type PICK, ACCEPT, or Letter"; a001 = FORMONLY.jump TYPE CHAR, NOENTRY; a002 = FORMONLY.descr TYPE CHAR, NOENTRY; INSTRUCTIONS DELIMITERS " " SCREEN RECORD s_pick[15] (FORMONLY.pck, FORMONLY.jump, FORMONLY.descr) END ------------------------- CUT HERE FOR pick.4gl ------------------------ # Module: %M% SCCS: %I% %P% # Program: *.4gi # Purpose: Functions to work with a generic pick array # Author: Dennis J. Pimple # Date: %G% %U% # counters to work with ma_pick DEFINE mpick_x