Constructor Statement
Initializes the data of a new instance of an object.
Syntax
[ @Deprecated ] _
Constructor [ parameter_list ]
[ statements ]
End [ Constructor ]
Parts
@Deprecated- Optional modifier shows a warning if a person tries to use the given constructor. This lets you remove the constructor in a subsequent release. 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@Optionto make them mandatory. See Parameter List for more information. - Usually the variable is local to the constructor.
But if you put
Selfand a dot (.) befor the name, the parameter refers to the member of the parent construct with that name. The parameter cannot include type information, for example,AsorIn. But the parameter can beByRefand/orOptional, and can have a default value. 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:
@Option Args Enclosed@Option End Blockand@Option End
See @Option Directive for more information.
Examples
Class Point
Var x, y As Real64
Constructor Self.x, Self.y
End Constructor
End Class