LOAD Statement |
LOAD file AS module
Loads a MyBASIC2 program that can be used as a library. The program can have a number of functions and/or subroutines that can be called by using the "module@funcname" syntax. LOAD can also be used to load an extension library instead of using $LIBRARY. This allows the library to be loaded/unloaded on demand. Please note that when using LOAD for extension libraries you will need to do a forward declaration of the functions being called since normally extension function calls are resolved during parse time.
Note; Current version doesn't support a module array item as module variable.
Uses "MyBASIC2_Run" environment variable to search for file if no folder is specified.
Examples:
DIM m AS MODULE DIM ext AS MODULE DIM user AS MODULE
LOAD "D:\Tech\Projects\COMMON\MyBASIC2\Test Files\sub.bas" AS m LOAD "MyBASIC2_ExtLib.dll" AS ext LOAD "user32.dll" AS user
UNLOAD m UNLOAD ext UNLOAD user
' This code snippet checks if file is a C3D file using a function ' in C3D Extension library. The library is dynamically loaded using ' LOAD Library AS instead of $LIBRARY parse command
DECLARE FUNCTION IsFileC3D ALIAS "C3D.IS_C3D"
DIM test AS INTEGER
DIM c3d AS MODULE LOAD "MyBASIC2_C3DLib.dll" AS c3d
test = IsFileC3D( "e:\maxpro\demo files\hand.c3d" )
UNLOAD c3d
IF test = C3D_SUCCESS THEN PRINT "File ";UPPER( "e:\maxpro\demo files\hand.c3d" );" exists :-)", ELSE PRINT "File ";UPPER( "e:\maxpro\demo files\hand.c3d" );" doesn't exist :-(", ENDIF
END
|