Invokes an external function declared with DECLARE, such as a Windows API or DLL export. The compiler follows the Windows x64 calling convention: the first four integer/pointer arguments go in RCX, RDX, R8, R9; remaining arguments are pushed to the stack. Float arguments go to XMM0-XMM3. BYREF arguments pass a pointer to the variable. String arguments are converted to null-terminated ASCIIZ pointers before the call.
Parameters
Parameter
Description
FunctionName
The name of the external function as declared with DECLARE.
args
Comma-separated list of arguments. Each argument is evaluated and passed according to the Win64 ABI. Use BYVAL or BYREF as specified in the declaration.
Example
DECLARE FUNCTION MessageBoxA LIB "user32.dll" _
ALIAS "MessageBoxA" ( _
BYVAL hWnd AS QUAD, _
BYVAL lpText AS ASCIIZ PTR, _
BYVAL lpCaption AS ASCIIZ PTR, _
BYVAL uType AS LONG _
) AS LONG
FUNCTION PBMAIN() AS LONG
LOCAL result AS LONG
' Call Windows API MessageBox
CALL MessageBoxA(0, "Hello from PowerBASIC!", _
"PB x64", 0)
FUNCTION = 0
END FUNCTION