New Statement

Creates an object instance and initializes its state.

Syntax

Normal form
[ Shared ] [ New ] className [ < typeList > ] #object [ , argumentList ]
[ Begin [ defaultType ]
    [ statements ]
End { New | className } ]
Subclass constructor form
New [ < typeList > ] #Base [ , argumentList ]

Parts

Shared
Optional in the normal form
Not allowed in the subclass constructor form
New
Optional in the normal form
Required in the subclass constructor form
className
Required in the normal form.
Not allowed in the subclass constructor form where it is implicit.
typeList
Required only if className is a generic type. One or more data types separated by commas and enclose in angle brackets.
#object
Required in the normal form.
Must be #Base in the subclass constructor form.
argumentList
Optional. One or more expressions separated by commas.
Begin
Optional. Marks the start of the multi-line form.
defaultType
Optional. Specifies a data type that the compiler should assume when a given statement makes its determination ambiguous.
statements
Required in the multi-line form. one or more object-creation statements (i.e., New or Object) or simply an argument list, which is treated like the arguments to a New statement. Each statement must be placed on a separate line.
End New
Terminates the multi-line form. Alternatively, you can also use End className instead.

Remarks

Examples

Listing 1
' Find all text files in current directory
Files #fs, "*.txt"

Listing 2
New Menu #File, "&File"
Begin
    "&Open...", DoFileOpen
    |----
    "E&xit", DoFileExit
End New

Listing 3
Menu #File, "&File"
Begin
    "&Open...", DoFileOpen
    |----
    "E&xit", DoFileExit
End Menu

See also