Constructor Statement

Initializes the data of a new instance of an object.

Syntax

[ @Deprecated ] _
Constructor [ parameter_list ]
    [ statements ]
End [ Constructor ]

Parts

@Deprecated
Optional modifier. See @Deprecated for more information.
parameter_list
Optional, one or more variable declarations with a comma between each. Parentheses (( )) around the parameters are optional unless you use @Option to make them mandatory.
Usually the variable is local to the constructor. But if you put Self and a dot (.) befor the name, the parameter refers to the member of the parent construct with that name. See Parameter List for more information.
statements
Optional statements.
End
Completes the statement. You can also use End Constructor.
You can change the syntax of this part. See @Option Directive for more information.

Instructions

ViviFire lets you have many constructors in an object. Each constructor must have a different parameter signature. A constructor without parameters is known as a default constructor.

All constructors must be in a group together. They come after a possible data section and before a possible destructor or other procedures.

You can think of the data section as a type of constructor. Statements you put in this section always run before a constructor gets called.

Permitted parents

Changes in syntax with @Option

There are two areas where you can change the syntax of the statement:

See @Option Directive for more information.

Examples

Class Point
    Var x, y As Real64

    Constructor Self.x, Self.y
    End Constructor
End Class

See also