I have a script that saves a text field from filemaker to a text file. Currently it is saved as text with a .txt extension.
I wish to have the script save the text as .rtf. I can see how to change the file extension, but I don't know how to do the rest.
Any help would be greatly appreciated.
Greg.
tell application "Finder"
set homeFolder to (home)
set D_folder to folder "Documents" of homeFolder
end tell
tell application "Finder"
if not (exists folder "ReferenceWorks Bookmaker" of D_folder) then
make new folder at D_folder with properties {name:"ReferenceWorks Bookmaker"}
end if
end tell
tell application "FileMaker Pro Advanced"
set {fileName, this_Book} to {get data of cell "FileName" of current record, get data of cell "CompleteBook_cc" of current record}
end tell
set homeFolder to path to home folder as Unicode text
set BookmakerFolder to homeFolder & "Documents:ReferenceWorks Bookmaker:"
set this_file to BookmakerFolder & fileName & ".rtf"
-- I have chaned the .txt to rtf.
my write_to_file(this_Book, this_file, false)
on write_to_file(this_data, this_file, append_data)
try
set the target_file to the this_file as text
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
«event rdwrwrit» this_data to the open_target_file starting at eof -- call "write" using raw code: «event rdwrwrit»
close access the open_target_file
return true
on error errMsg number errnum
display dialog errMsg & return & errnum
try
close access file target_file
end try
return false
end try
end write_to_file