# DATA

Alternate syntax for VAR: instance variable for the objects.

Syntax

  DATA <DataName1> [,<DataNameN>] [ AS <type> ] [ INIT <uValue> ]
  [[EXPORTED | VISIBLE] | [PROTECTED] | [HIDDEN]] [READONLY | RO]

Arguments

  <DataName1> Name of the DATA
  <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 DATA is accessible to functions and methods outside of the class. VISIBLE is a synonym for EXPORTED.
  PROTECTED Specifies that this DATA is only accessible to functions and methods within this class and its subclasses.
  HIDDEN Specifies that this DATA 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.

Description

  DATA 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 DATA elements are referenced with the colon (:) as in MyObject:Heading := "Last name". Usually a class also defines methods to manipulate the DATA.
  You can use the "AS <type>" clause to enforce that the DATA 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 DATA to <uValue> whenever a new object is created.
  VAR can be a synonym for DATA, or it can use a slightly different syntax for compatibility with other dialects.

Examples

          CLASS TBColumn

             DATA Block      // Code block to retrieve data for the column
             DATA Cargo      // User-definable variable
             DATA ColorBlock // Code block that determines color of data items
             DATA ColSep     // Column separator character
             DATA DefColor   // Array of numeric indexes into the color table
             DATA Footing    // Column footing
             DATA FootSep    // Footing separator character
             DATA Heading    // Column heading
             DATA HeadSep    // Heading separator character
             DATA Width      // Column display width
             DATA ColPos     // Temporary column position on screen

             METHOD New()    // Constructor

          ENDCLASS

Status

  Ready

Compliance

  DATA is a Harbour extension.

Platforms

  All

See Also

- Object Oriented Programming
- CLASS
- METHOD
- CLASSDATA