Re: creating temp files??
Re: creating temp files??
- Subject: Re: creating temp files??
- From: Andrew Oliver <email@hidden>
- Date: Wed, 11 Jun 2003 20:48:40 -0700
Welcome, Chris.
>
How do I make a temp file (just needs to be plain old text)
-- create a file reference and open the file
-- This creates the file if it doesn't already exist
set fileRef to open for access file "path:to:filename.tmp" with write
permission
-- note the use of Mac OS-style pathnames
-- just to be sure, reset the file EOF so you're overwriting, not appending
set eof fileRef to 0
-- Write your data to the file
-- note: can be any AppleScript object, string, variable, etc.
write "some data" to fileRef
-- to force coercion to strings/text rather than AppleScript objects, add
'as string' to the command:
write 12345 to fileRef as text
-- note also you can use multiple write statements to continue to append
data to the file
write "more data" to fileRef
-- close the file when done
close access fileRef
>
the file is in a loop, so the file would either need to be deleted, or
>
over written each loop iteration.
The inclusion of the 'set eof' line resets the file's EOF, thereby
overwriting any existing file each time through the loop.
To be doubly safe, you can use the 'path to' command to find the system temp
directory (not necessarily /var/tmp :
set tempDir to path to temporary items
set tempFilename to tempDir & "myFilename" as string
set fileRef to open for access file tempFilename ... blah blah blah...
On 6/11/03 6:23 PM, "Chris Kacerguis" <email@hidden> wrote:
>
Hello All,
>
>
I'm a UNIX programmer (C++, Perl, PHP, etc) for a living, however I have
>
never used, seen, or written an AppleScript program...script...whatever.
>
>
So I decided to write a script, and for the most part I have figured out
>
how things work. However, I am writting a program that takes a variable
>
reads it into a temp file, then I need to know the file name and location,
>
then send that file name to a:
>
>
do shell script ("command <" & filename)
>
>
So my question is:
>
>
How do I make a temp file (just needs to be plain old text)
>
>
the file is in a loop, so the file would either need to be deleted, or
>
over written each loop iteration.
>
>
Can someone PLEASE help!
>
>
Thanks,
>
>
Chris
>
_______________________________________________
>
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.
_______________________________________________
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.