Re: 4GL monitoring program
Posted in 1997
Well, the trick here is not to check for keys being pressed by the user, but to interrupt an INPUT statement in a timely manner, along these lines: let do_loop=true while do_loop <load & display data> let int_flag=false input by name next_data_set on key (some_key) #you need a way to flag that the user let do_loop=false #wants to quit exit input end input if (next_data_set is not null) then <choose data to be shown> end if end while (Added bonus - if the user hits the interrupt key, the data is reloaded before the timeout) Now, the tricky part is to interrupt the input statement from the outside world. Even though alarm() and a SIGALRM handler that kill(getpid(), SIGINT) are likely candidates, their use only works *outside* input statements or menus, since, as Jonathan Leffler pointed out many a time (and mind you, I just can't see a more authoritative opinion on the subject around here), alarm is used internally by 4gl to implement the DBESCWAIT functionality. The solution instead is to spawn a child process that sends a SIGINT back to the parent at regular intervals. HTH, Marco _______________________________________________________________________________ Marco Greco, Catania, Italy Informix faq http://www.iiug.org/ marcog@linux.ctonline.it 4glworks http://www.ctonline.it/~marcog rem radioterapia +39 95 447828 fax 446558 Rob Prop wrote: > > Does anybody know how to make user-interaction possible in Informix 4GL > without waiting for the user to press a key. My goal is to create a > monitoring program that shows the number of open sessions, locked > records and so on from the systmaster database. > It must also retrieve status information from the application > database. The monitoring screen consists out of several windows. > Now the data shown is always the same, and the program runs in a loop > with a sleep command in it. Because I cannot show all the information > on the screen, I want to give the user the possibility to change his > view. Therefore I need the user interaction in a loop without waiting > for it. In other languages such as pascal this is not a problem but how > can I solve this problem in Informix 4GL. We have 4GL version 6.04. > > Hereby I want to thank anyone who wants to help me.