lang • propdecl

Property Declaration

PROPERTY [ READ ] Identifier AS Datatype

Since 3.1

PROPERTY [ READ ] Identifier [ , Synonymous1 [ , Synonymous2 ... ] ] AS Datatype

This declares a class property.

If the keyword READ is specified, then the property will be read-only.

Once declared, a property must be implemented: you must write a function to read the property, and if not read-only, a function to write the property.

The name of the read function is the name of the property followed by an underscore and the word Read. This function takes no arguments and must return data whose type is the same as the property datatype.

The name of the write function is the name of the property followed by an underscore and the word Write. This function is a procedure that returns nothing. It takes only one argument which has the same type as the property datatype.

Property Synonymous

Since 3.1

It is possible to declare up to three synonymous to the declared properties by using the second syntax.

Examples

Property Enabled As Boolean
Property Read Handle As Integer
...

Private $bEnabled As Boolean
Private $iHandle As Integer

' Implements the Enabled property

Function Enabled_Read() As Boolean

  Return $bEnabled

End

Sub Enabled_Write(bEnabled As Boolean)

  $bEnabled = bEnabled
  UpdateEverything

End

' Implements the Handle property

Function Handle_Read() As Integer

  Return $iHandle

End

See also