MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"John A.M. Darnell" <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 21 May 2003 17:35:10 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (96 lines)
Bill:

   After some agonizing testing I figured out that what happens is that
even though the documentation says that a READ...BEFORE command does not
read in the delimiter, the fact seems to be that it does, and then
discards it (i.e. does not provide it to the program).

   Unfortunately the file is potentially huge (the biggest one on record
is 127k) so I have to take the data a chunk at a time.

   I solved my problem by making an assumption that wherever I find a  XX$
at the front of the buffer immediately following a read delimited by "$"
then I can assume that a dollar sign preceded the XX$.  As this is a
proprietary markup language used in house, I feel good about that
assumption.
R,

John A.M. Darnell
Software Development
In honor of THE MATRIX RELOADED:
In the first movie, close to the climax, Keanu Reeves and Carrie Ann Moss
take a harrowing express ride up an elevator by explosively disconnecting
the counterweight.  Just before activating the detonator, Reeves says
something.  What was it that he said?





Bill Steele <[log in to unmask]>
Sent by: Macintosh Scripting Systems <[log in to unmask]>
05/21/2003 03:58 PM
Please respond to Macintosh Scripting Systems


        To:     [log in to unmask]
        cc:
        Subject:        Re: Where goes the "$"?


>Hello fellow Scripters:
>
>         Spam vs Ham aside, Applescript is doing something that I quite
>don't understand.  I have a small script looking like this:
>
>set FileName to "Macintosh HD:source code:Applescript
>Convert:TestScripts:Example 2" as alias
>
>set FileHandle to open for access FileName without write permission
>
>set buf to read FileHandle until return
>display dialog "|" & buf & "|"
>
>set tempbuf to read FileHandle before "$"
>display dialog "|" & tempbuf & "|"
>
>set tempbuf to read FileHandle before return
>
>display dialog "|" & tempbuf & "|"
>close access FileHandle
>
>
>The actual file from which data is being read looks like this for the
>first, say five lines:
>
>$$17$Y211419.003A$07$B$00410000$011208$
>
>$20$
>[TB1,48.0,48.0,516.0,276.0][LD14][RR][NH][LYNN][PS10][BF]This is
>page [SPGN][EBF].  Page size is 7.  A vermilion moon hung gibbous
>
>The first and second DISPLAY DIALOGs perform as expected, the first
>displaying the very first line of text and includes the RETURN character,
>the second displaying only a return character.  The third DISPLAY DIALOG,
>however, displays only a "20$" regardless of whether I am using READ
>BEFORE or READ UNTIL.
>
>I really, really need that dollar sign in the data that precedes the
"20."
>  Can anyone suggest a remedy?
>

No idea why it's doing that, but, unless the file is gigantic, it may
work better to read in the whole thing and process it inside
Applescript. Like maybe

repeat with onePar in paragraphs of Filehandle
(do whatever you want with each line)
end repeat

Gets rid of the returns and you can just play with your dollar signs.
--

Bill Steele
[log in to unmask]

ATOM RSS1 RSS2