Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5b

Application v 5.24b

  

 

Chapter TwentyPageView Integration (continued)

20.2 Page View Hooks

20.2.1 Overview

Page View can be hooked in conventional methods by intercepting menu functions (MenuSetHook function), adding tools and extensions (MenuAddFunction function), or via certain specific Page View related operations. this section covers that last item.

20.2.2 File New Template

Depending on the host application, the HTML New File with Template (FILE_NEW_HTML_TEMPLATE function) or from the File New Dialog, will load a template list either from the base application or a user specified location.

These functions rely on the ‘html.csv’ data list for template information. The file can be modified, or a more safe option, is to place a copy in a folder called ‘User’ under ‘Templates’. The data file has five columns:

Name — The name of the template to be loaded into the selection dropdown box.

Title — A descriptive title displayed as the item is selected.

Description — A description of the template.

Filename — The filename to load the template from. For data, this is normally an XDS file that actually will load the Forms View. For scripts, it is a script file. If the file is not located at the resolved path, the application will look into the following order:

Absolute Path — If specified, that location.

program files\application\Template\User — If the file is present or the path resolves to a valid location.

%appdata%\vendor\Extensions — The local application and vendor folder.

application\Scripts\Extensions — User extensions to the application scripts.

application\Scripts — Application scripts to the application.

Options — Options field. For a script, the word ‘script’ must appear in the options. ‘data’ is used for data templates, so avoid the word data.

When the script is called, the functions “create_content” is called with two parameters. The prototype:

string create_content ( string name, string options );

Where:

name

A string as the selected name as specified above. This can be used to allow the script to process more than one template entry.

options

A string as the selected options as specified above. This can be used to allow the script to pass information from the template entry. It will have the string ‘script’ as part of the string since that causes the hook to be run.

Upon entry, an untitled window is open. Since the script is answering a FM_FILE_NEW or equivalent operation, the GetMenuFunctionResponse function can be used to retrieve window handle information for the newly opened edit window.

The script can present dialogs and perform what ever queries as necessary. Upon completion, the script should return a string containing HTML code or an error code string. For HTML, it should be well formed with an HTML header and footer. The type of line ending employed within the code are not significant and can be mixed as they will be resolved as the data is added to the editor. 

Script runtime errors will result in a general message box and the newly opened window will be closed.

If the return string value is “ERROR_CANCEL”, the operation is cancelled and the edit window closed.

If the return string value is “ERROR_NONE”, the application assumes the script loaded the window content and no further processing is performed.

Field script hooks can be added to the code which will be run after the the hook completed. However, note that script references, and images, must have a synthetic base path or be absolute references. To avoid this, save the edit window to a file within the script.