Condividi tramite


AGETCLASS( ) Function

Displays class libraries in the Open dialog box and creates an array containing the name of the class library and class chosen.

AGETCLASS(ArrayName [, cLibraryName [, cClassName [, cTitleText   
[, cFileNameCaption [, cButtonCaption]]]]])

Parameters

  • ArrayName
    Specifies the name of the array in which the names of the class library and class are placed. The following table lists the contents of each element of the array created when you chose a class.

    Element Contents
    1 File name of the class library chosen.
    2 Name of the class chosen.
  • cLibraryName
    Specifies the name of the class library initially selected when the Open dialog is displayed. cLibraryName can be a visual (.vcx) or program (.prg) -based class library.

    The class library name you specify is displayed in the File name text box. An error is generated if the class library you specify doesn't exist or cLibraryName is the empty string or the null value.

  • cClassName
    Specifies the name of the class initially selected in the Class name list when the Open dialog is displayed. If the class you specify doesn't exist, the first class in the Class name list is selected. An error is generated if you omit cLibraryName or cClassName is the null value.

  • cTitleText
    Specifies the text displayed in the title bar of the Open dialog. By default, "Open" is the text displayed.

  • cFileNameCaption
    Specifies the text displayed next to the File name text box. By default, "File name:" is the text displayed.

  • cButtonCaption
    Specifies the caption for the OK button.

Return Values

Logical data type. AGETCLASS( ) returns True (.T.), if you chose a class, and creates a one-dimensional array containing two elements. The first element contains the file name of the class library chosen; the second element contains the name of the class chosen. AGETCLASS returns False (.F.) if you exit the Class Library dialog box by pressing ESC, choosing Cancel, or clicking the Close button.

Remarks

If the array you specify does not exist, Visual FoxPro automatically creates the array.

If the array exists and is not large enough to contain the names of the class library and class, Visual FoxPro automatically increases the size of the array.

If the array is larger than necessary, Visual FoxPro truncates the array. If the array exists, and AGETCLASS( ) returns False (.F.) because the Class Library dialog box was closed by pressing ESC, choosing Cancel, or clicking the Close button, the array remains unchanged.

If the array does not exist, and AGETCLASS( ) returns false (.F.), the array is not created.

Visual FoxPro does not support AGETCLASS( ) in its run-time libraries.

Example

The following example creates an array named aClassLib. The directory is changed to the \Samples subdirectory that contains the sample class libraries. AGETCLASS( ) is used to display a dialog with the Buttons class library and the VCR class selected. If you choose the Modify button, the name of the class library and class you select is stored in the array. The class is then opened in the Class designer.

LOCAL aClassLib(2)  && Create an array, initialized to .F.
cCurrentDir = CURDIR( )  && Save the current directory.
CD HOME(2) + 'CLASSES'  && Switch directories.

AGETCLASS(aClassLib, 'BUTTONS.VCX', 'VCR', 'Modify Class', ;
   'Class File:', 'Modify')  && Display the dialog.
CD (cCurrentDir)  && Switch to the previous directory.

IF TYPE('aClassLib(2)') = 'C'  && Class chosen?
   MODIFY CLASS (aClassLib(2)) OF (aClassLib(1))  && Open to modify.
ENDIF

See Also

ACLASS( ) Function | AMEMBERS( ) Function | AVCXCLASSES( ) Function | CREATE CLASS Command