• 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
Re: Strange Error Reading File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange Error Reading File


  • Subject: Re: Strange Error Reading File
  • From: Andrew Oliver <email@hidden>
  • Date: Tue, 06 Apr 2004 10:38:33 -0700

On 4/6/04 8:24 AM, "David Crowe" <email@hidden> wrote:

>> If someone can explain why "open for access X" sometimes works when
>> "X" is a string, and sometimes gives an error (a misleading error at
>> that), I would appreciate it!

The short answer is it depends on whether the file already exists or not.

Open for access... with write permission is designed to create the file if
it doesn't exist.

If you pass it a string and the file does not exist, it is created.

If you pass it a string and the file already exists, it fails.

If you pass it a file (via 'file "path:to:file"') it always works, creating
the file if necessary, or opening the existing file if it's already there.

In other words, passing it a string will only ever work once if it works at
all.

Some would say the behavior of failing when you pass it a string when the
file exists is a bug.

Andrew
:)

> Richard;
>
> You seem to have identified the problem (you'd think I'd know by now,
> but I guess I was lulled by the fact that this usually works).
>
> "AFile" was passed to the function as a string. I've changed the
> function call to pass it as the alias instead of casting it to string.
>
> If that doesn't work I'll try using the keyword "file" in front of
> the value as string.
>
> (my gut instinct is that it's always better to remove words from a
> program than add them!)
>
> If someone can explain why "open for access X" sometimes works when
> "X" is a string, and sometimes gives an error (a misleading error at
> that), I would appreciate it!
>
> - David Crowe
>
>> From: Richard Morton <email@hidden>
>> Subject: Re: Strange Error Reading File
>> Date: Tue, 6 Apr 2004 10:17:05 +1000
>> To: ASUsers List <email@hidden>
>>
>> On 6 Apr 2004, at 12:51 AM, David Crowe wrote:
>>> ...I still don't understand the end of file error.
>>>
>>> It's not a timing issue because if the file is bad I can read it a
>>> second time and get the same error. And it's a mystery because if I
>>> download it again it almost always works and a comparison shows that
>>> the files are identical.
>>
>>
>>>> David Crowe wrote on Sat, 3 Apr 2004 11:47:39 -0700:
>>>>
>>>>> I am having strange errors reading small text files with Applescript.
>>>>>
>>>>> The code in question is:
>>>>>
>>>>> set ImportFileRef to open for access AFile
>>
>> If 'AFile' is a path string:
>>
>> "Mac HD:folder:file"
>>
>> Then it will work the first time but fail subsequently. The 'open for
>> access' command requires a file spec, so perhaps that is the problem.
>> Try this:
>>
>> set ImportFileRef to open for access file AFile
>>
>>
>> Cheers,
>>
>> IO
> _______________________________________________
> 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.
_______________________________________________
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.


References: 
 >Re: Strange Error Reading File (From: David Crowe <email@hidden>)

  • Prev by Date: Re: Quark - setting justification dynamically
  • Next by Date: Re: Strange Error Reading File
  • Previous by thread: Re: Strange Error Reading File
  • Next by thread: Re: Strange Error Reading File
  • Index(es):
    • Date
    • Thread