Hi
I sometime have to loop trough a list, in this case I use proc like the one
Dan has sugested
but we dont have to give the number off elementes as a parameter to the
proc, we can use the FME_Execute function to call @NumElements() from
within the proc
alsoe note fme normaly starts numbering a list from 0 to N-1 therefor the
proc has to look like this
proc FindElement {} {
set N [ FME_Execute NumElements ufo_label ]
for { set i 0 } {$i < $N } {incr i} {
set s [ FME_GetAttribute myList{$i}.val ]
... some more code ...
}
}
A different appoache could be to find all the the list attributes with the
FME_AttributNames, by wrapping this in a lsearch command and teh use a
roreach loop to loop troug the attributes.
the 'myListName' is a regexp expresion matching the listname
set atrLst [ lsearch -inline -all -regexp [ FME_AttributeNames ]
{myListName} ]
foreach a $attrLst {
puts [ FME_GetAttribute $a ]
.....
}
the [ lsearch -inline -all -regexp [ FME_AttributeNames ] {myListName} ] is
an extremy poverfull expresion as it lets us search the attributes off a
feature in a simpel way
to get all system attributes off a SHAPE file just write
set shapeLst [ lsearch -inline -all -regexp [ FME_AttributeNames ]
{[A-Z0-9_]} ]
documentation off the lsearch command you can find at
http://www.tcl.tk/man/tcl8.5/TclCmd/lsearch.htm
Peter
>From: "Dan Iseminger" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: Re: [fme] Re: Lists in Tcl2
>Date: Fri, 3 Aug 2007 15:23:09 -0700
>
>On 8/3/07, kathy.irwin <[EMAIL PROTECTED]> wrote:
> >
> > Hi Mark,
> > The way I found to get around it is to get the number of list
> > elements before entering the Tcl2 proc and use that in the for loop.
> >
> > If anyone knows how to access the WB generated list array, I'd
> > appreciate it.
> >
>
>
>
>
>
>
>
>
>Hi Kathy,
>
>The Tcl2 [FME_AttributeNames] returns the same as the old TCL [array names
>FME_Attributes], so to see everything, do
>
>foreach name [FME_AttributeNames] {
> puts [format "%-30s %-30s" $name [FME_GetAttribute $name]]
> }
>
>But I prefer to get the number of elements from the list and loop through
>that anyway:
>
># e.g _list = points
># num = 40
># _attr = SEIS_PT_LONG
>proc FindElement {_list num _attr} {
> set _element_count [FME_Execute NumElements $_list]
> puts \n[concat $_list has $_element_count elements in it]
> for {set i 1} {$i<=$_element_count} {incr i} {
> set _current [FME_GetAttribute $_list{[expr $i - 1]}.$_attr]
> if {$num == $_current} {
> puts [concat Element [expr $i - 1] of $_attr = $num]\n
> }
> }
>}
>
>Dan Ise.
>Safe Software
_________________________________________________________________
Opret en personlig blog og del dine billeder på MSN Spaces:
http://spaces.msn.dk
For insights into what's up at Safe Software and what's on the development
horizon, visit Safe's blog at spatial-etl.blogspot.com.
Love FME? Then open your diary to March 6-7, 2008 and write this... "Second
Worldwide FME User Conference - Must Attend!" See
http://www.safe.com/company/fmeuc2008/index.php for more details.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/fme/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/fme/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> 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/