Re: get eof real?
Re: get eof real?
- Subject: Re: get eof real?
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 26 Sep 2003 08:44:00 -0700
On 9/25/03 9:19 PM, "David Crowe" <email@hidden> wrote:
>
I'm executing the following AppleScript code:
>
>
set theFileSize to (get eof FileRef)
>
display dialog "theFileSize=" & theFileSize & ", class=" &
>
(class of theFileSize) as string
>
>
>
>
.... and the class of "theFileSize" comes up as "real". I understood
>
that "get eof" returned an integer.
>
>
Can anyone explain this. As far as I can tell the variable
>
"theFileSize" is not involved in any calculations that might return a
>
non-integer result.
Check the dictionary:
get eof anything -- a reference number, alias, or file reference of a file
that has been opened for access
Result: double integer -- the total number of bytes in the file
'double integer' is a real. It means it's a floating point, a 'double', not
a standard integer.
Files can be enormous. The number of bytes in a file can exceed the limit
for integer, so this way it's still possible to get eof, since the limit for
'double integer' is that of a real - if there even is one. Floating point
numbers may sometimes be represented as fractional when they get large
enough, since they're not decimal.
Some else will have more detail on these limits. The limit for integer seems
to be (2 ^ 29) - 1 whereas I don't know what the limit is on doubles/reals:
2 ^ 128 is still OK, for example, on a G3. I'm not even going to try it on
my G5...
You can just coerce your result 'as integer' which will work fine until you
hit 2 ^ 29. You may want to use a try block.
--
Paul Berkowitz
_______________________________________________
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.