Re: ON KEY with EXIT INPUT: loosing field data
Posted in 1995
akent@cix.compulink.co.uk ("Andy Kent") wrote: > .... > > However, I have run into the problem described in the INPUT manual page. > > The ON KEY command expects to return to the current field. Because my > > ON KEY contains an EXIT INPUT statement, any data changes in the current > > field are discarded when the EXIT INPUT is done. > > > > The manual says that I can do a NEXT FIELD to another field to keep the > > changed data. I tried that, but it only works if the cursor actually > > lands in the new field. Doing a NEXT FIELD and then a BEFORE FIELD > > containing an EXIT INPUT does not save field changes. The problem is I > > can not actually land in another field because the function key press is > > supposed to take me to another form. > .... > .... > > Have a look at the get_fldbuf() function. The get_fldbuf() is not practical in all cases. If you have a form with many fields, picked out of several records, the get_fldbuf() function is very tedious to use and ridiculous to maintain. If the user is in any one of the fields and presses a key (other than accept) e.g. to jump to another form, he will lose any newly typed data in the field. To use get_fldbuf() requires specifying every field in the form (in some cases it may be possible to use record.* notation). Whenever the program is changed and fields added or taken away, the get_fldbuf() section has to be updated. In my book this is an bug trap, and it may be better to have all the fields never work right than some of them work and some not. What is needed is a more general method that doesn't require maintenance. One idea which may be tried is using a c function to put the accept key value into the keyboard buffer. The 4gl code would then look something like this: let accept_flag = true input .... on key (f9) -- some key other than accept let accept_flag = false call put_accept() .... after input if accept_flag then .... end if end input Has anyone done this or have any other ideas?