Mid-Michigan Computer Consultants - Bay City, Michigan

CONTENTS       (old style)
Mid-Michigan Computer Consultants
509 Center
Bay City, Michigan

Sales (989) 892-9242
Support (989) 686-8860

Plb-0380.cfm v1.0


ANSI Standard PL/B Language and Visual PL/B

Event Handling

Events are everything in the windows environment. You click a key and it causes an event. You move the mouse and it causes an event.

When you create a form with Sunbelt's Visual PL/B form designer you can double click an object and add coding for any of the events that object type can detect.

Sometimes you need to evaluate a key press to anticipate what the user is trying to do. Consider the example shown beloe. We have a datalist of items and an edit text with a value. When the user updates the value the program updates the currently selected item in the datalist.

What we want to do is be responsive to the user. If they press an arrow up or arrow down key we want to detect that and automatically move to the previous or next line in the data list. So How do we get that keystroke?

The answer is to check the KEYPRESS event in the PLF (form) file using the designer. (See second screen print below).

The only problem with this is that the various event responses are avaiilable in the designer as "#" variables. That means that they can be seen in the designer only. We could process the event right there in the code in the designer, but at MMCC we don't do that. Rather we move a literal to the variable "ACTION" and evaluate it back in the mainline after the WAITEVENT.

To capture the event data, we move the # variable to a variable in our standard set of variables found in our COMMONWK include unit. This allows us to transfer them from the PLF code to the mainline code.

We'll add more to this article later. For now, just check out the code.

The EventResult will give you the numerical value of the key that's been pressed.

Code in the PLform on the Key Press event:
	  MOVE	#EventChar,    EventChar
	  MOVE	#EventMod,     EventMod
	  MOVE	#EventResult,  EventResult      
	  MOVE	#EventType,    EventType
Code in the mainline to see what we got:
            ACTION = "EXIT")
            DISPLAY  "Event Result:":

Write to MMCC Technical Support at:               Send e-mail to MMCC.
MMCC - Technical Support
600 W. Midland
Bay City, MI 48708
(989) 686-8860
© 1997 - 2022 MMCC - All Rights Reserved