ALIAS: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Redirected page to DECLARE LIBRARY)
Tags: New redirect visualeditor
 
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
#REDIRECT [[DECLARE LIBRARY]]
The '''ALIAS''' clause in a [[DECLARE LIBRARY]] statement block tells the program the name of the procedure used in the external library.
 
 
{{PageSyntax}}
: [[DECLARE LIBRARY]]
:: SUB {{Parameter|pseudoname}} [[ALIAS]] {{Parameter|actualname}} [(''parameters'')]
: [[DECLARE LIBRARY|END DECLARE]]
 
 
{{PageParameters}}
* The {{Parameter|pseudoname}} is the name of the [[SUB]] or [[FUNCTION]] the QB64 program will use.
* The {{Parameter|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.
 
 
{{PageDescription}}
* 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.
 
 
{{PageExamples}}
;Example:Instead of creating a wrapper [[SUB]] with the Library statement inside of it, just rename it in the declaration.
{{CodeStart}}
{{Cl|DECLARE LIBRARY}}
    {{Cl|SUB}} {{Text|MouseMove|#55FF55}} {{Cl|ALIAS}} glutWarpPointer ({{Cl|BYVAL}} xoffset&, {{Cl|BYVAL}} yoffset&)
{{Cl|END DECLARE}}
 
{{Cl|DO...LOOP|DO UNTIL}} {{Cl|_SCREENEXISTS}}: {{Cl|LOOP}}
{{Cl|PRINT}} {{Text|<nowiki>"Hit a key to move the pointer to top left corner..."</nowiki>|#FFB100}}
{{Cl|SLEEP}}
 
{{Text|MouseMove|#55FF55}} {{Text|1|#F580B1}}, {{Text|1|#F580B1}}
{{CodeEnd}}
{{PreStart}}
'''Explanation'''
When a Library procedure is used to represent another procedure name
use '''ALIAS''' instead of creating a wrapper [[SUB]]. Just place your name for
the procedure first with the actual Library name after '''ALIAS'''.
{{PreEnd}}
 
 
{{PageSeeAlso}}
* [[SUB]], [[FUNCTION]]
* [[DECLARE LIBRARY]], [[BYVAL]]
 
 
{{PageNavigation}}

Latest revision as of 22:59, 27 February 2024

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 in the declaration.
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 of creating a wrapper SUB. Just place your name for
 the procedure first with the actual Library name after ALIAS.


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link