ASELOBJ( ) Function
Places object references to currently selected controls in the active Form Designer into a variable array.
ASELOBJ(ArrayName, [1 | 2])
Return Values
Numeric
Parameters
- ArrayName
Specifies the name of the array containing the object references of the currently selected controls. If the array you specify doesn't exist, Visual FoxPro automatically creates the array. If the array exists and isn't large enough to contain all the control information, Visual FoxPro automatically increases the size of the array to accommodate the information. If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists and ASELOBJ( ) returns 0 because no controls are currently selected, the array remains unchanged. If the array doesn't exist and ASELOBJ( ) returns 0, the array isn't created. - 1
Creates a one-element array containing an object reference to the container for the currently selected control. For example, if the currently selected control is a spinner on a form, the array contains an element with the value "FORM." Include 1 when issuing ASELOBJ( ) from within the Command window. Note that if a page frame is selected, ASELOBJ( ) returns the name of the current page. - 2
Specifies that Visual FoxPro creates a one-element array containing an object reference to the DataEnvironment object for the form. The DataEnvironment object allows you to determine the data environment properties for the form.
Remarks
ASELOBJ( ) creates a one-dimensional array containing object references to the currently selected controls in the active Form Designer and returns the number of currently selected controls. If no controls are currently selected and the optional 1 argument is omitted, ASELOBJ( ) returns 0 and the array isn't created. ASELOBJ( ) does not recognize the form as the selected control if there are no controls on the form. If no controls are currently selected and the optional 1 argument is included, ASELOBJ( ) returns 1.
You can use ASELOBJ( ) to create your own control builders.
Example
Before running the following example, open a new form in the Form Designer and add one or more controls with Caption properties, such as a Label or CommandButton, to the form. Select a number of these controls and then run the example. ASELOBJ( ) displays the names of the selected controls, and then changes the captions of the selected controls.
gnobjects = ASELOBJ(gaSelected) && Create array of control names
IF gnobjects > 0 && 0 indicates no controls selected
CLEAR
DISPLAY MEMORY LIKE gaSelected && Displays selected controls
FOR nCnt = 1 TO gnobjects
? gaSelected(nCnt).Caption + ' => New Caption ' ;
+ LTRIM(STR(nCnt)) && Display old and new caption
gaSelected(nCnt).Caption = 'New Caption ' ;
+ ALLTRIM(STR(nCnt)) && Assign new caption
NEXT
ENDIF
See Also
CREATE FORM | DataEnvironment Object | Form Designer | _ObjectReference( ) API Library Routine | AMOUSEOBJ( ) Function