|
![]() |
![]() |
version 2003
PA_ExecuteTokens (tokens; len)
Parameter | Type | Description | |
tokens | char * | → | Tokens to execute |
len | long | → | Length of the tokens' buffer |
Description
The routine
PA_ExecuteTokens
allows the 4D Extension to execute any pre-tokenized 4th Dimension statement that does not return a result. Use the
PA_ExecuteTokensAsFunction
for pre-tokenized statements that return a result.
Pass the text of the tokens in
tokens
and its length in
len
prior to the call.
The type of uses for
PA_ExecuteTokens,
as well as re-entrance precautions, are identical to those of
PA_ExecuteMethod
. For more information on these topics, refer to the entry point
PA_ExecuteMethod
.
Remember that if you know the statement will be executed just once or twice per working session, you can immediatly execute it without using tokens. On the other hand, if it will be executed often, it is faster to tokenize it and to execute the tokens. It is also important to store tokens instead of text expressions since, in this case, the tokens can run in a 4D that uses a different localized set of commands. As an example, the expression ALERT(aString) will not work on a French version of 4D, because the French 4D language requires ALERTE(aString), but the tokens will work on both French and English versions of 4D.
Example
Executing a formula 100 times. This code is faster than calling
PA_ExecuteMethod
instead of
PA_ExecuteTokens
.
void UserFormulaHundredTimes ()
{
char formula[ 32000 ];
long len = 0;
long i;
char* tokens = 0;
if ( PA_FormulaEditor( 0, formula, &len ) )
{
len = PA_Tokenize( formula, len, 0 );
if ( len > 0 )
tokens = malloc( len );
if ( tokens )
{
PA_Tokenize( formula, len, tokens );
for ( i = 1; i <= 100; i++ )
{
PA_ExecuteTokens( tokens, len );
if ( PA_GetLastError() )
break;
}
free( tokens );
}
}
}
See Also
PA_ByteSwapTokens , PA_Detokenize , PA_ExecuteTokensAsFunction , PA_Tokenize .
Error Handling
Use
PA_GetLastError
to see if an error occurred