I'm trying to create an attribute ("incorporated") whose value is 0 or 1, depending on the value of another attribute ("Code"). I'm trying to do this in Attribute Manager. But I can't seem to get it to evaluate. I've tried many different permutations of the expression. The attempt shown in the attachment uses Python syntax highlighting which I would assume means it would be interpreted as Python code. Anyway, it doesn't work, as you can see in the breakpoint data.
In the AttributeManager, click the incorporated line. Then click on the down arrow in the Attribute Value box. Click Conditional Value...
This will open the conditional value dialog, where you can define your if-then statement. Double-click on the blank next to If. Then type in your first condition. Note that Output Value is the value that you are assigning to incorporated when the test clause passes.
You can do this many times, to create all possible values for incorporated, or just set the Else value
:
In the AttributeManager, click the incorporated line. Then click on the down arrow in the Attribute Value box. Click Conditional Value...
This will open the conditional value dialog, where you can define your if-then statement. Double-click on the blank next to If. Then type in your first condition. Note that Output Value is the value that you are assigning to incorporated when the test clause passes.
You can do this many times, to create all possible values for incorporated, or just set the Else value
:
Great, thanks that works. Somehow I hadn't seen that option!
I'm still curious about how, when you enter an expression using the syntax of say, for instance, python, how that works. Is the fact that it's python detected via the syntax, meaning it's then interpreted as python? Would love to see some examples.
Great, thanks that works. Somehow I hadn't seen that option!
I'm still curious about how, when you enter an expression using the syntax of say, for instance, python, how that works. Is the fact that it's python detected via the syntax, meaning it's then interpreted as python? Would love to see some examples.
@angela
The problem with the expression is the if and return.
It should be
@Value(CODE)=="CN":1:0
@angela
The problem with the expression is the if and return.
It should be
@Value(CODE)=="CN":1:0
@angela
The problem with the expression is the if and return.
It should be
@Value(CODE)=="CN":1:0
Yes, I forgot the questionmark.
Should be @Value(CODE)==?"CN":1:0
It doesn't no more? I, see
Well then we have no choice but to use
>regexp {CN} @Value(CODE)] !=0?1:0
@angela
The problem with the expression is the if and return.
It should be
@Value(CODE)=="CN":1:0
@angela
The problem with the expression is the if and return.
It should be
@Value(CODE)=="CN":1:0
It would be a great loss if it were removed.
I see no logic in doing so.
It would cause workspaces to need more transformers then required.
FME uses tcl a lot anyway, so why would it become deprecated?
In fact before there was a "Conditional Value" I did this using expressions.
The @Evaluate() always did evaluate tcl expressions, I can't imangine why that would surprise you....
Look at the stringsearcher, which now (since some 2016 version) can do what I used to do using attributecreators evaluating regexp in string-mode, boolean-mode and index-mode using a custom to loop trough all the matches. Because using regexp in tcl would allow me to use switches. (example is still on the forum, so you can see how long ago that was..)
Great improvement. Alas, still can't use switches.
I could go on..i guess...