DECLARE FUNCTION / DECLARE SUB

Concept Link IconSee also Concept Link IconExample

Declaration of an external function or subroutine. This instruction is used whenever a DLL call is to be made.

WebVue support - Yes.

Mode

Mnemonic

Syntax

- FUNCTION 1
- SUB 2

Functions or subroutines must always be declared in the header block of the program.

Syntax 1

DECLARE FUNCTION GlobalName LIB Libname [ALIAS AliasName] ([Arguments]) AS Type;

Argument

Meaning

GlobalName

The name by which the SUB or FUNCTION will be known. If different to the real name of the SUB or FUNCTION in the DLL then the AliasName must also be specified.

LibName

The name of the DLL where the declared function is to be found. Type STR.
If executed in a WebVue session context this instruction is processed by the computer that hosts the web back end. The DLL must be present on the computer that hosts the web back end.

AliasName

The name of the function in the DLL if different to the name that it will be known by in the program (as specified by the GlobalName parameter). Type STR.

Type

The type returned by the function (INTEGER, LONG, SINGLE, DOUBLE or STR).

Arguments

An argument list with the following syntax:

 

[BYVAL] Variable AS Type, [BYVAL] Variable AS Type, ...

Variable

The name of the variable passed as an argument.

Type

The type of the variable passed as an argument. INTEGER, LONG, SINGLE, DOUBLE.

Execution

The external program behaves as a function. It always returns a value.

Syntax 2

DECLARE SUB GlobalName LIB LibName [ALIAS AliasName] ([Arguments]);

Execution

The external program behaves as a subroutine. It does not return a value.

The declared sub-program is visible to all sub-programs of the current program. If it is declared in the GLOBAL program, it is visible to all programs.

The folder in which the DLL resides must have a path set to it, or else the full path may be included in the declaration.

Example

DECLARE SUB DosBeep lib "DOSCALLS" (X as integer);

DECLARE FUNCTION WinExec LIB "KERNEL" (BYVAL File AS STR,BYVAL SH AS INTEGER) AS INTEGER;