GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Twenty-two — Conversion Functions (continued)
Overview
The TranslateAddHook function adds a translate filter to the translate module.
Syntax/Parameters
Syntax
dword = TranslateAddHook ( string name,
string
s_format | dword s_code,
string
d_format | dword d_code,
string
description, string script, string function.
[dword
flags] );
Parameters
name
A string defining the name of the conversion filter such as ‘CSVtoSpecialHTML’.
s_format or s_code
A string or dword specifying the source file type as a string or a code.
d_format or d_code
A string or dword specifying the destination file type as a string or a code.
description
A string specifying the description of the filter. This description is displayed in the import selection dialog.
script
An optional string that specifies the script that will service the translate. If empty, the script name from the script executing the function is used.
function
A string specifying the name of the entry function for translation.
flags
An optional dword specifying flags. Presently the only flag is TAH_ALLOW_DUPLICATES or TRUE which will allow the same file types.
Return Value
A dword as as the translate type code or a formatted error code. The the code is essentially a script ID and serial number.
On success, the last error will also contain information regarding the translate index table insertion:
Definition | Bitwise | Description | |||||
Translate Table | |||||||
TAH_INDEX_MASK | 0x000000FF | Translate Table Index Mask | |||||
Flags | |||||||
TAH_REPLACED_BY_NAME | 0x00010000 | Replaced Existing Name | |||||
TAH_REPLACED_BY_TYPE | 0x00020000 | Replaced Existing Type Pair | |||||
TAH_OVERRODE_TYPE_MATCH | 0x00040000 | Overrode Existing File Type Match |
Remarks
This function allows the import and translate function to be extended with custom conversion scripts. An example of adding a hook:
TranslateAddHook("IDMLtoHTML", FT_IDML, FT_HTML,
"InDesign Markup
Language (IDML) to HTML for one or more files.", "",
"idml_to_html_hook");
Note that the script name parameter is an empty, thus the hook script is the source for the specified connection. The hook is normally defined during application startup. See Section 17.2 Application Startup for more information.
Creating the Hook
The hook entry point in the script must match the following template:
int translate_hook (string xl_src, string xl_dst, string xl_dst_base,
dword xl_flags, string
xl_options);
Where
xl_src
A string containing a fully qualified source file. It can be a URI.
xl_dst
A string containing a fully qualified destination file. The file can be in the application (user’s) temporary area.
xl_dst_base
A string containing a the base path for the destination. If image or other companion files must be created, they should be placed in this folder.
xl_flags
A dword specifying various control bits.
xl_options
A string in the form of parameter: value pairs that may be passed with data from the API or other source and can be used by the script to set various options.
The xl_flags parameter tells the hook about the context and requested operations. These are bitwise items specified as follows:
Definition | Bitwise | Comment/Description | ||||
Shares with Options Settings | ||||||
XL_GLOBAL_FLAGS_MASK | 0xFFFF0000 | Global Import/Translate Options | ||||
XL_MODULE_FLAGS_MASK | 0x0000FFFF | Reserved Import/Translate Options | ||||
XL_SUB_TYPE_MASK | 0x0000000F | Sub Type of Conversion for Module | ||||
General Flags | ||||||
Control | ||||||
XL_QUIET | 0x00010000 | Do Not Display Messages | ||||
XL_PSG_FORMAT | 0x00020000 | Output in PSG Format (if possible) | ||||
XL_NO_NEW_LINES | 0x00040000 | Output With 0x0D (not 0x0D/0x0A) | ||||
XL_WANT_LOG | 0x00080000 | Output Errors to Translate Log | ||||
Context | ||||||
XL_CONVERT_AS_INSERT | 0x00100000 | Treat as Inserting | ||||
XL_MULTI_IMPORT | 0x00200000 | Importing Multiple Sheets | ||||
XL_SOURCED_FROM_CLIPBOARD | 0x00400000 | Sourced from Clipboard | ||||
Multiple Files | ||||||
XL_GROUP_IMPORT_MODE_MASK | 0x03000000 | Multiple File Mode (if supported) | ||||
XL_GROUP_IMPORT_SINGLE | 0x00000000 | Import Single File | ||||
XL_GROUP_IMPORT_MULTIPLE | 0x01000000 | Automatically Import Multiple | ||||
XL_GROUP_IMPORT_QUERY | 0x02000000 | Query if Multiple |
The default log for the script is imported back into the caller to the hook and then included into the Information View window. Note that on paste, an error must be in the log for it to appear at the end of the operation.
The XL_SOURCED_FROM_CLIPBOARD flag will indicate whether the source data was retrieved from the clipboard. If the XL_QUIET, the hook should not display message boxes or dialog boxes.
A formatted error code should be returned upon completion or error. The script should perform its own cleanup.
Related Functions
Platform Support
Go13, GoFiler Complete, GoFiler Corporate, GoFiler, GoXBRL
Page revised 2024-12-13
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.