You can use the advanced configuration interface of the ExecuteDocumentLua processor to write and debug Lua scripts.
If you plan to write a large amount of code you can divide it into modules. This is especially useful if you write functions that can be re-used in different places. To add a new module from within the advanced configuration interface, click in the Scripts area. This adds a new dynamic property with your code as the value. To delete a module, find the module in the Scripts area and click
.
After making changes to the script in the Lua code area, click SAVE to save your changes. If your Lua script was loaded from a file and Overwrite script files is selected, the original file is overwritten. If your Lua script was loaded from a file and Overwrite script files is not selected, the value of the relevant property (Lua script file for the main script, or a dynamic property for optional modules) is overwritten with the new code.
The interface also includes a Move To File button that you can use to move code entered as a property value into a script file on disk. Your Lua script must be stored in a file if you want to use the debugging features.
A selection of code samples is available from the LUA SAMPLES tab. You can copy these into the Lua code area and modify them as necessary.
TIP: When debugging a Lua script, Micro Focus recommends that you:
When the ExecuteDocumentLua processor is stopped, you can open the advanced configuration interface and add breakpoints to your script. To add a breakpoint, click in the margin next to the line number. A red circle indicates a breakpoint.
After adding one or more breakpoints, start the processor. Then, return to the advanced configuration interface and click the DEBUG tab. The status of each concurrent task is shown at the top of the DEBUG tab. In the example below the processor is processing four documents concurrently (which is not recommended while debugging) and in each case the script has stopped at the breakpoint.
Below the list of sessions, you can see the following information:
After examining the information in the DEBUG tab, you can perform one of the following actions. Click one of the sessions to select it, and then:
To step over lines of code, click Step . This runs one line of code at a time. In the Lua code area, a green arrow indicates where the script has stopped. For example, after stepping over two lines the Lua code area might look like this:
|