On Apr 16, 2007, at 4:38 PM, Charles Hartley wrote:
I need, within a FM script, to capture the contents of a FM6 field
and paste it into a text file (BBedit or TextEdit) at the end of
the current contents of that file using Applescript.
You might want to consider writing it directly to a text file using
command line, rather than any particular application. It will then
open by default with TextEdit; though you could set its creator code
to BBEdit's if you want (R*ch).
You'd do this within a Perform AppleScript step.
First you'd set the FileMaker field (cell) data into an AppleScript
variable.
Then use a simple command line command to read it, echo. By default
it adds a new line character at the end; but this can be suppressed
with the -n option. To append to a file you use the redirect symbol, >>
Assuming the field is named Text_, you can create and append to a
file on your Desktop named Test.txt (the tilde ~ is short for your
Home folder, which is where your Desktop is):
set theLine to cell "Text_" of current record
do shell script "echo " & theLine & " >> ~/Desktop/Test.txt"
If you do not want the last line to have an extra return, you could
suppress it this way:
set theLine to cell "Text_" of current record
do shell script "echo -n " & theLine & " >> ~/Desktop/Test.txt"
So the FileMaker script would look like:
Commit Record
Go to Record [ First ]
Loop
If [ Get ( RecordNumber ) ≠ Get ( FoundCount ) ]
Perform AppleScript [ the 1st one above ]
Else
Perform AppleScript [ the 2nd one above, suppressing the extra return ]
End If
Go to Record [ Next, exit after last ]
End Loop
(P.S. the file path could also come from, or be constructed from
fields in FileMaker.
Fenton Jones
FileMaker Development
1728 Meade Ave
San Diego, CA 92116
619-692-1529
http://fentonjones.com