4GL INPUT ARRAY for Ryan Mcfall
Posted in 1994
This mail keeps getting bounced, so I'll try posting.
Subject: Re: Input array help
To: cps.msu.edu!mcfallry@uunet.uu.net (Ryan L Mcfall)
> What I need to be able to do is to somehow have two input array statements
> "active" at the same time, and to be able to switch back and forth between
> them easily. The trick is getting the statements to "remember" where they
> were when they were last active. I have no problem accomplishing this
> when the user only has one screenful of data, but when there could be more
> I run into problems.
>
My approach would be to eliminate multiple screens in the INPUT ARRAY with an
array sized just for the screen, using a temp table to store the values above
and below the screen, and ON KEY statements to emulate NEXT, PREVIOUS, and (if
required) INSERT and DELETE. Then the arrg/NOENTRY trick works fine.
I have some sample code that does all this that I'll dig out tonight and send to
you. It is my generic pick screen module, so it doesn't do the INSERT or DELETE
stuff, but that is pretty manageable.
I assume by your mail that you've covered all the problems with recursiveness
and set_count() I anticipate. If not, let me know and I'll elaborate.
...
Here's my pick.4gl code, which I hope will get you a start on you
"dueling arrays" problem. Look it over and see if you can figure it
out. Remember that the intent of this code is to provide a pick screen
with some fancy features; so no input testing is in place. If you get
stuck or have some specific questions, fire away.
If it can wait until this weekend, I'll pull together a more specific
example for you. Let me know if it would be useful and spell out some
specifics of the perform screens and etc. involved.
=======================================================================
Dennis J. Pimple dennisp@informix.com Opinions expressed are
Senior Consultant -------------------- soley my own, & 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 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 SMALLINT # max array size
DEFINE mpick_s SMALLINT # screen record
DEFINE mpick_t SMALLINT # total records in temp table
DEFINE mseltxt CHAR(500) # Select clause
DEFINE ma_pick ARRAY[15] OF RECORD
pck CHAR(1), # cursor/input field
jump CHAR(10), # field we're jumping to; NOENTRY
descr CHAR(45) # any other display; NOENTRY
END RECORD
DEFINE ma_pct ARRAY[15] OF RECORD # non-screen values
arr SMALLINT, # array value; order we inserted the records
cod CHAR(10), # code to return when picked
ct SMALLINT # order we picked the record in
END RECORD
DEFINE m_picktab RECORD
pck CHAR(1), # cursor/input field
jump CHAR(10), # field we're jumping to; NOENTRY
descr CHAR(45), # any other display; NOENTRY
arr SMALLINT, # array value; order we inserted the records
cod CHAR(10), # code to return when picked
ct SMALLINT # order we picked the record in
END RECORD
#---------------------------------------------------------------------#
FUNCTION init_pick()
# Arguments: N/A
# Purpose: Initialize modular variables for working with picker.
# This function should be called in the MAIN of each
# module that may use a picker.
# Returns: N/A
#---------------------------------------------------------------------#
LET mpick_x = 15
LET mpick_s = 15
# do the thing we do for each change in picker
CALL reset_pick()
END FUNCTION
# init_pick()
#---------------------------------------------------------------------#
FUNCTION reset_pick()
# Arguments: N/A
# Purpose: Clear the temp table and prepare to fill it with the
# pick values of a new table, or with a different SELECT
# clause of the same table.
# Returns: N/A
#---------------------------------------------------------------------#
LET mpick_t = 0
LET mseltxt = ""
# in case we have the pick temp table already, drop it
WHENEVER ERROR CONTINUE
DROP TABLE picktabWHENEVER ERROR STOP
# we rebuild the temp table each time because it's generally
# faster than a DELETE FROM picktab WHERE 1=1
# when the table has a lot of records in it
CREATE TEMP TABLE picktab
(
pck CHAR(1),
jump CHAR(10),
descr CHAR(45),
arr SMALLINT, # array value; order we inserted the records
cod CHAR(10), # code to return when picked
ct SMALLINT # order we picked the record in
)
DECLARE c_picktab CURSOR FOR
SELECT * FROM picktab
ORDER BY arr
END FUNCTION
# reset_pick()
#---------------------------------------------------------------------#
FUNCTION sel_pick(lseltxt)
# Arguments: SELECT clause for the pick
# Purpose: Declare cursor to fill pick. The cur