|
Navigation: thinBasic language > Script structure > External function declarations > DECLARE |
![]() ![]()
|
Description
Instruct thinBasic about a Windows API function/sub or 3rd party external DLL functions.
Syntax
DECLARE {SUB | FUNCTION} ProcName LIB "LibName" ALIAS "AliasName" [([Arguments])] [AS ReturnType]
Returns
None
Parameters
Name |
Type |
Optional |
Meaning |
ProcName |
String |
No |
Is the name of the function that will be used inside you script. This name must be a unique name not yet used as variable, as equate and not be a keyword or a reserved word. |
LibName |
String |
No |
Is a string expressions representing the library where to search for the API function/sub |
AliasName |
String |
No |
Is the exact name of the function to search for inside the library. |
Arguments |
Yes |
List of arguments to pass to function/sub. Arguments must contain the name and the type of the parameter the function/sub expects. Each argument can be preceded by an optional BYVAL or BYREF. |
|
ReturnType |
Yes |
In case of function, the returning function type. See also Remarks below |
Remarks
thinBasic will automatically search for "LibName.dll" in the following paths following the indicated order:
1. script_path\LibName.dll
2. script_path\Lib\LibName.dll
3. script_path\Bin\LibName.dll
4. script_path\Mod\LibName.dll
5. script_path\Lib\LibName\LibName.dll
6. script_path\Bin\LibName\LibName.dll
7. script_path\Mod\LibName\LibName.dll[/code]
11. thinBasic_path\LibName.dll
12. thinBasic_path\Lib\LibName.dll
13. thinBasic_path\Bin\LibName.dll
14. thinBasic_path\Mod\LibName.dll
15. thinBasic_path\Lib\LibName\LibName.dll
16. thinBasic_path\Bin\LibName\LibName.dll
17. thinBasic_path\Mod\LibName\LibName.dll
38. Dir_GetSystemDirectory\LibName.dll
39. Dir_GetWindowsDirectory\LibName.dll
40. CURDIR$\LibName.dll
In case LibName will be indicated with a full absolute path no assumption or search sequence will be followed but the absolute path will be taken.
Return type can be expressed also as pointer to some data type.
For example:
... As Double PTR
... As String PTR
In this case thinBasic will return a DWORD representing a pointer to something.
It is programmer responsibility to correctly use returned data.
Restrictions
Functionality still under construction
See also
Examples
'---Declare WinBeep function from KERNEL32 dll library
DECLARE FUNCTION WinBeep LIB "KERNEL32.DLL" ALIAS "Beep" ( _
BYVAL dwFreq AS DWORD, _
BYVAL dwDuration AS DWORD _
) AS LONG
'---Declare AllocConsole function from KERNEL32 dll library without any parameter
DECLARE FUNCTION AllocConsole LIB "KERNEL32.DLL" ALIAS "AllocConsole" () AS LONG
| © 2004-2008 thinBasic. All rights reserved. | Version 1.6.0.7 | Web Site: http://www.thinbasic.com |