Hello FMEers,

You may have seen some action in the list and in the whatsnew.txt revolving
around the new @Tcl2 function, so I thought I'd explain what all the fuss is
about.

@TCL is a very very handy function that has been in FME for a long time now,
and it is heavily used in many large-scale mapping files and, in one way or
another, by about 65 of the 170 or so transformers in FME.

The problem that @TCL had was that it was kind of slow.  In fact, its
performance was directly related not so much to what the Tcl script you were
having it execute was, but more to how many attributes were on each feature.

Why? Because we *had to* always set up the FME_Attributes global array, which
traditionally was used to access the attributes on the feature.

The sad thing was that many/most of the time, the Tcl script accessed only
one or two attributes, but yet we were paying the overhead for all the
attributes that were there.

Enter @Tcl2 (yes, it is lower case cl, which is what the @TCL should have
been actually).

@Tcl2 is IDENTICAL to @TCL except that it does not set up the FME_Attributes
array.  So it does not incur that overhead.

But what if you want to actually access some attributes?  We provide several
new functions to do just that:

    FME_AttributeExists <attributeName>

    FME_GetAttribute <attributeName>

    FME_SetAttribute <attributeName> <attrValue>

    FME_UnsetAttributes <attr1> [<attr2> <attr3 ...]

    FME_AttributeNames

    FME_RenameAttribute <newName> <oldName>

    FME_CopyAttribute <newName> <oldName>

See the attached PDF for details on the operation of each of these.

Note that you can use these functions from @TCL as well, but you should just
change your @TCL to @Tcl2 to get the speedups.  All you need to do is replace
any $FME_Attributes references with the relevant function calls above.

Also note that if you have any workspaces around, just opening them up,
moving a transformer a wee bit, and then saving them will cause the all-new
transformer definitions to be used. So any of the transformers that used @TCL
will now be using @Tcl2, and so you should notice a speedup.  (And hopefully
no behaviour changes -- if you do, please let us know at [EMAIL PROTECTED]).

This stuff has been (mostly) in the FME 2005 betas for about a month now,
though the FME_AttributeExists makes its appearance in builds > 1584
(basically, as of today).

How much faster is it? It is directly related to how many attributes were on
your features.  Its easy to make cases where mapping files run 100 times
faster than they did before, but this may not be the typical case.  All we
know is that it is a lot more efficient, and in some cases, drastically
faster.  Enjoy!

Dale

PS:  One last note -- if you are using @Tcl in mapping files, you should try
as hard as you can to use "proc"s to do your actual processing.  Just set
them up on Tcl2 configuration lines, like:

        Tcl2 proc doSomething {} { ... }

Then do only @Tcl2(procname) or @Tcl2("procname arg1 arg2..") in your actual
mapping file.  Why? The Tcl interpreter pre-compiles all "procs", so if you
use this pattern, the interpreter isn't reparsing your script over and over
again, as it would if you put the whole script in the @Tcl2( ... ) function
call.  All relevant transformers have been rewritten to use this trick as
well.


----------------------------------------------------------------------
Dale Lutz������������� Safe Software Inc.���������������� [EMAIL PROTECTED]
VP Development�������� Surrey, BC, CANADA������� phone: (604) 501-9985
���������������������� http://www.safe.com�������� fax: (604) 501-9965
----------------------------------------------------------------------



Get the maximum benefit from your FME, FME Objects, or SpatialDirect via our 
Professional Services team.  Visit www.safe.com/services for details. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/fme/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Attachment: Tcl2.pdf
Description: Adobe PDF document

Reply via email to