• 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
IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum


  • Subject: IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
  • From: Johnny AppleScript <email@hidden>
  • Date: Tue, 12 Oct 2004 11:19:19 -0600

Title: IS: Bug in String Coercions containing  Operators? -- WAS: Re: String to sum
I'm not suggesting this was a solution to the original question, but I'm curious about this approach I began to work out for fun. I'm sure there's a good reason listed somewhere as to why it shouldn't work for any instance listed here, but it comes across as a bug that prevents the latter two instances from working:

set theStrings to {"4 + 5", "4 * 5", "4 - 5", "4 / 5"}
set theResults to {}
repeat with i from 1 to number of items in theStrings
    
set theString to item i of theStrings
    
try
       set {operand1, operator, operand2} to {word 1, word 2, word 3} of theString
        
if operator is "+" then set theResult to operand1 + operand2
        
if operator is "-" then set theResult to operand1 - operand2
        
if operator is "*" then set theResult to operand1 * operand2
        
if operator is "/" then set theResult to operand1 / operand2
    
on error errMSG
        
set theResult to errMSG
    
end try
   set the end of theResults to theResult
end repeat
return
theResults
-->
{9, 20, "Can't get word 3 of \"4 - 5\".", "Can't get word 3 of \"4 / 5\"."}

Any comments?  -- (a curious)JA
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • IS: Re: String to sum -- WAS: Bug in String Coercions containing Operators?
      • From: Johnny AppleScript <email@hidden>
    • Re: IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
      • From: Johnny AppleScript <email@hidden>
References: 
 >Re: String to sum (From: Paul Berkowitz <email@hidden>)

  • Prev by Date: Mail.app plugin based on email address
  • Next by Date: Re: IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
  • Previous by thread: Re: String to sum
  • Next by thread: Re: IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
  • Index(es):
    • Date
    • Thread