Re: Something to watch out for...
Re: Something to watch out for...
- Subject: Re: Something to watch out for...
- From: Zachary Smestad <email@hidden>
- Date: Tue, 10 Feb 2004 18:19:55 -0600
Whoops! I meant to send this one to the mailing list, not just Gary.
I got the "cheap goto" line from my professor in a data structures and
algorithms class. He was talking about try-catch blocks in Java.
On Feb 09, 2004, at 10:15 PM, Gary Lists wrote:
Zachary Smestad wrote [2/9/04 7:08 PM]:
I've noticed that white-space characters become zeros when coerced to
numbers. For example:
tab as number
I've tried it on 10.3.2 and 10.2.8. I'm pretty sure this throws an
error in OS 9. Hopefully this saves someone from hours of frustration.
Zach
Hmmm. Someone spending their time trying to cast a tab-space into a
number,
perhaps...?
It does throw an error in OS9, and the error says, quite logically:
Can't make " " into a number.
If I ever saw that error, I'm pretty sure I wouldn't keep trying. :)
--
Gary
: )
Well, it did appear in a bigger chunk of code, like this:
set theString to "01/01/1980 00:01:32"
set endString to ""
repeat with theChar in (every character of theString)
try
set theNum to theChar as number
set endString to endString & theNum
on error
if (theChar = " ") then set endString to endString & theChar
end try
end repeat
return endString
I could not figure out why the space wasn't appearing, and my eyes
didn't catch the extra zero in there.
That is what I get for using try as a "cheap goto"!
Zach Smestad
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.