• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: weird comparison problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: weird comparison problem


  • Subject: Re: weird comparison problem
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Mon, 26 Feb 2001 13:09:56 -0500

> Date: Mon, 26 Feb 2001 17:38:45 +0100
> From: Robert Brenstein <email@hidden>
> Subject: weird comparison problem

> set tplSource to text of characters 5 thru (length of htmlTemplate) of
> htmlTemplate

The above should return a string.

> set n to the number of items in fieldNames

Where do the fieldNames come from?

> if item j of fieldNames is tplSource then -- !!!!!

> This produces the following output
> -payment- is not -payment- <<<<<<<<<<

> NOW, if I change "is" to "begins with" *or* to "ends with" in the line
> marked with !!!!s then the condition is met and I get:
>
> payment is payment

Good, this is a clue. Equality will often fail in AppleScript because
the operands are of different types. In these same situations, "begins"
or "ends with" DO work, because these operators seem to force an implicit
coercion that the equality operator does not.

Try this:

if (contents of item j of fieldNames) = tplSource then

If that doesn't work, try this:

if item j of fieldNames = (contents of tplSource) then

or maybe this:

if (item j of fieldNames as string) = tplSource then

Basically, you need to ensure that both "things" are of the same
type.


Arthur J. Knapp
http://www.stellarvisions.com
mailto:email@hidden

Hey, check out:
http://www.latenightsw.com


  • Prev by Date: Persistant Properties
  • Next by Date: Re: random scatter
  • Previous by thread: Re: weird comparison problem
  • Next by thread: Re: weird comparison problem
  • Index(es):
    • Date
    • Thread