Re: [NEWBIE] Open file
Re: [NEWBIE] Open file
- Subject: Re: [NEWBIE] Open file
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 05 Nov 2002 10:10:58 -0800
On 11/5/02 9:40 AM, "Stiphane Pinel" <email@hidden> wrote:
>
I'm not sure to be clear:
>
>
I don't want to launch a file from a script but get a ref to it so I'm able
>
to read/write in the file.
Ah, that wasn't clear. Then just avoid the Finder:
set myPath to (path to me as string) -- use (path to me) as Unicode text
in AS 1.8.3 and later for non-European filepaths included
set AppleScript's text item delimiters to {":"}
set myFolderPath to (text items 1 thru -2 of myPath) as string & ":"
-- again 'as Unicode text' if AS 1.8.3 or later
set AppleScript's text item delimiters to {""}
try
set myTextFile to alias (myFolderPath & "myfile.txt")
on error
beep
display dialog "You have no such \"myfile.txt\" file in the same
folder as this script." buttons {"OK"} default button 1 with icon 0
return
end try
set fileRef to open for access myTextFile with write permission
--set eof fileRef to 0 -- to overwrite
write "any nonsense" to fileRef -- starting at (get eof fileRef) -- to
append
close access fileRef
--
Paul Berkowitz
_______________________________________________
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.