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 | Call method_name ]
    statements
End [ New | class_name ] ]

Parts

@Shared
Optional – There can be only one instance.
New
Optional keyword.
class_name
Mandatory name of a class.
type_list
Optional – See Type List for more information.
object_name
Mandatory name for the object.
argument_list
Optional – One or more expressions with a comma between each.
Begin
Optional start of the block construct.
default_type
Optional data type that the compiler will use for the subsequent statements, if the data type is not specified. The data type must be related to the type specified in a constructor of class_name.
method_name
Optional name of the method to call for each statement. It must come after the keyword Call.
statements
Mandatory in the block construct, one or more object-creation statements. See the section “Permitted members” for more information.
End
Completes the block construct. You can also use one of End New or End class_name.

Instructions

Permitted members

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

One-line constructs

' Find all text files in the current directory.
Files txtFiles, "*.txt"

' Make a menu.
Menu FileMenu, "&File", "&Open...", DoOpen, |, "E&xit", DoExit

Block constructs

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

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

See also