AEVENTS() Function
You can use the AEVENTS() function to retrieve the number of existing event bindings.
AEVENTS( ArrayName [, 0 | oEventObject ] )
Parameters
ArrayName
Specifies the name of the array that contains the results of AEVENTS().0
Specifies that AEVENTS() returns a three-element array containing an object reference to the current event source, the name of the triggered event, and how the event was triggered.Column Description Type 1 Event source Object reference 2 Event String 3 Event type, or how event was raised. 0 - System 1 - RAISEEVENT( ) function
2 - Method call
The third array element indicates how an event was triggered. If the event is a property, this value can be 1 or 2. The value is 2 if the property is set or assigned.
oEventObject
Specifies an object reference. If you specify an object reference, AEVENTS() returns a five-column array that contains the events raised and the delegate methods for oEventObject. Each row in ArrayName represents a binding. The following table describes the information in each of the five columns.Column Description Type 1 .T. if second element is the event source .F. if second element is the event handler
Logical 2 Event source if you pass the event handler to oEventObject; otherwise, event handler if you pass the event source to oEventObject. Object reference 3 Event String 4 Delegate method String 5 BINDEVENT() flags Integer When you pass oEventObject, the number of bindings returned by AEVENTS() should equal the number of unbound events returned by the UNBINDEVENTS() function when passing only the oEventObject parameter.
Return Values
Numeric data type. AEVENTS() returns the number of event bindings, each of which appear as a row in ArrayName.
Remarks
If AEVENTS() returns 0, and the array does not exist, Visual FoxPro does not create the array. Visual FoxPro changes or alters an existing array only if valid results are returned. The array remains unchanged under the following conditions:
- No events exist.
- You specify a value of 0 as the second parameter, and AEVENTS() does not appear within an event or oEventObject has no bindings.
Example
The following example shows how to use AEVENTS( ) to retrieve the number of existing event bindings. BINDEVENTS( ) keeps the Class Browser positioned to the right side of the Visual FoxPro desktop, regardless of how the desktop is resized. For more information, see BINDEVENT() Function.
UNBINDEVENTS( ) detaches the Resize event of the _SCREEN system variable from the object, oHandler
. AEVENTS( ) returns the number of event bindings before BINDEVENT( ) and after UNBINDEVENTS( ) in an array called myArray
:
PUBLIC oHandler
oHandler=NEWOBJECT("myhandler")
DO (_browser)
BINDEVENT(_SCREEN,"Resize",oHandler,"myresize")
AEVENTS(myArray,oHandler)
numRows=ALEN(myArray,1)
numCols=ALEN(myArray,2)
WAIT "Rows in array: " + TRANSFORM(numRows) WINDOW AT 20,20
WAIT "Cols in array: " + TRANSFORM(numCols) WINDOW AT 20,20
FOR count1 = 1 TO numRows
FOR count2 = 1 TO numCols
WAIT myArray[count1,count2] WINDOW AT 20,20
ENDFOR
ENDFOR
UNBINDEVENTS(_SCREEN,"Resize",oHandler,"myresize")
AEVENTS(myArray,oHandler)
numRows=ALEN(myArray,1)
numCols=ALEN(myArray,2)
WAIT "Rows in array: " + TRANSFORM(numRows) WINDOW AT 20,20
WAIT "Cols in array: " + TRANSFORM(numCols) WINDOW AT 20,20
FOR count1 = 1 TO numRows
FOR count2 = 1 TO numCols
WAIT myArray[count1,count2] WINDOW AT 20,20
ENDFOR
ENDFOR
DEFINE CLASS myhandler AS Session
PROCEDURE myresize
_obrowser.left = _SCREEN.Width - _obrowser.width
RETURN
ENDDEFINE
See Also
Functions | Event Binding for Visual FoxPro Objects | BINDEVENT() Function | UNBINDEVENTS() Function | RAISEEVENT() Function