cfunc.call C Function/C Functions

cfunc.call

Command cfunc.call C Function/C Functions
Applicable release versions: AP 6.1
Category C Functions (120)
Description is equivalent to the FlashBASIC statement: call name( {string1 {, string2 {, ...}}})

The number parameter must be a pointer to an integer. On the first call to particular subroutine, this integer MUST contain -1. Upon successful return, this location will contain an index number which should be passed down to all 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.

The expression must be the number of parameters to pass.

Each parameter passed to FlashBASIC must be a CPSTR**. Upon return from the subroutine, FlashBASIC will reconvert its variables back to strings, if necessary, and stuff the results back into the passed CPSTR**'s.

This function returns -1 if an error occurs. The error code is contained in _CP_errno. Specific error codes include:

PE_BAD_PARAMS indicates that too many parameters were passed as expression. The user may only pass _CP_MAX_PARAM parameters.

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.
Syntax int _CP_call(int* number, CPSTR* name, int expression, { CPSTR** string1 {, CPSTR** string2 {, ... }}})
Options
Example
/* call a user-written routine */

CPSTR * s = _CP_mkstr("hi");
int i = -1;

r = _CP_call(&i,s,0);
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);
Purpose
Related cfunc.introduction