Jump to content

if agument returning unexpected TRUE


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

Recommended Posts

The calculation:

$$category = "11491961930" or "11491971250" or "11491971250" or "47995855093" or "47995855093"

is giving me a TRUE no matter what $$category is. I have no idea what triggered this happening since it used to work properly. I tracked $$category in the debugger and it has $$category as a text string containing no numbers in my test cases so I don't know how it would be matching that to trigger the IF statement.

Edited by MaxB.
Link to comment
Share on other sites

You cannot write a string of "or" statements. Also, do you really need a $$var? If the var only needs to exist for the life of the script, then use $var.

Hopefully, someone will have a more elegant calc than this, but:

If ( $category = "11491961930" or $category = "11491971250" ) 

 

Link to comment
Share on other sites

You cannot use that syntax in FileMaker; only the first sub-expression tests $$category, the others are stand-alone that are all True, since it there is a number in that string and GetAsBoolean() returns True. So if any of them is True, the entire expression is.

Instead, try

$$category = "11491961930" or 
$$category = "11491971250" or 
$$category = "11491971250" or 
$$category = "47995855093" or 
$$category = "47995855093"

(which is a bit verbose), or

Let (
  checkList = List ( "11491961930" ; "11491971250" ; "11491971250" ; "47995855093" ; "47995855093" ) ;
  not IsEmpty ( FilterValues ( $$category ; checkList ) ) 
)

which looks better the longer your list is, and is the best way to check for membership in a non-literal list (one you generate dynamically).

And heed what Barbara (hi there! :)) said about using $$vars.

Edited by eos
Link to comment
Share on other sites

Well now I have no idea how this code was "working as intended" before now. This is super old and poorly documented, I don't even know where the numbers in the comparison are coming from. I do know the $$ is being used to pass the var between scripts though. I could change it to a global field probably if using $$ is such a faux-pas.

Edited by Lee Smith
duplicate, looks like the fmforums hickup
Link to comment
Share on other sites

Well now I have no idea how this code was "working as intended" before now.

It wasn't.

This is super old

Well, not super old, since variables are a "new feature" of version 7 - just slightly over 11 years ago. Time considerations aside, version 7 was the last revolutionary upgrade. For those of us that started in prior versions, variables are still new, as are the other changes introduced then and since then.

I could change it to a global field probably if using $$ is such a faux-pas.

We cannot tell if it is a faux-pas or not without seeing how exactly it is used. Certainly, if you need a variable to persist after the script has run, then it needs to be a global variable. And replacing it with a global field is not likely to serve any purpose other than bloat your schema. But if the purpose is to pass the value to another script, then consider using a script parameter instead. Unlike a global variable, it doesn't hang around after all the scripts have run out.

 

 

Edited by comment
Link to comment
Share on other sites

This topic is 3124 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.