Hi Richard

it look like you are mixing TCL and Tcl2 - read about the differance in the 
manual. The key point is that they use different intereprters so you can't 
mix them.

If you stick to Tcl2 - it gives the best performance in most cases - i think 
it will worke.

attatched is a small mapping file i normaly use to test functions and tcl 
code I find it wery usefull, where i have put a few exampels on how it works

a note about the notation the use off ::var is usede to reffrence a variable 
in the global namespace, you can do the same with a 'global var' in your 
proc.

have fun [;-}

Peter



>From: "RichardW" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: [fme] Re: Macros, Parameters & FME_END_TCL
>Date: Wed, 21 Dec 2005 15:47:06 -0000
>
>Thanks Peter,
>
>I have moved forward and can now pass a parameter to my called tcl
>script.  However I am still unable to create my own global.  Here is
>an extract from my header:
>
>
>TCL puts {ZZZZZZZZZZZZZZZZZZZZZZ $(FME_MF_DIR)}
>TCL2 set RwAdmin RichardW
>TCL puts {XXXXXXXXXXXXXXXXXXXXXX $RwAdmin}
># Call script to log status in Oracle table
>FME_END_TCL source {$(FME_MF_DIR)Test_FME_END.tcl} ; set  myVar
>$(FME_MF_DIR)
>
>
>and from my tcl script:
>
>puts {Printed from called tcl program $MyVar}
>
>
>The output extract is:
>
>Opened native MapInfo file `C:\MapTest\MyAggregateTest.tab'
>ZZZZZZZZZZZZZZZZZZZZZZ C:\MapTest/
>XXXXXXXXXXXXXXXXXXXXXX $RwAdmin
>
>Translation was SUCCESSFUL (4 feature(s)/43 coordinate(s) output)
>FME Session Duration: 1.5 seconds.
>Printed from called tcl program $MyVar
>
>
>You can see that the pre-defined macros expand ok but the globals
>RwAdmin and MyVar do not work.  I think that it must be either the
>way I am defineing them or the way I am calling them that is wrong. I
>tried following your example.  Can you see what I am doing wrong.
>
>Richard W
>
>
>
>
>
>
>
>--- In [email protected], "peter laulund" <[EMAIL PROTECTED]>
>wrote:
> >
> > Hi
> >
> > wheter your code is in the global namespace or in a proc you can
>use one off
> > these options
> >
> > FME_END_TCL source {$(FME_MF_DIR)Test_FME_END.tcl} ; myProg
>$(macroName)
> >
> > where you give the macro as a parameter to the proc starting the
>script
> >
> > or you can just place the value in a global variable
> >
> > FME_END_TCL source {$(FME_MF_DIR)Test_FME_END.tcl} ; set  myVar
>$(macroName)
> >
> > you can use this syntax when starting any kind of tcl (FME_END_,
>INCLUDE [
> > or Tcl2/TCL) as an exampel from a project i am working on right now
> >
> >
> > Tcl2 set gsPath2App
>$(FME_MF_DIR_UNIX)/
> > ; \
> >      set gsPath2Data [regsub -all -- {\\} {$(DestDataset)/
>$(DestFormat)}
> > {/}] ; \
> >      set dbf $gsPath2App/tcl/def/
>$(Dataset)/felter.dbf
> > ; \
> >      catch { file mkdir
>$gsPath2Data }
> > ; \
> >      source
>$gsPath2App/TCL/ATTRIBUT.TCL
> > ; \
> >      source $gsPath2App/TCL/$(DestFormat)
>_OUT.TCL
> > ; \
> >      source
>$gsPath2App/TCL/LIB/LANUTIL.TCL
> > ; \
> >      main $(DestFormat)
> >
> > Note: you have to sepperate the command with a ; and also note the
>use of
> > FME_MF_DIR_UNIX/ this gives a parth with / rather than \ allowing
>us to get
> > rid of the {} around the parth :-}
> >
> > Peter Laulund
> >
> >
> > >From: "RichardW" <[EMAIL PROTECTED]>
> > >Reply-To: [email protected]
> > >To: [email protected]
> > >Subject: [fme] Macros,  Parameters & FME_END_TCL
> > >Date: Tue, 20 Dec 2005 15:05:56 -0000
> > >
> > >Hi group,
> > >
> > >I am having trouble passing a parameter to a tcl script invoked by
> > >FME_END_TCL.
> > >
> > >I have used Tools, Edit Header to include the following:
> > >
> > ># =================================================================
> > ># Call script to log status in Oracle table
> > >FME_END_TCL source {$(FME_MF_DIR)Test_FME_END.tcl}
> > ># =================================================================
> > >
> > >
> > >The Test_FME_END.tcl script logs the translation status in an
>oracle
> > >table.  This works fine.
> > >
> > >Now I want to generalise the procedure so that the same tcl script
>is
> > >used for each transform.  A parameter(s), eg administrator email,
>set
> > >in the header will pass through to the tcl script which will be
> > >logged in the database and used to trigger an email alert to the
> > >appropriate administrator.
> > >
> > >I cannot figure out how to set a parameter in the header and pass
>it
> > >to my tcl script.
> > >
> > >Can anyone help with this
> > >
> > >Thanks
> > >Richard
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >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
> > >
> > >
> > >
> > >
> > >
> > >
> >
> > _________________________________________________________________
> > Del din verden med MSN Spaces http://spaces.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
>
>
>
>
>
>
>

_________________________________________________________________
Del din verden med MSN Spaces http://spaces.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 : 2 februar 2005

  Beskrivelse   :

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

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

READER_TYPE NULL
READER_KEYWORD INPUT
INPUT_DATASET nullin

WRITER_TYPE NULL
WRITER_KEYWORD OUTPUT
OUTPUT_DATASET nullout

DEFAULT_MACRO DestFormat MAPINFO

# =============================================================================
Tcl2 set var $(DestFormat)

Tcl2 proc myProc1 {} { FME_SetAttribute var $::var }
Tcl2 proc myProc2 {a} { set ::var2 [string tolower $a ] } ; myProc2 $(DestFormat)
Tcl2 proc myProc3 {} { FME_SetAttribute var2 $::var2 }

# ============================================================================= # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FACTORY_DEF * CreationFactory \ FACTORY_NAME "Create Some Features" \ 2D_GEOMETRY 0.01 0.01 \ NUMBER_TO_CREATE 1 \ OUTPUT FEATURE_TYPE someFeature \ @SupplyAttributes(ID, 123) \
     @Log("start", 1, 0)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FACTORY_DEF * TeeFactory \ FACTORY_NAME "Output logger" \ INPUT FEATURE_TYPE * \ OUTPUT FEATURE_TYPE arcFeature \ OUTPUT FEATURE_TYPE * \ @Tcl2( myProc1 ) \ @Tcl2( myProc3 ) \
    @Log("efter", 10, 1)

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

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

Reply via email to