DATA

 

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

      CREATE 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

Compliance

Harbour

Platforms

All

Seealso

Object Oriented Programming, CLASS, METHOD, CLASSDATA, VAR

Advertisements

2 responses to “DATA

  1. Pingback: Harbour Statements | Viva Clipper !

  2. Pingback: Harbour Commands | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s