Re: Creating new file etc
Re: Creating new file etc
- Subject: Re: Creating new file etc
- From: Malcolm Fitzgerald <email@hidden>
- Date: Fri, 13 Apr 2007 14:22:34 +1000
On 13/04/2007, at 1:15 PM, Gregory White wrote:
Dear List, I would be very grateful for any help you could give me as
I've been struggling with it for a few days.
I'm trying to create a new file in the given directory and then
replace old data with new data should that be required.
I will get that data from the clipboard as it originates in another
app. The data will be text.
Kind regards,
Greg.
Here is the script which does not work.
copy (the clipboard) to Clip_Board -- don't use the finder unless you
must
-- get the actual path to your documents folder
set Bookmaker_Folder to (path to documents folder from user domain as
Unicode text) & "ReferenceWorks Bookmaker:"
set this_Book to Clip_Board --
set this_file to ((Bookmaker_Folder as text) & "New Book")
my write_to_file(this_Book, this_file, false)
set this_data to this_Book
set target_file to this_file
set append_data to false
on write_to_file(this_data, target_file, append_data)
try
-- set the target_file to the this_file as text -- this line is not
required and it is causing problems
-- no such variable as this_file inside this subroutine, so we error
-- you've already got that data AND it's already stored in target_file
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden