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:
Bill Steele <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Wed, 21 May 2003 16:58:28 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (55 lines)
>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