Skip to main content

Hello FME Gurus,

 

I have a list which contains a known sequence of values that represent different things but are linked.

I have created a list and I am then searching in the list for a specific word, in this case 'PM'

The ID for the PM is located two spots in the list before the word PM.

I am trying to extract the ID from the list dynamically but can't seem to get the syntax correct in Attribute Manager.

 

@Value(_surveytable{@Evaluate(@sub((_list_index),2))}.autocad_text_string)

 

Can anyone help is getting the index value syntax correct so I get the value that is located in the index minus 2?

Thanks

Dean

 

I think this expression works for you if the "_list_index" attribute has a number greater than 1.

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

Hi! This would work:

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

I tested with sub function too, but couldn't get it working inside @Evaluate. No errors, but no result. It might be a bug related to sub, since e.g. max is working just fine inside @Evaluate, and it has a similar syntax.

EDIT: Just noticed Takashi had already posted an answer.


I think this expression works for you if the "_list_index" attribute has a number greater than 1.

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

Thanks @takashi you are a champion :)


Hi! This would work:

@Value(_surveytable{@Evaluate(@Value(_list_index)-2)}.autocad_text_string)

I tested with sub function too, but couldn't get it working inside @Evaluate. No errors, but no result. It might be a bug related to sub, since e.g. max is working just fine inside @Evaluate, and it has a similar syntax.

EDIT: Just noticed Takashi had already posted an answer.

Thanks @geolassi very much appreciated.


Thanks all, the suggestions above worked but only gave me the first match using List Searcher.

Is there a way to loop through all values in the list?


Thanks all, the suggestions above worked but only gave me the first match using List Searcher.

Is there a way to loop through all values in the list?

It seems like you're building the list in the first place - if you just want to keep every feature that is 2 places in front of the feature with the value in PM you could use the adjacent attribute function with a conditional in an attributecreator without building a list

So for each feature, test whether the feature that is 2 after it equals PM. If it does, make a new attribute called PM holding the value in the autocad_text_string.

If there's another reason for using the list and I had to loop through it i'd probably resort to python.

Example:

two_in_front.fmwt

 


It seems like you're building the list in the first place - if you just want to keep every feature that is 2 places in front of the feature with the value in PM you could use the adjacent attribute function with a conditional in an attributecreator without building a list

So for each feature, test whether the feature that is 2 after it equals PM. If it does, make a new attribute called PM holding the value in the autocad_text_string.

If there's another reason for using the list and I had to loop through it i'd probably resort to python.

Example:

two_in_front.fmwt

 

Thanks @egomm, that worked perfectly after tweaking the index values to get the correct values.


Reply