Re: a script for saving text from the clipboard to a file
Re: a script for saving text from the clipboard to a file
- Subject: Re: a script for saving text from the clipboard to a file
- From: "Gary (Lists)" <email@hidden>
- Date: Tue, 28 Mar 2006 03:55:04 -0500
"Paul Berkowitz" wrote:
> On 3/27/06 7:20 PM, "Malcolm Fitzgerald" <email@hidden> wrote:
>
>> On 28/03/2006, at 12:47 PM, Diane wrote:
>>
>>> I am a newbie trying to make an Applescript to attach to a FileMaker
>>> button. I'm pretty stuck at this point. I have cobbled together a
>>> script that runs in Script Editor but seems unacceptable to FileMaker,
>>> which tells me "Expected end of line, etc. but found identifier." and
>>> will not save my clumsy script (below).
>>
>> This is your problem:
>>> write clipboard_contents to alias the_path starting at eof
>>
>> FMP defines WRITE in it's own dictionary and there is a clash because
>> you are wanting to use Standard Additions write command
>>
>> You need to use the raw applescript codes for that command.
>>
>> Standard Additions read/write
>> -- «event rdwrwrit» -- write
>> -- «event rdwrread» -- read
>>
>> «event rdwrwrit» clipboard_contents to alias the_path starting at eof
>
> A less cumbersome way to do it is to "farm" out the file writing to a handler:
>
> set f to open for access alias thePath with write permission
>
> tell app "FileMake Pro"
>
> set clipboard_contents to whatever
> my writeToFile(clipboard_contents, f)
>
> end tell
>
> on writeToFile(someText, f)
>
> write someText to f starting at eof
> end writeToFile
>
> Note that since you're writing to f outside an application tell block you also
> need to set f to open for access outside any tell block. Otherwise,
> AppleScript won't know what file you're talking about.
I would agree with Paul that it is still less cumbersome to call a handler,
but Paul, remember that the OP wanted to attach this action to some
FileMaker button. That implies that the script would be inside a FileMaker
Script step, "Perform AppleScript".
If that is what the OP wanted, then that context is always inside an imposed
(and invisible) tell block, so AS inside a FM script step that collides with
FM dictionary entries will be problematic, or at least require "some cumber"
in the process.
But, Diane (OP), you may wish to take Paul's advice anyway, and just include
inside the handler a specific application tell statement.
on writeToFile(someText,f)
tell app "System Events" -- or whatever, as appropriate
...
end
end
Further, Diane, but hopefully not to confuse you...
...you have a couple of other options for integrating AS into FM scripts.
One of these would be to get your script working, in an AppleScript
editor[*] and then when it behaves as desired, save it as an application and
then use the FM script step to simply call your (external) script.
This method may require more "looking after", since you'll have to make sure
the file moves along with copies of your DB and such. But, in some cases,
it can be the easier option.
If you'd need more answers before doing that, I'm sure the other FM-AS folks
here could help.
But, hopefully what you've gotten so far will get you up and running without
further thought about it.
--
Gary
[*] Smile is really very handy in this particular (with FM) case, because
Smile's applescript text windows can be turned into the same "context" that
your script experiences inside the FM script steps. That is, you can use
the 'tell target' feature to connect your script editor window to FileMaker,
and then the statements you execute in that window are inside the same
"invisible" tell wrapper.
I've found that, because of this and because of the overly tiny editing
space of FM script editor AppleScript input windows, Smile makes a
particularly useful tool for preparing and testing AS that is destined for a
FM 'perform applescript' script step.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden