Connector Framework Server 24.3

# Debug Your Lua Scripts

The CFS installation includes files that you can use to debug your Lua scripts with an IDE such as the ZeroBrane Studio Lua IDE. You can use the IDOL and CFS Lua functions through the IDE, with code-completion.

To debug Lua scripts in the ZeroBrane Studio IDE

1. Install ZeroBrane Studio Lua IDE.

2. Copy the files from the `lua_ide_files/ZeroBraneStudio` directory in your CFS installation to the ZeroBrane Studio installation directory, merging them with the files that are already there:

   Source (CFS Installation) | Destination
   --- | ---
   `lua_ide_files/ZeroBraneStudio/api/lua/*` | `ZeroBraneInstall/api/lua/`
   `lua_ide_files/ZeroBraneStudio/bin/*` | `ZeroBraneInstall/bin/`
   `lua_ide_files/ZeroBraneStudio/interpreters/*` | `ZeroBraneInstall/interpreters/`

3. Open the ZeroBrane Studio IDE.
4. On the Project menu, click Lua Interpreter > Lua 5.3 64bit.

5. On the Project menu, click Project Directory > Choose, and then select a directory to use as the project directory.

   TIP: Any relative paths in your Lua scripts are relative to the project directory that you choose.

   NOTE: The project directory must include:

   - `autn_lua.dll`
   - `autn_lua_cfs.dll`
   - A CFS configuration file. Some of the Lua functions that you can use in your scripts write to log files or use KeyView and the configuration file specifies the paths of these files.

   The libraries are available in the `lua` directory of your CFS installation. You can use that folder as your project directory.

   An example CFS configuration that is suitable for debugging Lua scripts appears below.

       [License]
       LicenseServerHost=10.0.0.1
       LicenseServerACIPort=20000

       [Logging]
       LogLevel=NORMAL
       0=ApplicationLogStream
       1=ImportLogStream

       [ApplicationLogStream]
       LogTypeCSVs=application
       LogFile=application.log

       [ImportLogStream]
       LogTypeCSVs=import
       LogFile=import.log

       [ImportService]
       KeyviewDirectory=../filters
       ExtractDirectory=temp
       ThreadCount=3
       ImportInheritFieldsCSV=AUTN_GROUP,AUTN_IDENTIFIER,DREDBNAME,AUTONOMYMETADATA,SECURITYTYPE

   CAUTION: If you use your CFS configuration file, the Lua scripts that you are debugging can write to the CFS log files, or even index documents into your IDOL Content component.

6. Create a new Lua script file in the project directory. Start your script with the following lines, to provide the path of the configuration file and include the IDOL and CFS Lua functions:

       -- Configuration file provides paths to log files, KeyView
       require_config = "my_config.cfg"
       require("autn_lua_cfs").as_global()
       require("autn_lua").as_global()

7. You can now begin writing your script, using all of the standard IDOL and CFS Lua functions. CFS pre- and post- tasks call a function named `handler` that is passed a document object, so you might want to construct a document and then call the function. For example:

       -- Configuration file provides paths to log files, KeyView
       require_config = "my_config.cfg"
       require("autn_lua_cfs").as_global()
       require("autn_lua").as_global()

       function handler(document)
           print(document:to_xml())
           return true
       end

       -- Parse a document from an IDX file to be used as input
       local document = parse_document_idx("input.idx", true)

       -- Call the handler, storing the return value (expected to be Boolean)
       local result = handler(document)

       -- Print the result
       print("handler returned:", result)

8. Run and debug the script as necessary using the ZeroBrane Studio IDE. For more information about using the ZeroBrane Studio IDE, refer to the ZeroBrane documentation.

Copyright 2024 Open Text
Version 24.3 | Last updated June 2024

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: IDOL Connector Framework Server 24.3

Topic Title: Debug Your Lua Scripts