Hi Jason

>Are TCL regular expressions expensive

I think tcl i quit efficient so its more a matter of using the 'correct' 
functions if they exists

alsoe note that there is a 'file split' commad that will convert a filename 
into a tcl list and a 'file join' that will convert a tcl list into a proper 
filename

I use regexp / regsub a lot but as you point out they can be rather complex 
to build.

As an exampel if you want to change a input path to a output part this can 
be don with a regular expresin

if your input dataset are in

D:\Mydata\input\01\....
D:\Mydata\input\02\....
etc

and you want the output data to be in
E:\TEMP\output\01\....
etc

the input root is D:\Mydata\input and the output root is E:\TEMP\output

we can now build a regular expression that substiute the input root with the 
output root

FME_SetAttribute multi_writer_id [regsub -- {E:\TEMP\output}  
[FME_GetAttribute myInputDir ] ] {E:\TEMP\output}

beware of the \ / issue ;-{

as fme onley creates a new directory if it is a subdirectory to an existing 
directory we will alsoe have to write a function thats checks if a directory 
exist and if not then creates
it

proc checkAndCreate {} {
       set outputDir [regsub -all -- {\\} [FME_GetAttribute multi_writer_id 
] {/} ]
       if {![file exists $outputDir ]} {
           file mkdir $outputDir
       }
}

And YES use some time to learn tcl it is worth the effort, you can do so 
mutch more not only in processing the features, but alsoe in writing dynamic 
mapping files, batch processing, pre and post processing using the 
fme_begind_tcl / fme_end_tcl  and mutch, mutch more. [:-}

if you search the list i think you can find some exampels illustrating 
different aspects of tcl, alsoe get yourselv a null2null mappingfile this 
will let your test any tcl command - or fme function - in a controlled way - 
I just attatched one as an exampel

DALE: at the scandinavian user conference you talked about a fme wiki, how 
are the plans for this, the above diskussion is a candidate  it think.

Peter


>From: "Jason Birch" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: <[email protected]>
>Subject: RE: [fme] FME -how extract source dataset directory attribute
>Date: Mon, 27 Jun 2005 20:17:27 -0700
>
>Hi Peter,
>
>Even with the (much more readable) TCL call, you're still stuck with the 
>problem of breaking the path into two parts and hard-coding one of them in 
>the dataset fanout.
>
>That TCL function is good to know about.  I really must find time to learn 
>enough TCL to be dangerous.  Right now my TCL comprehension is enough to be 
>middling ineffectual...
>
>Are TCL regular expressions expensive, or do you just not prefer them 
>because of their relative complexity?  I know that I always have to make 
>sure to comment REs so that I can remember what they're for :)
>
>Jason
>
>________________________________
>
>From: [email protected] on behalf of peter laulund
>Sent: Mon 2005-06-27 1:22 AM
>To: [email protected]
>Subject: RE: [fme] FME -how extract source dataset directory attribute
>
>
>
>Hi
>
>just a comment to Jasons  mail
>
>rather than using a regular exprsion why not use the 'flile dirname' 
>command
>   from tcl
>
>in the tcl caller type in this expresion
>
>file dirname [FME_GetAttribute fme_dataset]
>
>NOTE this command will convert \ into / but i dont think its a problem for
>fme. TCL normaly use / as a directory seperator and the  \ as an escape
>character, making it 'interesting' to work with files in tcl on a windows
>machine.
>
>if you want the windows version use this command
>
>file nativename [file dirname [FME_GetAttribute fme_dataset]]
>
>Peter Laulund
>National Survey and Cadastre, Denmark
>
>
>
>
>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
>
>
>
>
><< winmail.dat >>

_________________________________________________________________
Log på MSN Messenger direkte på nettet  http://webmessenger.msn.com/


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/
 
/* ============================================================================

  Navn          : Peter Laulund, KMS

  Oprettet dato : 26 januar 2004 - 12:55

  Beskrivelse   :

============================================================================*/

# ============================================================================= # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#FME_DEBUG MAPPING_FILE

READER_TYPE NULL
READER_KEYWORD INPUT
INPUT_DATASET nullin

WRITER_TYPE NULL
WRITER_KEYWORD OUTPUT
OUTPUT_DATASET nullout

# =============================================================================
Tcl2 source mysource.tcl

# ============================================================================= # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FACTORY_DEF * CreationFactory \ FACTORY_NAME "Create Some Features" \ 2D_GEOMETRY 100000 600000 \ NUMBER_TO_CREATE 1 \ OUTPUT FEATURE_TYPE someFeature \ @SupplyAttributes(myattr, somValue) \
     @Log("Before", 1, 1)

FACTORY_DEF * TeeFactory \ FACTORY_NAME "Output logger" \ INPUT FEATURE_TYPE * \ @Tcl2(myProg) \ OUTPUT FEATURE_TYPE * \
     @Log("After", 1, 1)

# =============================================================================
INPUT *

OUTPUT *
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # =============================================================================


Reply via email to