TclCaller

Runs a Tool Command Language (Tcl) command and assigns its return value to an attribute.

The Tcl command can operate on the feature’s geometry and/or attributes, using any of the built-in Tcl functions provided by the Tcl language, as well as any of the FME-provided Tcl facilities.

See the Tcl language reference manual (www.tcl.tk) and the FME Tcl Variables and Functions section below for details of the capabilities.

Common Tcl examples usage include:

  • Trim spaces from an attribute:

FME_SetAttribute trimmedAttribute [string trim [FME_GetAttribute originalAttribute]]

  • Replace all non-numeric characters with spaces in an attribute:

FME_SetAttribute anAttribute [regsub -all {[^0-9]} [FME_GetAttribute anAttribute] {}]

  Note that in this case, the return value is the number of substitutions actually made.

  • Match a regular expression against an attribute:

regexp {^[A-Za-z]$} [FME_GetAttribute anAttribute]

This regular expression tests if the entire value of the attribute consists only of alphabetic characters.

Note that when matching regular expressions, the return value will be 1 if the expression matched, and 0 otherwise.

  • Log a custom message to the log window:

FME_LogMessage fme_inform {This is my message}

The recommended way to manipulate feature attributes is through the functions that are provided for this purpose:

FME_GetAttribute attrName

FME_SetAttribute attrName newVal

FME_CopyAttribute destAttrName srcAttrName

FME_RenameAttribute destAttrName srcAttrName

FME_UnsetAttributes attrName1 [attrName2 attrName3 ...]

Usage Notes

  • % Character: Due to FME parser limitations, a Tcl expression cannot contain a percent (%) character. If a % character is needed, the expression should be coded as a Tcl procedure and put into an external file to be 'source'd in. Note that you can avoid the % character issue by using a StringFormatter transformer, which provides a convenient way to access the Tcl 'format' command.

Configuration

Parameters

FME Tcl Variables and Functions

Editing Transformer Parameters

Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.

Defining Values

There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters. There are a number of tools and shortcuts that can assist in constructing values, generally available from the drop-down context menu adjacent to the value field.

Dialog Options - Tables

Transformers with table-style parameters have additional tools for populating and manipulating values.

FME Community

The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.

Search for all results about the TclCaller on the FME Community.