Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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  )


ParameterDescription

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
titleExample - 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
titleExample - 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
titleExample - 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
titleExample - 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 )


ParameterDescription
aplCode The APL Code to be compiled
ReturnsHandler to use together with dynamicCall


Info
titleExample - 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
titleNote!

Use this function only during initialization of workflow.


Code Block
any dynamicImport ( string  confName  )


ParameterDescription

confName

The configuration name of APL Code to import.

Returns

Handler to use together with dynamicCall.


Info
titleExample - Using dynamicImport


Code Block
any aplCode;
initialize {
    //
    // Dynamic Import of generic APL Code
    //
    aplCode = dynamicImport("Default.helloworld");
}


dynamicPlugin

The dynamicPlugin function initializes a DTK APL plug-in. For further information, see 10. APL Plugins in the Development Toolkit User's Guide .

The command returns a handler that you use together with dynamicCall.

Note
titleNote!

Use this function only during initialization of workflow.


Code Block
any dynamicPlugin ( string classOrFunctionName )


ParameterDescription
classOrFunctionName

The name of plug-inclass implementing DRAPLExecutor, or a function name that is defined by the plug-in

ReturnsA handler that you use together with dynamicCall


Info
titleExample - Using dynamicPlugin


Code Block
any plugin1;
any plugin2;
initialize {
    //
    // Initialize DTK plugin - Using ClassName
    //
    plugin1 = dynamicPlugin(
                     "com.<product>.apl.MyPluginExecutor");
    //
    // Initialize DTK plugin - Using exposed function name
    //
    plugin2 = dynamicPlugin("myPluginExposedFunction");
}



Scroll ignore
scroll-viewportfalse
scroll-pdftrue
scroll-officefalse
scroll-chmtrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue
scroll-htmlfalse


Next:



Scroll pagebreak