ALIAS: Difference between revisions
Jump to navigation
Jump to search
(Removed redirect to DECLARE LIBRARY) Tag: Removed redirect |
No edit summary |
||
Line 21: | Line 21: | ||
{{PageExamples}} | {{PageExamples}} | ||
;Example:Instead of creating a SUB with the Library statement inside of it, just rename it. | ;Example:Instead of creating a wrapper [[SUB]] with the Library statement inside of it, just rename it. | ||
{{CodeStart}} | {{CodeStart}} | ||
{{Cl|DECLARE LIBRARY}} | {{Cl|DECLARE LIBRARY}} |
Revision as of 08:59, 25 July 2023
The ALIAS clause in a DECLARE LIBRARY statement block tells the program the name of the procedure used in the external library.
Syntax
- DECLARE LIBRARY
- SUB pseudoname ALIAS actualname [(parameters)]
- END DECLARE
Parameters
- The pseudoname is the name of the SUB or FUNCTION the QB64 program will use.
- The actualname is the same procedure name as it is inside of the library code, it may optionally have a prepended namespace specification (e.g. ALIAS std::malloc).
- QB64 must use all parameters of imported procedures including optional ones.
Description
- The ALIAS name clause is optional as the original library procedure name can be used.
- The procedure name does not have to be inside of quotes when using DECLARE LIBRARY.
- QB64 does not support optional parameters.
Examples
- Example
- Instead of creating a wrapper SUB with the Library statement inside of it, just rename it.
DECLARE LIBRARY SUB MouseMove ALIAS glutWarpPointer (BYVAL xoffset&, BYVAL yoffset&) END DECLARE DO UNTIL _SCREENEXISTS: LOOP PRINT "Hit a key to move the pointer to top left corner..." SLEEP MouseMove 1, 1 |
Explanation: When a Library procedure is used to represent another procedure name use ALIAS instead. Saves you from creating a wrapper SUB. Just place your name for the procedure first with the actual Library name after ALIAS. {{PreEnd} |