Re: Coercion from string to integer fails
Re: Coercion from string to integer fails
- Subject: Re: Coercion from string to integer fails
- From: Emmanuel <email@hidden>
- Date: Fri, 1 Jun 2007 01:03:26 +0200
At 4:52 PM -0400 5/31/07, Dan Doughtie wrote:
I have a script that reads in a preference from a text file.
The preference is basically the number of seconds since midnight.
I read the number from the file as text which makes it string.
I try to force it to an integer so I can do some math.
No matter what I do it fails and says it can't make "49900" into type
integer. (49000 being the text from the file).
My guess is, maybe you're reading a UTF16 file. I don't know how the
file got written: if it's with AppleScript and you're writing a
Unicode string, then by default you are writing a UTF16 file.
(Why are you skipping the first two bytes of the file?)
To know if you've got UTF16, try again with:
read theFile as Unicode text
and see if it works.
Emmanuel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden