Dynamic functions enable you to dynamically call an agent, a plug-in, or a generic APL function by name.
dynamicCall
The dynamicCall function calls a user defined APL function.
Code Block
any dynamicCall ( any handler ,
string functionName ,
list<any> arguments )
Parameter
Description
handler
The handler that is returned by dynamicImport, dynamicPlugin or dynamicCompile. If the handler is set to null, the functions that are defined in the agent are used.
functionName
The name of the function to call
arguments
A list of arguments to pass to the called function. To call a function that requires no argument, use either null or an empty list.
Returns
Either the result of the executed function,or null, if the function returns void
Info
title
Example - Using dynamicCall to call an agent defined function
Code Block
consume {
//
// Dynamic Call to call an agent defined function
//
list<any> args = listCreate(any);
dynamicCall(null, "testA", args);
listAdd(args, "HelloWorld");
dynamicCall(null, "testB", args);
listAdd(args, 21);
int result = (int) dynamicCall(null, "testC", args);
debug(result);
}
void testA() {
debug("testA called");
}
void testB(string b) {
debug("testB("+b+") called");
}
int testC(string b, int c) {
debug("testC("+b+", "+c+") called");
return c*2;
}
Info
title
Example - Using dynamicCall to call a plugin function
Code Block
any plugin;
initialize {
//
// Initialize DTK plugin - Using ClassName
//
plugin = dynamicPlugin(
"com.<product>.apl.MyPluginExecutor");
}
consume {
//
// Dynamic Call to call a plugin function
//
list<any> arguments;
listAdd(arguments, 1024);
dynamicCall(plugin,
"myPluginExposedFunction",
arguments);
}
Info
title
Example - Using dynamicCall to call an APL Code defined function
Code Block
any aplCode;
initialize {
//
// Dynamic Import of generic APL Code
//
aplCode = dynamicImport("Default.helloworld");
}
consume {
//
// Dynamic Call to call an APL Code defined function
//
list<any> arguments;
listAdd(arguments, "HelloWorld");
dynamicCall(aplCode,
"myHelloFunc",
arguments);
}
Info
title
Example - Using dynamicCall to call a dynamically compiled function
Code Block
any compiled;
initialize {
compiled = dynamicCompile("""
void testA() {
debug("testA called");
}
""");
}
consume {
//
// Call to a dynamically compiled function
//
dynamicCall(compiled, "testA", null);
}
dynamicCompile
The dynamicCompile function dynamically compiles APL Code and returns a handler that is used together with dynamicCall.
Code Block
any dynamicCompile ( string aplCode )
Parameter
Description
aplCode
The APL Code to be compiled
Returns
Handler to use together with dynamicCall
Info
title
Example - Using dynamicCompile
Code Block
any aplCode = dynamicCompile("string helloWorld() { return \"Hello World!\"; }
debug("Compiled function returned "+dynamicCall(aplCode, "helloWorld"));
dynamicImport
The dynamicImport function imports generic APL Code.
The command returns a handler that is used together with dynamicCall.
Note
title
Note!
Use this function only during initialization of workflow.
Code Block
any dynamicImport ( string confName )
Parameter
Description
confName
The configuration name of APL Code to import.
Returns
Handler to use together with dynamicCall.
Info
title
Example - Using dynamicImport
Code Block
any aplCode;
initialize {
//
// Dynamic Import of generic APL Code
//
aplCode = dynamicImport("Default.helloworld");
}