Enigma20xx Posted August 30, 2013 Posted August 30, 2013 I am trying to filter two variables but I can't make it work. Could someone point me what am I doing wrong? Thank you. Sample.zip
bruceR Posted August 30, 2013 Posted August 30, 2013 You are incorrectly understanding the result of the filter operation. The result is a list. But your script step is looking for a true/false value. Filter( "Black¶White¶Red¶Blue¶Green"; "Black") results in "Black" You want to test for the value count of the result. Set Variable [ $Colors; Value:"Black¶White¶Red¶Blue¶Green" ] Set Variable [ $FilterColor; Value:"Black" ]Set Variable [ $result; Value:FilterValues ( $Colors ; $FilterColor ) ] If [ ValueCount( $result ) ] Show Custom Dialog [ Title: "It filters"; Default Button: “Aceptar”, Commit: “Yes” ] Else Show Custom Dialog [ Title: "It doesn't filter"; Default Button: “Aceptar”, Commit: “Yes” ] End If
bruceR Posted August 30, 2013 Posted August 30, 2013 Also, if you did: Set Variable [ $FilterColors ; Value:"Black¶Purple" ] Set Variable [ $result; Filter( "Black¶White¶Red¶Blue¶Green"; $filterColors)] The result would be "Black" You would probably want to test for valueCount( $result ) = valueCount( $filtercolors )
Enigma20xx Posted August 31, 2013 Author Posted August 31, 2013 I’m sorry but I think I didn’t explain myself well. My goal: I’m working on a Show Custom Dialog TAG. I want to use the $AvailableColous variable as the TAG of a field. Once a colour is chosen, the next time I go through the dialog (I know a loop is needed), the TAG shouldn’t show the already chosen colour. What I try to accomplish is to dynamically exclude the chosen colour from the available ones. In another one of my posts, EOS, suggested me to use filtered portals instead of value lists. He drove my sample in that direction and in one of his sample scripts filters two variables to later exclude value in the filtered. http://fmforums.com/forum/topic/89458-conditional-vl-including-2-join-tables/ script: SelectExecsInHolding, section: #keep both lists synchronous That is what I’m trying to do but I still can’t manage it. Too many to learn yet. Thank you. I’ve made some changes to the sample file. Sample.zip
eos Posted August 31, 2013 Posted August 31, 2013 Instead of a loop you can use a recursive CF, like this very handy one: http://www.briandunning.com/cf/193 Some error trapping is also a good idea when dealing with those pesky users … Sample_Zap_eos.fmp12.zip 1
bruceR Posted September 1, 2013 Posted September 1, 2013 Well, perhaps you made some changes but they can't work because you ignored the logic problem of your IF statement. Your statement If [ FilterValues ( $AvailableColours ; $ChosenColour ) ] Does not work as written. It needs to be: If [ ValueCount( FilterValues ( $AvailableColours ; $ChosenColour )) ] SampleMOD.fmp12.zip
jbante Posted September 1, 2013 Posted September 1, 2013 If [ ValueCount( FilterValues ( $AvailableColours ; $ChosenColour )) ] This usually isn't a substantial difference, but the calculation will usually evaluate a little faster like so: If [not IsEmpty ( FilterValues ( $shorterList ; $longerList ) )]
Recommended Posts
This topic is 4373 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now