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
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/
|
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
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.
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()
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)