Declare Statement

Makes a wrapper for a procedure.

Syntax

One-line construct

Declare [ library_name [ flags ] ] { Function | Sub } name _
  [ Is canonical_name ] [ parameter_list ]

Block construct

Declare library_name [ flags ]
  { Function | Sub } name [ Is canonical_name ] [ parameter_list ]
  …
End [ Declare ]

Parts

library_name
Optional string literal with the name of a compiled library, for example, a dynamic link library (DLL).
flags
Optional one or more non-reserved keywords. A comma between each is optional.
  • ANSI – Strings are 8-bit ANSI. Cannot use with UTF16.
  • CDECL – Uses the C calling convention.
  • UTF16 – Strings are 16-bit Unicode. Cannot use with ANSI.
name
Mandatory name for the wrapper procedure.
canonical_name
If library_name is given, an optional string literal, when the exported name is different.
If library_name is not given, name becomes an alternative name for the procedure canonical_named.
parameter_list
Optional. See Parameter List for more information.
If library_name is not given, a different construct is used.

Parameter list

( mandatory_params [ Optional optional_param [ = default ] [ , optional_params ] ] )
mandatory_params
One or more integer literals, with a comma between each. Use 1 for the first parameter, 2 for the second, thru all mandatory parameters. You can write the parameters out of sequence.
optional_param
Mandatory after Optional – an integer literal.
default
Optional expression.
optional_params
Optional one or more subsequent parameters, with a comma between each. Each can have a default value.
End
Completes the block construct. You can also use End Declare.
You can change the syntax of this part. See @Option Directive for more information.

Instructions

TODO

Examples

Alternative names

Declare Function MyAlias1 Is SomeNamespace.SomeFunction
Declare Function MyAlias2 Is SomeOtherFunction(1, 2, Optional 3=False, 4=0.0)
Declare Function TwoArgs Is FourArgs(3, 2, Optional 1=0, 4=0)

Foreign function libraries

Declare "user32.dll" Function BringWindowToTop (
    h As Int32) As Int32
Declare "user32.dll" UTF16 Function SetWindowText Is "SetWindowTextW" (
    h As Int32, s As String ) As Int32

Declare "user32.dll" UTF16
    Function BringWindowToTop (
        h As Int32) As Int32
    Function SetWindowText Is "SetWindowTextW" (
        h As Int32, s As String) As Int32
End Declare

See also