Jump to content

Compare/Evaluate Variables


This topic is 1809 days old. Please don't post here. Open a new topic instead.

Recommended Posts

This is probably one of those questions which separates me from people that make money as developers and those that don't (that would be me).  I have a simple script that compares two variables. The variables are populated with  text (Peoples Names).  Basically, if the the two variables are TRUE (the variables are equal) I want to stop the script.  Despite the two variables being equal - the IF continues.  I have noted when I use the same numbers to populate the variables - the script works as expected.  Please tell me Filemaker is smart enough to evaluate text in variables.   Below is the my script and attached is a screenshot of my debugging efforts.   

As always - thank you to the people here which share your wisdom - a big reason I love Filemaker so much.  

Jim

IWP: IWP: Bunk Choice Select
#This script allows WebD users to select bunkmates for the coming summer.

#List All Chosen Names

Set Variable [ $BR_List; Value:List ( BRE__BUNKSREQUEST_tog::Bunk Request Choice 1;BRE__BUNKSREQUEST_tog::Bunk Request
Choice 2;BRE__BUNKSREQUEST_tog::Bunk Request Choice 3;BRE__BUNKSREQUEST_tog::Bunk Request Choice 4 ) ]

Set Variable [ $BunkRequest; Value:Agegroup_Names_List::Name_Full ]
Set Variable [ $BR_Check; Value:FilterValues ( $BR_List ; $BunkRequest ) ]

#IF check to see if the names has already been selected

If [ $BunkRequest = $BR_Check ]
Show Custom Dialog [ Title: "No Duplicates"; Message: "You have already chosen this person. Please give us FOUR differnt names!
Thanks!"; Default Button: “OK”, Commit: “Yes” ]
Exit Script [ ]
End If

 


If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 1 = "" ]
Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 1; $BunkRequest ]
Else If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 2 = "" ]
Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 2; $BunkRequest ]
Else If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 3 = "" ]
Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 3; $BunkRequest ]
Else If [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 4 = "" ]
Set Field [ BRE__BUNKSREQUEST_tog::Bunk Request Choice 4; $BunkRequest ]
End If
Commit Records/Requests
[ Skip data entry validation; No dialog ]

 

Variable_Compare.jpg

Link to comment
Share on other sites

Of course, without seeing your file with the actual data, I can only guess. Still, it seems like a reasonable conjecture:

The result of the FilterValues() function always has a trailing carriage return. Therefore:

item = FilterValues ( list ; item ) 

will always be false (unless item has a trailing carriage return, too).

 

To test if an item appears in a list, use:

not IsEmpty ( FilterValues ( item ; list ) )

 

 

Edited by comment
Link to comment
Share on other sites

1 hour ago, comment said:

not IsEmpty ( FilterValues ( item ; list ) )

Thank you so much Comment - this was the correct answer!  ******* carriage returns - they get me every time!   Thank you again!!

Link to comment
Share on other sites

This topic is 1809 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.