Page History
Once the prototype record has been defined, and the BASIC+ callable functions have been created using Declare_FCNS, you can call the functions from BASIC+ as if they were BASIC+ stored procedures.
Use the Declare Function statement if a return value is required from the DLL function; use the Declare Subroutine statement if the function does not return a value, or if the return value will be ignored.
Example
In the following example, the Windows functions MessageBeep and MessageBoxA (the ANSI version of MessageBox()) are used to inform the user of a problem. The return value from MessageBeep is discarded; the return value from MessageBoxA is used to determine whether or not to abort.
The function prototypes for MessageBeep and MessageBox, in the DLL_USER32 prototype record in the SYSPROCS table, are as follows:
Code Block |
---|
INT STDCALL MessageBeep(UINT) INT STDCALL MessageBoxA(HANDLE,LPCHAR,LPCHAR,UINT) AS MessageBox |
In the function prototype, both MessageBeep() and MessageBoxA() return an INT. MessageBeep() is declared as a subroutine because its return value is not used. However, MessageBoxA() is declared as a function because its return value is used (to determine which button the user clicked on).
...