Re: Read File Problems
Re: Read File Problems
- Subject: Re: Read File Problems
- From: Nigel Garvey <email@hidden>
- Date: Tue, 20 Mar 2001 01:20:15 +0000
Lyle Petro wrote on Mon, 19 Mar 2001 10:33:23 -0700:
>
Hi,
>
I would really appreciate some help with syntax problems I am having with
>
the read command. I would like to read a portion of a file into a list.
>
This list would be delimited by the return character. For example:
>
>
set chkFile to choose file
>
set fStart to 1
>
set fStop to 600
>
open for access chkFile
>
set fEnd to get eof chkFile
>
if fEnd < fStop then set fStop to fEnd
>
read file chkFile as list using delimiter "\r" from fStart to fStop
>
close access chkFile
>
>
I keep getting parameter errors with all variations of syntax. Am I
>
attempting the impossible using the Standard Read/Write addition?
Interesting that "\r" string. It actually compiles as a return. I didn't
realise that was possible in AppleScript.
The 'read' command can't make lists from partial reads of files - unless
this has changed in AppleScript 1.6 too.(See the thread "How to use
delimiters in Standard Additions file read/write".) You have to modify
the line like this:
set theText to paragraphs of (read fileRef from fStart to fStop)
In this case, the 'read' command just gets the 600 bytes of text and
AppleScript itself breaks up the text at the returns.
NG