Re: Lowlights of AppleScript 1.5.5 in Mac OS 9.1
Re: Lowlights of AppleScript 1.5.5 in Mac OS 9.1
- Subject: Re: Lowlights of AppleScript 1.5.5 in Mac OS 9.1
- From: Richard 23 <email@hidden>
- Date: Thu, 11 Jan 2001 18:12:24 -0800
>
> Anyone able to read a text file using delimiter return? (9.1)
>
>
>
> Where did my lists go?
>
>
Has anyone tried this yet. It broke my "essential" surfing script that
>
loads a list of urls from a text list, and goes to the next site when no
>
more windows are open.
>
>
Bummer.
>
>
Nate
Well the read/write thing has always been screwy so I've never written
anything that depends on it. I figured they'd eventually fix it, and
in doing so, would break my scripts which relied up it working (or
took advantage of side effects of its not working!)
If you're talking about a simple return delimited list it should be
easy as constructing a box-girder bridge.
It can't be that hard to replicate whatever result you need using
AppleScript's text delimiters instead.
To reduce the effort required to apply it to old scripts you can
simply redefine read with a command handler and sneak it into an
unsuspecting existing script.
The first handler is probably all you might need. Anything after
that's strictly for power users and other pointy-headed scripting
geeks....
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d2
-- ---------------------------------------------------------
return read "Private:testlog.mbug"
-- -----------------------------------------------
-- this one handler may be all you need,
-- acts like "read file using delimiter return"
-- -----------------------------------------------
on read fileRef
tell AppleScript
if fileRef's class /= integer then set fileRef to fileRef as alias
set {text item delimiters} to {return, read fileRef from 1}
set {text item delimiters} to {"", text items of result's end}
return result's end
end tell
end read
Extra crap for propellor heads and other freaks of nature:
----------------------------------------------------------
-- If you needed more than one kind of read command you can even
-- maintiain different call methods in separate script objects
-- (since AppleScript doesn't provide a way for lowly scripters
-- to specify optional parameters.
----------------------------------------------------------
set thePath to "Private:testlog.mbug"
tell Variation1 to read thePath using delimiter "e"
tell Variation2 to read alias thePath using delimiter "e" from 1 to 10
script Variation1
on read fileRef using delimiter theDelim
tell AppleScript
if fileRef's class /= integer then set fileRef to fileRef as
alias
set {text item delimiters} to {theDelim, read fileRef from 1}
set {text item delimiters} to {"", text items of result's end}
return result's end
end tell
end read
end script
script Variation2
on read fileRef using delimiter theDelim from sPos to ePos
tell AppleScript
if fileRef's class /= integer then set fileRef to fileRef as
alias
set {text item delimiters} to {theDelim, read fileRef from
sPos to ePos}
set {text item delimiters} to {"", text items of result's end}
return result's end
end tell
end read
end script
-- ---------------------------------------------------------
If you need any assistance be sure to ask the nearest wall... 8)
R23