DECLARE Statement

Previous  Next

 

DECLARE FUNCTION funcname

DECLARE SUB subname

DECLARE FUNCTION alias-name ALIAS "name"

DECLARE FUNCTION alias-name LIB "library" ALIAS "real-name"( parameters ) AS type

 


 

Forward declaration of a function or sub as well as functions and subs in external programs or libraries.  Can be used to create an alias name for external function since they're referred as "module@name".  Use the last format to declare a function in an external DLL.

 

Tech Note; When declaring an alias, the assignment is done during run-time and since the DECLARE statement must not be used inside any strcuture, the module using DECLARE must be run by using a CALL to the module before any functions or subroutines can used the alias.

 

Examples:

 

' Simple Forward Declarations

DECLARE SUB Nils

DECLARE FUNCTION LoadModule

 

' Forward Declaration with alias name

DECLARE FUNCTION Pelle ALIAS "Kalle"

 

' Alias Declaration of function Pelle in module MM

DECLARE FUNCTION Pelle ALIAS "mm@pelle"

 

' Forward Declaration of C3D Extension Library Function

DECLARE FUNCTION IsFileC3D ALIAS "C3D.Is_C3D"

 

' Declare MessageBox Windows API function

DECLARE FUNCTION MessageBox LIB "user32.dll" ALIAS "MessageBoxA"( BYVAL hWnd   AS INTEGER,_

                                                                  BYVAL lpText AS STRING,_

                                                                  BYVAL lpCapt AS STRING,_

                                                                  BYVAL uType  AS INTEGER ) AS INTEGER