Skip to main content
Question

string concatenation issue

  • May 1, 2015
  • 5 replies
  • 134 views

I want to create a paragraph number like "1.2" from a literal "1." and the output attribute from a Counter using an expression in AttributeCreator.

 

Simple eh?

 

When the Counter is 2 I get the correct string "1.2" but when the Counter is 1 the output is "1.1000000000000001" as if it's a floating point operation with a rounding error.

 

I've tried

 

           @Trim(1.)@Evaluate(@int(@Value(street_count)))

 

to try and force string behaviour with no effect and I've tried using StringConcatenator instead of AttributeCreator in case that made a difference (doesn't).

 

 

Any ideas?
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
  • May 1, 2015
Hi,

 

 

It might be a side-effect caused by change about handling of internal data types in FME 2015.

 

I don't know whether it's intentional.

 

 

Anyway, workarounds.

 

a. Concatenate twice.

 

(1) _result = .@Value(street_count)

 

(2) _result = 1@Value(_result)

 

 

b. Use a suitable character other than dot (e.g. hyphen) as the delimiter when concatenating, and replace the character with a dot later, by a StringReplacer.

 

 

c. Use a TclCaller with this expression.

 

-----

 

return [format {1.%d} [FME_GetAttribute "street_count"]]

 

-----

 

 

and so on.

 

 

Takashi

takashi
Celebrity
  • May 1, 2015
This Tcl expression is simpler than the previous one.

 

-----

 

format {1.%d} [FME_GetAttribute "street_count"]

 

-----

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 1, 2015

 

In 2015 version you can't get past the forced evaluation. In 2014 you could remove the @Evaluate or the "=" sign. But in 2015 that is not possible. It is some symbol now...

 

 

i filed an issue on that, because it blocks the use of a lot of tcl in the attributecreator/tester etc..

 

 

 

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • May 1, 2015
btw....the concatenator transformer has no issue with that, afaik.

 

 

But we passed on fme2015 and await the fixes we hope they will make in the next patch.

  • Author
  • May 6, 2015
Takashi,

 

Concatenating twice gives me the same result as before, but concatenating with hyphen and then substituting a dot does the trick, thanks.

 

 

And thanks to everyone who replied.