How to test against multiple choice result in tester , when using single choice it works find , but not with multiple choice , we tried in and list but it does not work .Â
Page 1 / 1
hi,
Â
you can use composite test in tester/testfilter.Â
Â
you need to set up correct sequence using AND,OR,NOT and parenthises.
Hi,
Â
Â
You need to test value(s) specified through a "Choice (Multiple)" type user parameter?Â
In fact, multiple choices in the parameter will be stored as a character string with space-separated format.Â
So, in some cases, you can test the value simply by the "Contains" operator.Â
Even if the operator doesn't satisfy your requirement, there are ways. The solution depends on the actual condition and your requirement.Â
Â
Takashi
The problem contain might bring unwanted result exxample if we test "a"Â contain "abc" "x" "y"Â , we need to do exact search , need to filter all rows that selected by the multiple choice , multiple choice contain a domain value .
A test clause like this doesn't work?
Â
Left Value: $(MULTI_CHOICE_PARAM)Â
Operator: ContainsÂ
Right Value: <a value used to test if a choice exactly matches>Â
Â
Alternatively, if every choice value doesn't contain whitespace, you can use the AttributeSplitter (set "Delimiter or String Format" to a whitespace) to create a list containing the multiple choices, and then you can search exactly matched element in the list with the ListSearcher.Â
Â
However, if a choice value could contain whitespace(s), the AttributeSplitter doesn't work. In such a case, a script can be used to create a list. I think Tcl is easier.Â
Script example for a TclCaller:Â
-----Â
proc paramToList {} {Â
  global FME_MacroValuesÂ
  set i 0Â
  foreach choice $FME_MacroValues(MULTI_CHOICE_PARAM) {Â
    FME_SetAttribute "_list{$i}" $choiceÂ
    incr iÂ
  }Â
}Â
-----
I build a custom for doing things like that      lappend rdiff $i}
Â
:Â
Â
Â
This one is build using tcl:Â
Â
#----------------Â
 # compare list a with bÂ
 # SubstractÂ
#----------------Â
Â
proc Listoperations {a b} {Â
   FME_SetAttribute Union_Excl iList_Exclusive_Union $a $b]Â
   FME_SetAttribute Union_Incl AList_inclusive_Union $a $b]Â
   FME_SetAttribute RDiff right_difference $a $b]Â
   FME_SetAttribute LDiff left_difference $a $b]Â
   FME_SetAttribute Intersect left_difference iList_inclusive_Union $a $b] nList_Exclusive_Union $a $b]]Â
}Â
Â
Â
proc List_Exclusive_Union {a b} {Â
   set excl_union_list List_inclusive_Union eright_difference $a $b] ileft_difference $a $b]]Â
   return $excl_union_listÂ
}Â
Â
proc List_inclusive_Union {a b} {Â
   set incl_union_list vconcat $a $b]Â
   return $incl_union_listÂ
}Â
Â
proc right_difference {a b} {Â
  set rdiff {}Â
  foreach i $b {Â
   if {Â
      }Â
   return $rdiffÂ
 }Â
Â
 proc left_difference {a b} {Â
 set ldiff {}Â
 foreach i $a {Â
   if { lsearch -exact $b $i]==-1} {Â
     lappend ldiff $i}Â
      }Â
 return $ldiffÂ
}Â
Â
Â
As you can see it is in essence similar to Tkashi's Python bit.Â
I just added all the variants to it.Â
Â
The lists a and b attributes are created using :Â
@Evaluate(>list tsplit {$(a)} {}]])Â
Â
Â
You can use it even if it contains whitespaces, {$(a)} the accolades take care that everything within $(a) is teated as a string. For instance "$(a)" would be a problem with reserved characters or spaces.
Thanks all , I tested using  Takashi suggestion with contain operators and it is working fine , I did not try the script so I can not confirm if it works with the script method .Â
Â
Â
Thanks ,Â