FME_BEGIN_TCL

The FME_BEGIN_TCL directive specifies a Tcl script to execute just prior to the start of translation. The script is executed after the mapping file has been completely parsed, and after the log file has been opened, but before any of the readers or writers have begun to do their processing.

Note: FME will abort the translation if the execution of FME_BEGIN_TCL scripts fails. If, for some reason, this behavior is undesirable and you want to continue a translation even if the execution fails, you can add a Tcl catch command in your Tcl script – this will catch any errors and FME will continue with the translation.

The syntax is:

FME_BEGIN_TCL <Tcl script>

where the <Tcl script> is any valid Tcl script to execute, or

FME_BEGIN_TCL FME_Decode <encoded Tcl script>

which allows for the script to be encoded in an internal FME format produced by Workbench.

The script may access the following global Tcl variable:

Global Variable

Contents

FME_LogFileName

Allows you to write custom (user-defined) messages to the log file.

Note: Writing custom (user-defined) messages to the log file varies depending on whether it is during the start-up or shutdown phase. In a start-up script (because FME already has the log file open, and it is dangerous to open it more than once) you should use FME_LogMessage.

FME_LogMessage

 

The FME_LogMessage function is used to write messages to the FME log file. It may be invoked in one of two ways:

FME_LogMessage <severity> <messageNumber> [<arg1> ... <argN>]+

or

FME_LogMessage <severity> <message>

<severity> can have one of these values:

fme_inform, fme_warn, fme_error, fme_fatal, fme_statistic, and fme_statusreport

When the first form is used, the message number must be present in a file in the messages subfolder under the FME installation folder. The remaining parameters are used to fill in any %0, %1, ... %n parameter holders in the message. For example, if the message was:

3011, Opening file %0 for mode %1

then FME_LogMessage could be called like this:

FME_LogMessage fme_inform 3011 /tmp/cacher.txt read

In the second form, the message is output directly to the log file.

FME_MacroValues(<macroname>)

Each element in this array, indexed by macro name, holds the number of each macro known to the workspace or mapping file at the end of parsing.

FME_MappingFileId

The value of the MAPPING_FILE_ID directive specified in the mapping file