skip to main content

Working With Controls : Creating a control : Embedded Procedures : Event handling

Event handling
As explained above, Embedded Procedures can be used to handle the most common actions the user can do, such as activating and leaving a control.
The user can interact with controls in a number of ways, however, and creating a new Embedded Procedure for every possible action would be confusing and not efficient at all. Handling events is preferable in most cases.
Events are categorized into three groups:
command events (whose name begins with "CMD-") correspond to actions taken by the user that the program needs to act on, such as closing a window or pushing a button. When a command event occurs, the runtime system assigns a value to the EVENT STATUS and then terminates the current ACCEPT with an exception value of "96"
notify events (whose name begins with "NTF-") correspond to informational events that the program may not have to act on, such as editing a text-field or resizing the window. When a notify event occurs, the runtime system assigns a value to the EVENT STATUS and then terminates the current ACCEPT with an exception value of "96"
messages (whose name begins with "MSG-") pass information to a screen control's Event Procedure. This division is somewhat arbitrary, but corresponds to the most common situations. Messages are different from other events, because they do not terminate the current ACCEPT. Messages are sent only to a control's Event Procedure.
Event names are listed as constant items in the isgui.def copybook.
Just one Event Procedure can be assigned to a control at a time and it is executed each time that control fires an event. Within Event Procedures, the EVENT STATUS special registry can be used to monitor and change the event behavior.
Events cannot be nested, therefore in the event procedure code you shouldn’t:
For the above needs, it’s suggested that you:
   if event-type = msg-tv-dblclick 
      move 1 to flag-call
      set event-action to event-action-terminate
   end-if.
accept Screen1 
  on exception
     |do something here
if flag-call = 1
   move 0 to flag-call
   call "ProgramWithNewWindow" 
Note: Embedded and Event procedures are paragraphs and sections automatically executed by the runtime while the user interacts with the screen. The program jumps to these paragraphs as if a PERFORM statement was issued, then, when the paragraph code has been executed, the program returns to the ACCEPT statement. Therefore, it is strongly suggested that you avoid using GO TO statements into these paragraphs; if the program jumps outside these paragraphs through a GO TO statement, it may not be able to return to the ACCEPT, causing it to hang.
Performance Tuning: In the Thin Client environment, when the focus changes, no information is sent from the client to the server if:
In this case the program will run faster.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left