Re: ACCEPT Key
Posted in 1995
John Brown (johnb) wrote: : Is there any possible way to have more than one accept key when using : an INPUT statement in 4GL. I know I can change the accept key using : OPTIONS ACCEPT KEY F1, but what I really want to say is OPTIONS ACCEPT : KEY (ESC,F1). I have tried to use an ON KEY EXIT INPUT, but this exits : the INPUT statement immediately without performing any of the : BEFORE/AFTER field checks. The only way I can think of (and it may be painful) is to duplicate the field testing code in ON KEY code block, or maybe AFTER INPUT, which I believe will still be triggered on an EXIT INPUT (you should make sure of this). You can reduce the code duplication by CALLing functions that do the actual testing and return TRUE/FALSE for the pass/fail. Don't forget to do a get_fldbuf() in your ON KEY statement. From (flawed) memory (i.e. refer to the manual for details): INPUT BY NAME ... ON KEY (accept,key,list) LET m_input_record.* = get_fldbuf(*) <<- I don't remember how to get all fields in get_fldbuf(), but it can be done # check fields as required IF field_a_fails() THEN NEXT FIELD a END IF ... AFTER FIELD a IF field_a_fails() THEN NEXT FIELD a END IF ... AFTER INPUT # if you have a default ACCEPT key as well as those in ON KEY: # check fields as required IF field_a_fails() THEN NEXT FIELD a END IF ... END INPUT ... FUNCTION field_a_fails() DEFINE failed SMALLINT LET failed = FALSE IF some check on modular.a fails THEN ERROR "This check failed" LET failed = TRUE END IF ... RETURN failed END FUNCTION ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed Principal 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.