Jump to content

How can I compare text from fields?


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

Recommended Posts

Hi there!

Can give me an help about a problem that i'm having? I hope so. I need to make a comparison between values of text type (for example 13" ). When I'm writing the code in the script, and try to insert the value to make the comparison, an error is generated. For example:

IF (<FieldName> = "13"")

The values are: 13", 14", ... (a proprety of a Monitor)

Can anyone explain me how to solve this problem?

Thanks a lot...

FileMaker Version: Dev 6

Platform: Mac OS X Jaguar

Link to comment
Share on other sites

I don't know whether it makes too much difference, but you may want to stay away from using the " sign as a convention in your fields. Would you lose any information if you just stored the "13" and then added the " label later? Since the quotes are a fairly common part of scripting, it may lead to unnecessary confusion if you also have the quotes in the text field.

Case in point, your example asked about [color:"blue"] 13" as the value in the text field and Lee's solution referred to [color:"red"]13"". With the quote mark as part of the field value, even a veteran of 1750+ wink.gif posts might lose track. BTW, Lee is usually the guy that I see correcting everyone else's formulas (# of parens, commas, semicolons).

OR, I could be overly concerned, at which time I'm sure someone on the forum will let me know! grin.gif

Paul

Link to comment
Share on other sites

Hi Paul,

I agree that the data would be easier to deal with if it was just the number. Entering the data as 13" makes the calculation have potential problems if the data were entered as 13", 13 ", or 13 inch, 13 in, etc. However, as alexandraPT explained the situation as the data being entered as 13", so the calculation addressed that. Any variables can be dealt with by adding them to the calculation.

FileMaker will not accept a single quote in a calculation, and in order to have FileMaker accept it as a quote in the calculation, or display it as a result, you have to enclose one quote in two quotes.

HTH

Lee

wink.gif

Link to comment
Share on other sites

I tried to hardcode a 13" in a calculated field to check and see if the use of the " was valid:

IF(Monitor = "[color:"green"]13"", "Valid","not valid")

My computer did not recognize that the green " was supposed to be part of the text field contents and not part of the calculation. It gave me an error and would not let the field definition stand. Removing the green " took care of that problem.

Case(Monitor= "13", "Do This" , "Do That") works great.

If(Monitor="13", "Do This, "Do That") should also work.

By inserting the extra " into the formula, here's what it looks for:

If(Monitor= [color:"green"]"13" [color:"blue"]"," [color:"purple"]DoThis[color:"blue"] ","[color:"purple"] DoThat ")

With italicized comments, here's what happens with that extra quote mark:

If(Monitor= [color:"green"]"13" a text field with a comma[color:"blue"] "," a field called[color:"purple"] DoThis a text field with a comma[color:"blue"] "," a field called[color:"purple"] DoThat and an extra quote mark ")

Sorry about the colors. I was getting turned around while writing this, so the colors helped keep it straight.

If you want to use the " symbol in your text fields and compare two values, it may be best to compare two fields rather than to try to put the [color:"green"]13" into the formula. For example:

If(Monitor=Monitor2,"Do this", "Do that")

Good luck! smile.gif

Paul

Link to comment
Share on other sites

Sorry, Lee I was composing while you were answering my original (apparently less-than-accurate) post. I must not understand a convention;

Does """ function as a single quote? If so, do you still need to have an ending quote on the equation? confused.gif

In your example, Case(Monitor= "13""",

Do the second and fourth quotes encase the third one? If so, do you then need another quote to "close" the first one? Grrrr... Is there a growly graemlin?

Thanks for the explanation. If you could have a moderator remove the post (since it is unnecessarily long and, oh yeah, WRONG!), I'd appreciate it!

Paul

Link to comment
Share on other sites

This topic is 6493 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
 Share

×
×
  • Create New...

Important Information

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