New Statement

Makes an instance of an object and initializes it.

Syntax

[ Shared ] [ New ] class_name [ < type_list > ] #object_name [ , argument_list ]
[ Begin [ default_type ]
    [ statements ]
End [ New | class_name ] ]

Parts

Shared
Optional – There can be only one instance.
New
Optional
class_name
Necessary name of a type class.
type_list
Optional – See “Type List” for more information.
#object_name
Necessary name for the object.
argument_list
Optional – One or more expressions with a comma between each one.
Begin
Optional – Starts the expanded construction.
default_type
Optional data type that the compiler will use for the subsequent statements, if the data type is ambiguous. The data type must derive from the type specified in a constructor of class_name.
statements
Necessary in the expanded construction – One or more object-creation statements. See the section “Permitted members” for more information.
End
Completes the expanded construction. You can also use one of End New or End class_name.

Instructions

Permitted members

Examples

One-line constructions

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

' Create a menu.
Menu #file, "&File", "&Open...", DoOpen, |, "E&xit", DoExit

Expanded constructions

New Menu #File, "&File"
Begin
    "&Open...", DoOpen
    |----
    "E&xit", DoExit
End New

Menu #File, "&File"
Begin
    "&Open...", DoOpen
    |----
    "E&xit", DoExit
End Menu

See also