IS: Bug in String Coercions containing Operators? -- WAS: Re: String to sum
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