The custom report option allows provides a mechanism to inspect data source or document related information and output it in virtually any format. LuaSocket support is enabled for custom reports, which can be exported in a variety of ways, such as files, posted via HTTP or shown in a browser.
The pencil icon provides access to a number of simple examples. The Test button executes the code. If any TABLE objects are presented back from the script they will be shown in the area at the bottom.
Once a report has been written it can be saved under a unique name to the “Report Menu” or recalled from the menu for editing.
Inspecting Document Links
The script is passed a document object if a document is open, representing a Lua DOCUMENT object. So to access all the links in the current document, it’s a case of using the getlinks call which returns a table of links:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | -- create a new TABLE object mytable = TABLE:new(); -- retrieving all the links in the current document mylinks = document:getlinks(); r=1; c=1; -- add a header row mytable:cell(r,c):setcontent("Key"); mytable:cell(r,c):setheader(true); r=r+1; -- add a row for each link for i,mylink in ipairs(mylinks) do theKey = mylink:getkey(); mytable:cell(r,c):setcontent(theKey); r=r+1; end -- return the results mytable:present(); |
Inspecting The Panel Selection
A selection variable is passed into the script containing details of the selection. Here’s an example script the expects a single selected record and then opens a URL built from its field content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | -- check only one item is selected if selection:size() ~= 1 then error "must have one item selected" end; -- get the first record myrecord = selection:getrecordset():getrecord(1); value = myrecord:field("RNR"):content(); -- build the URL url = "http://www.65bit.com?" .. value; -- ask the OS to open the URL (Mac) os.execute("open " .. url) -- ask the OS to open the URL (Windows) os.execute('start "" "' .. url .. '"') |