Skip to main content
Solved

String Compare for TestFilter

  • November 20, 2013
  • 5 replies
  • 105 views

Forum|alt.badge.img
Excuse my knowlege of TCL (it is very rusty).

 

 

I have a stream of featues (fme_line), with the attribute:

 

 

Attribute(encoded: utf-8) : `type' has value `Ferry Route'

 

 

or

 

 

Attribute(encoded: utf-8) : `type' has value `Major Highway'

 

 

I am trying to use the TestFilter to find the ferrys.

 

 

I have the following StringFinder call, but it always returns -1:

 

 

@FindString(@Value(type) , "ferry", 0, FALSE)

 

 

also I have tried something simpler

 

 

@Value(type) = "Ferry Route"

 

 

But that also is always failing.

 

 

And this also does not work:

 

 

@Value(type) CONTAINS "Ferry"

 

 

any ideas?

 

 

 

Best answer by dr_ysg

I'm sorry 

 

 

It really should be

 

 

@Value(type) CONTAINS Ferry (with no quotes).

 

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

takashi
Celebrity
  • November 21, 2013
Hi,

 

 

The FindString function seems not to trim white spaces in the parameter string. Try these expressions: @FindString(@Value(type),"ferry", 0, FALSE) or @FindString(@Value(type),ferry, 0, FALSE)    But, I believe these expressions would work. Sounds strange... @Value(type) = "Ferry Route" @Value(type) CONTAINS "Ferry"

 

Takashi

Forum|alt.badge.img
  • Author
  • November 21, 2013
But all of these varients, I listed in my original message as NOT WORKING. I just retried them exactly as you specifed (in an expression evaluator,

 

 

the FindString() is returning -1 always

 

and the others are false.

 

 

And the other two crash the expression evaluator

 

 

RoadMaker_ExpressionEvaluator: Failed to evaluate TCL expression: Major Highway CONTAINS "Ferry"

RoadMaker_ExpressionEvaluator: TCL Error Message: invalid bareword "Major"

in expression "Major Highway CONTAINS "Fer...";

should be "$Major" or "{Major}" or "Major(...)" or ...

 

 

Which seems to point a TCL syntax issues of quoatation,

 

 

 

 

 


takashi
Celebrity
  • November 22, 2013
I reproduced the error message with the ExpressionEvaluator. Did you perhaps type this expression directly in the editor of ExpressionEvaluator? @Value(type) CONTAINS "Ferry"   If so, it will be transformed like this, when receiving a feature. Major Highway CONTAINS "Ferry" Naturally it is not a valid expression to be interpreted by the Tcl interpreter.   If you want to use the ExpressionEvaluator, try this expression. @FindString(@Value(type),ferry,0,FALSE)   Or, consider using the Tester transformer with this setting. Left Value  |  Operator  |  Right Value type  |  Contains  |  Ferry * type is the attribute name, Ferry is a constant value.

Forum|alt.badge.img
  • Author
  • November 22, 2013
@Value(type) CONTAINS "Ferry" was the only magic verison that works (for the TestFilter Transform). But it does work, so thank you.

 

 

 


Forum|alt.badge.img
  • Author
  • Best Answer
  • November 22, 2013
I'm sorry 

 

 

It really should be

 

 

@Value(type) CONTAINS Ferry (with no quotes).