cfunc.load
Pre-load a FlashBASIC subroutine.
Syntax
int _CP_load(int* number, CPSTR* name)
Description
is an optional function for pre-loading FlashBASIC subroutines, before they are needed.
The number parameter must be a pointer to an integer. This integer MUST contain -1 when loading a new subroutine. Upon successful load, this location will contain an index number which should be passed down to succeeding _CP_call's to the same subroutine. This index allows the system to jump directly into the subroutine code without having to look up the name in the master dictionary.
The name parameter should be a CPSTR* pointing to the subroutine name.
The subroutine to be called MUST be previously compiled with FlashBASIC and be cataloged in the current master dictionary.
This function returns -1 if an error occurs. The error code is contained in _CP_errno. Specific error codes include:
PE_LOAD_ERR indicates that the system could not load the subroutine. The subroutine must be cataloged, and must be compiled with the current version of FlashBASIC.
Example
/* call a user-written routine */
CPSTR * s = _CP_mkstr('hi');
int i = -1;
r = _CP_load(&i,s);
if (r < 0)
{
_CP_logoff();
exit(-1);
}
/* Now that the subroutine is loaded, it can be called */
/* very efficiently */
for (j=1; j < 100; j++) _CP_call(&i,s,0);
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
