DEFINE NEW GLOBAL SHAREDPRIVATE PROTECTED PUBLIC STATICVARIABLE variable-nameAS primitive-type-nameAS CLASS object-type-nameLIKE field EXTENT constantBGCOLOR expressionCOLUMN-LABEL labelCONTEXT-HELP-ID expressionDCOLOR expressionDECIMALS nDROP-TARGETFONT expressionFGCOLOR expressionFORMAT stringINITIALconstant [ constant , constant ]LABEL string , stringMOUSE-POINTER expressionNO-UNDONOT CASE-SENSITIVEPFCOLOR expressionview-as-phrasetrigger-phraseNEW SHARED VARIABLE variable-nameNEW GLOBAL SHARED VARIABLE variable-nameSHARED VARIABLE variable-namevariable-namePRIVATE PROTECTED PUBLIC STATIC VARIABLE
Note: The specified options are applicable only when defining a data member for a class in a class definition (.cls) file. Note also that you cannot shadow (override) the definition of a given variable data member in a class hierarchy.For more information on the mechanism for accessing variable data members of different access modes and scopes, see the reference entry for Class-based data member access.If variable-name is an ABL reserved keyword, you must include an access mode of PUBLIC, PROTECTED, or PRIVATE in its definition. You must also use the THIS-OBJECT system reference or Type-name syntax to access the variable data member. For more information on referencing variable data members, see the reference entry for Class-based data member access.
Note: If the data member is defined in a class that is derived from a .NET class, other restrictions on variable-name apply. For more information, see the CLASS statement reference entry.For more information on where and how to define data members in a class, see the CLASS statement reference entry.VARIABLE variable-nameAS primitive-type-nameSpecifies a built-in primitive type for the variable you are defining. The built-in data type (primitive-type-name) can be one of the following:
CHARACTER COM-HANDLE DATE DATETIME DATETIME-TZ DECIMALHANDLE INT64 INTEGER LOGICAL LONGCHAR MEMPTR RAW RECIDROWID
For more information on these primitive types, see the Data types reference entry.AS CLASS object-type-nameDefines the variable as an object reference with the data type of a class or interface. The default value of the variable is the Unknown value (?). You cannot assign an initial value using the INITIAL option.Specifies the type name of an ABL or .NET class or interface. Specify an object type name using the syntax described in the Type-name syntax reference entry. With an appropriate USING statement, you can also specify a class or interface name alone, without the qualifying package or namespace.LIKE fieldIf field has help and validate options defined, the variable you are defining does not inherit those characteristics.EXTENT constantDefines the variable as an array of data elements, where the element data type is specified by the AS primitive-type-name option, the LIKE field option, or the AS object-type-name option. This option can specify an array variable as either determinate (has a defined number of elements) or indeterminate (has an undefined number of elements). To define a determinate array variable, specify the EXTENT option with the constant argument. This optional argument is an integer value that represents the number of data elements in the array variable. To define an indeterminate array variable, specify the EXTENT option without the constant argument.The EXTENT is part of the variable data type. For more information, see the Type-name syntax reference entry.If you are using the AS option and you do not use the EXTENT option (or you specify constant as 0), the variable is not an array variable. If you are using the LIKE field option and you do not use the EXTENT option, the variable uses the extent defined for the database field you name (if any).BGCOLOR expressionNOT CASE-SENSITIVECOLUMN-LABEL labelCONTEXT-HELP-ID expressionDCOLOR expressionDECIMALS nSpecifies the number of decimal places to store for a DECIMAL variable, where n is an integer constant. When you define a variable AS DECIMAL, ABL automatically stores up to 10 decimal places for the value of that variable. Use the DECIMALS option to store a smaller number of decimal places. The DECIMALS option has nothing to do with the display format of the variable, just the storage format.
DEFINE VARIABLE fill-in-1 AS CHARACTER DROP-TARGET.FGCOLOR expressionFONT expressionFORMAT stringThe data format of the variable you define. If you use the AS primitive-type-name option and you do not use FORMAT string, the variable uses the default format for its data type. Table 35 lists the default data formats for the data types.
Table 35: CLASS2
You cannot display a BLOB, CLOB, MEMPTR, RAW, or ROWID value directly. However, you can convert a MEMPTR, RAW, or ROWID value to a character string representation using the STRING function and display the result. You can also convert a BLOB to a MEMPTR, and then use the STRING function. A MEMPTR or RAW value converts to decimal integer string. A ROWID value converts to a hexadecimal string, "0xhexdigits", where hexdigits is any number of characters "0" through "9" and "A" through "F". You can display a CLOB field by converting it to a LONGCHAR, and displaying the LONGCHAR using the VIEW-AS EDITOR LARGE phrase only.
If you display a class instance using the MESSAGE statement, ABL automatically invokes the ToString( ) method (provided by the Progress.Lang.Object class) on the object reference. To display a class instance in a frame (for example, using the DISPLAY statement), you must first explicitly convert the object reference to a displayable type using the INT64 function, the INTEGER function, the STRING function, or the ToString( ) method.
See OpenEdge Getting Started: ABL Essentials for more information on data formatting.If you use the LIKE field option and you do not use the FORMAT string option, the variable uses the format defined for the database field you name. You must enclose the string in quotes.The initial value of the variable you want to define. If you use the AS primitive-type-name option and you do not use the INITIAL constant option, the default is the initial value for the data type of the variable or array element.
DEFINE VARIABLE array-var AS CHARACTER NO-UNDO EXTENT 3INITIAL ["Add","Delete","Update"].
DEFINE VARIABLE x AS INTEGER NO-UNDO EXTENT INITIAL [1,2,3].DEFINE VARIABLE x1 AS INTEGER NO-UNDO EXTENT 3 INITIAL [1,2,3].You can also use the EXTENT statement to fix the number of elements in an unfixed indeterminate array variable. For more information, see the EXTENT statement reference entry.Table 36 lists the default initial values for the various variable data types.
Table 36: Unknown value (?) (displays as blanks)
If you display a class instance using the MESSAGE statement, ABL automatically invokes the ToString( ) method (provided by the Progress.Lang.Object class) on the object reference. To display a class instance in a frame (for example, using the DISPLAY statement), you must first explicitly convert the object reference to a displayable type using the INT64 function, the INTEGER function, the STRING function, or the ToString( ) method.
If you are using the LIKE field option and you do not use the INITIAL constant option, the variable uses the initial value of the field or variable. In the DEFINE SHARED VARIABLE statement, the INITIAL option has no effect. However, the DEFINE NEW SHARED VARIABLE, the DEFINE NEW SHARED TEMP-TABLE, and the DEFINE NEW WORK-TABLE statements work with the INITIAL option.The label you want to use when the variable is displayed. If you use the AS primitive-type-name option and you do not use the LABEL string option, the default label is the variable name. If you use the LIKE field option and you do not use the LABEL string option, the variable uses the label of the field or variable you name. You must enclose the string in quotes.In MS-Windows, you can designate a character within each label as a navigation mnemonic. Precede the character with an ampersand (&). When the variable is displayed with side labels, the mnemonic is underlined. The user can move focus to the variable by pressing ALT and the underlined letter. Navigation mnemonics operate only when you use side labels. If you specify more than one widget with the same mnemonic, the AVM transfers focus to each of these in tab order when you make a selection.MOUSE-POINTER expressionPFCOLOR expressionSpecifies the default data representation widget for this variable. Following is the syntax for the view-as-phrase:
VIEW-AScombo-box-phraseeditor-phraseFILL-INNATIVEsize-phraseTOOLTIP tooltipradio-set-phraseselection-list-phraseslider-phraseTEXTsize-phraseTOOLTIP tooltipTOGGLE-BOXsize-phraseTOOLTIP tooltipDefines triggers for the data representation widget specified in the view-as-phrase. Following is the syntax for the trigger-phrase:
TRIGGERS:ON event-list ANYWHEREtrigger-blockPERSISTENT RUN proc-nameIN handle( input-parameters )END TRIGGERSFor more information on triggers, see the Trigger phrase reference entry.The r-dfvar.p procedure defines two variables, del and nrecs to be shared with procedure r-dfvar2.p. The del variable passes information to r-dfvar2.p, while nrecs passes information back to r-dfvar.p from r-dfvar2.p.The following example is a startup procedure. It defines a new global variable with the initial value TRUE and uses that variable to determine whether to run an initialization procedure, r-init.p, that displays sign-on messages. Then the global variable first-time is set to FALSE. If you restart this procedure during the same session (pressed STOP), r-init.p does not run again.For examples of instance and static variable data member definitions, see the descriptions of r-CustObj.cls, r-CustObjStatic.cls, and r-CustObjAbstract.cls in the CLASS statement reference entry.
You can neither define a SHARED or NEW SHARED variable, nor access such a variable defined in a procedure file, from within a class definition (.cls) file. If you do, ABL generates a compilation error. However, multiple procedure (.p) files can define and access an object reference variable for a class instance as a NEW SHARED or NEW GLOBAL SHARED variable. In this case, the object reference variables must be defined for the same class (not a subclass or a super class) in all procedures that use them.
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |