Skip to main content
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?
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} fFME_GetAttribute "street_count"]]

 

-----

 

 

and so on.

 

 

Takashi
This Tcl expression is simpler than the previous one.

 

-----

 

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

 

-----

 

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..

 

 

 
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.
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.

 

 

Reply