• 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: email@hidden
  • Date: Mon, 26 Feb 2001 14:51:19 EST

Robert,

I recently brought this subject up. Basically, you must coerce to a string,
then do the comparison, so

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

should be

if (item j of fieldNames) as string is equal to tplSource as string then

However, there are a few other improvements your snippet can use

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

should be

set tplSource to text 5 thru -1 of htmlTemplate

which is faster, shorter, easier to read.

Other suggestions would depend on the big picture of what you are trying to
achieve.

How are you parsing the post_args? I recommend Tanaka's osax.

Jeff Baumann
email@hidden
www.linkedresources.com

14 Days, 2 Hours, 55 Minutes
How is it going to end?


In a message dated 2/26/01 11:12:42 AM, Robert Brenstein wrote:

>I have a script (this is a debug version) as part of my AppleScript-based
cgi:
>
>set tplSource to text of characters 5 thru (length of htmlTemplate) of
>htmlTemplate
>set n to the number of items in fieldNames
>repeat with j from 1 to n
> if item j of fieldNames is tplSource then -- !!!!!
> if item j of fieldContents is "" then
> set theResult to theResult & item j of fieldNames & " is " & tplSource &
>return
> return formatError(htmlTemplate & " refers to empty token (" & tplSource
>& ")")
> else
> set theResult to theResult & item j of fieldNames & " is " & tplSource &
>return
> set htmlTemplate to item j of fieldContents
> set tplSource to ""
> exit repeat
> end if
> else
> set theResult to theResult & "-" & item j of fieldNames & "- is not -" &
>tplSource & "-" & return
> end if
>end repeat
>
>This produces the following output
>
>-to_address- is not -payment-
>-subject- is not -payment-
>-from_address- is not -payment-
>-required_institute- is not -payment-
>-required_address1- is not -payment-
>-required_address2- is not -payment-
>-required_country- is not -payment-
>-required_phone- is not -payment-
>-payment- is not -payment- <<<<<<<<<<
>-Submit- is not -payment-
>-cgi_version- is not -payment-
>-client_ip_address- is not -payment-
>
>The problem is that the line marked with <<<< fails the comparison (marked
>with !!!!) even though the strings on both sides are identical. I checked
>for invisible characters but can't see anything. I added the "-" to visibly
>delimit the text.
>
>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
>
>But I need to check for equal! Anyone any ideas?
>
>Robert


  • Prev by Date: Re: Scripting icon copying: Finder barfs - howcome?
  • Next by Date: Good book to learn AppleScript?
  • Previous by thread: Re: weird comparison problem
  • Next by thread: Re: weird comparison problem
  • Index(es):
    • Date
    • Thread