CLASS VAR

CLASS VAR

Define a CLASS VAR variable for a class (NOT for an Object!)

Syntax

      CLASS VAR <DataName1> [, <DataNameN>] [ AS <type> ] [ INIT <uValue> ]

Arguments

<DataName1> Name of the VAR

<type> Optional data type specification from the following:

Character, Numeric, Date, Logical, Codeblock, Nil

<uValue> Optional initial value at program startup

Description

CLASS VAR variables can also be thought of as the “properties” of an entire class. Each CLASS VAR exists only once, no matter how many objects are created. A common usage is for a counter that is incremented whenever an object is created and decremented when one is destroyed, thus monitoring the number of objects in existence for this class.

You can use the “AS <type>” clause to enforce that the CLASS 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 the class is first used.

Examples

      CREATE CLASS TWindow
         VAR   hWnd,  nOldProc
         CLASS VAR lRegistered AS LOGICAL
      ENDCLASS

Compliance

Harbour

Platforms

All

Seealso

Object Oriented Programming, CLASS, METHOD, VAR

Advertisements

3 responses to “CLASS VAR

  1. Pingback: Harbour Statements | Viva Clipper !

  2. Pingback: Harbour Commands | Viva Clipper !

  3. Pingback: Harbour RG Summary | 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