User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive


Alternate syntax for VAR: instance variable for the objects.
VAR <DataName1> [, <DataNameN>] [ AS <type> ] [ INIT <uValue> ] [[EXPORTED | VISIBLE] | [PROTECTED] | [HIDDEN]] [READONLY | RO]
<DataName1> Name of the VAR
<type> Optional data type specification from the following:
Character, Numeric, Date, Logical, Codeblock, Nil.
<uValue> Optional initial value when creating a new object.
EXPORTED Specifies that this VAR is accessible to functions and
methods outside of the class. VISIBLE is a synonym for EXPORTED.
PROTECTED Specifies that this VAR is only accessible to functions and methods within this class and its subclasses.
HIDDEN Specifies that this VAR is only accessible to the
class where it was defined, and is not inherited by the subclasses.
READONLY Restricts assignment to the variable. If specified with
the EXPORTED clause, assignment is only permitted from the current class and its subclasses. If specified with the PROTECTED clause, assignment is only permitted from the current class. RO is a synonym for READONLY.
VAR elements can also be thought of as the "properties" of an object. They can be of any data type, including codeblock. Once an object has been created, the VAR elements are referenced with the colon (:) as in MyObject:Heading := "Last name". Usually a class also defines methods to manipulate the VAR.
You can use the "AS <type>" clause to enforce that the VAR is maintained as a certain type. Otherwise it will take on the type of whatever value is first assigned to it.
Use the "INIT <uValue>" clause to initialize that VAR to <uValue> whenever a new object is created.
VAR can be a synonym for VAR, or it can use a slightly different syntax for compatibility with other dialects.
   VAR Block      // Code block to retrieve data for the column
   VAR Cargo      // User-definable variable
   VAR ColorBlock // Code block that determines color of data items
   VAR ColSep     // Column separator character
   VAR DefColor   // Array of numeric indexes into the color table
   VAR Footing    // Column footing
   VAR FootSep    // Footing separator character
   VAR Heading    // Column heading
   VAR HeadSep    // Heading separator character
   VAR Width      // Column display width
   VAR ColPos     // Temporary column position on screen
   METHOD New()   // Constructor
This is Harbour specific
This is available on all platforms
See also

Object Oriented Programming, CLASS, METHOD, CLASS VAR, VAR