# 4D_ObjEvent(ObjType, ObjIndex, Handler) hash function
Declares a named subroutine as the handler for an event from the nominated 4D object. Any data returned by the 4D object will be in floating point register W.
ObjType is the 4D systems Object. These are defined in the ViSi-Genie reference manual. ObjIndex is the object number of that particular type.
If the object generates an event (say a user presses a button) the system will execute a GoSub to the subroutine at Handler.
Example:
Say you have the following line somewhere in your program. It declares evMyButton to be the subroutine to be called if WinButton (4D terminology) number 23 is pressed on the 4D screen:
k4D_Winbutton EQU 6 ;4D's object number for a "WinButton" # 4D_ViSi 4D_Obj_Event(k4D_Winbutton, 23, evMyButton)
Then elsewhere in your program you might have the following handler:
evMyButton: On 8 ;Turn on output 8 in response to WinButton 23 on the 4D screen
Return
This is powerful magic … it takes only a line or two of code to link the press of a graphical (totally unreal) button on a screen to a real-world action, namely turning on an output, which may be driving a relay that launches a rocket.
Some 4D objects return numerical data. For example, a Slider will return the numerical value of the slider when a user moves it. This data is in W when the event handler subroutine is called.