Re: Working with arrays
Posted in 1994
jcm@frank.nccom.com (John Musselman) writes:
>I would like to know if there is an easy way to take advantage of more
>than the default(s) keyboard keys when working with screen arrays.
>What I would like to do is have a screen full or customers come up in
>an array and then allow the user to push say for example, "c" to code
>them for an update to be completed. Then after they exit the screen
>array, anything marked "c" would complete a patterned update (based
>upon what "c" should do).
My approach would be to have a 1-CHAR field at the start of the array
that would allow the user to type the appropriate character, and react
appropriately:
DEFINE la_table ARRAY[##] OF RECORD
inp CHAR(1),
col1 LIKE table.col1,
...
ne CHAR(1) # NOENTRY
END RECORD
...
INPUT ARRAY la_table WITHOUT DEFAULTS FROM sa_table.*
BEFORE ROW
LET arr = arr_curr()
LET scr = scr_line()
...
BEFORE FIELD col1
# do this in a BEFORE FIELD col1 instead of
# AFTER FIELD inp because if the user navigates with
# up/down arrow keys or types ACCEPT, we don't want
# to do all this
CASE
WHEN LENGTH(la_table[arr].inp) = 0
# No Action Required for this row, go to the next row
NEXT FIELD ne
WHEN la_table[arr].inp = "D"
# This row marked for delete, skip to next row
NEXT FIELD ne
WHEN la_table[arr].inp = "C"
# This row marked to Change col5 only
NEXT FIELD col5
...
OTHERWISE
ERROR "Don't understand ", la_table[arr].inp
NEXT FIELD inp
END CASE
AFTER FIELD col5
...
IF la_table[arr].inp = "C" THEN
# for type-C changes, only this column is allowed,
# so go to next row
NEXT FIELD ne
END IF
...
END INPUT
...
FOR arr = 1 TO ###
CASE
WHEN LENGTH(la_table[arr].inp) = 0
# No Action Required for this row
CONTINUE FOR
WHEN la_table[arr].inp = "D"
# This row marked for delete
DELETE FROM table
WHERE primary_key = la_table[arr].primary_key
WHEN la_table[arr].inp = "C"
# This row marked to Change col5
UPDATE table
SET col5 = la_table[arr].col5
WHERE primary_key = la_table[arr].primary_key
...
END CASE
END FOR