DECLARE LIBRARY

From QB64 Wiki
Revision as of 15:35, 10 November 2010 by imported>Clippy (Created page with 'The '''DECLARE LIBRARY''' declaration allows the use of external library SUB and FUNCTION procedures. :::''Syntax:''  DECLARE LIBRARY :::::: SUB ''procedure_name'' (B…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The DECLARE LIBRARY declaration allows the use of external library SUB and FUNCTION procedures.


Syntax:  DECLARE LIBRARY
SUB procedure_name (BYVAL parameter(s))
END DECLARE


  • This QB64 procedure will be available in the NEXT version release!
  • Procedure_name is the procedure name used by the Library.
  • Parameters used by the Library procedure must be passed by value (BYVAL).
  • When using a procedure from a Dynamic Link Library (DLL file) use DECLARE DYNAMIC LIBRARY.
  • Declarations can be made inside of SUB or FUNCTION procedures.


Example: Using a QB64 SDL library procedure as a program SUB procedure to move the mouse pointer to a designated position.

SCREEN 13 DO _DELAY 1 x = RND * 300: y = RND * 180 LINE (x, y)-STEP(10, 10), RND * 100 + 32, BF MoveMouse x + 5, y + 5 LOOP UNTIL LEN(INKEY$) END SUB MoveMouse (x AS LONG, y AS LONG) DECLARE LIBRARY SUB SDL_WarpMouse (BYVAL xoffset&, BYVAL yoffset&) END DECLARE SDL_WarpMouse x, y 'call SDL library procedure END SUB

Explanation: The SDL Library is already included with QB64, so these procedures are directly available for use. Library documentation is available here in PDF format: http://www.libsdl.org/archives/sdldoc-ps.zip


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page