views:

503

answers:

2

I'm currently writing an applescript to be run within FileMaker. I need to tell filemaker what the name of its application is (FileMaker Pro or FileMaker Pro Advanced or whatever) so that I can within ANOTHER applescript within filemaker I can say "tell application filemaker"

I currently have a script that figures out the name of the app file, however, the problem is getting it back into filemaker. The name I want to send back is in the applescript variable "FMName" I can think of 2 options

1)

tell application FMName
   set cell "gFMName" of current record to FMName
end tell

The problem with this is that even though I know that application FMName will have a set cell command, applescript doesn't and so complains.

2) have the applescript either return a value or an error message and somehow get FileMaker to accept this and do something useful with it.

The problem with this is that 1)it appears that Applescripts can only return numbers (is this true?) 2) I don't want an error dialog or anything, and 3) I have not figured out how to get filemaker to accept this return value in the first place...

Anyone have any better ideas on how to do this?

Thanks!

+1  A: 

Since (if I understand you correctly) no matter what the application is that's being targeted, it's a version of FileMaker, whether FileMaker Pro or FileMaker Pro Advanced or even a runtime version of FileMaker, the dictionary being used will have the same terms available. So, you could use the using terms from application "FileMaker Pro" to enclose the block that you want to execute.

using terms from application "FileMaker Pro"
    tell application FMName
        set cell "gFMName" of current record to FMName
    end tell
end using terms from

I haven't experimented with it, so am not sure if it will work. It seems your goal is to get one FileMaker application to receive data from the AppleScript in another FileMaker application. I do wonder, however, why you're using two FileMaker applications. Are they different versions (i.e., FileMaker 10 and FileMaker 6)? If so, perhaps having the AppleScript write the data to a file that the second FileMaker application then imports is an option. But if they are both FileMaker 7-10, why not simply open the two files in the same application? Then you can write the data from AppleScript directly to the correct file.

Chuck
no, it's actually the same filemaker application. REALLY what I'm trying to do is get AppleScript to return data to filemaker. the easiest way we've come up with to do this is to have AS tell FM to set a cell to a value. And writing data to a file that FM imports is actually the current strategy that I'm using... AS writes the name of the application to a file which FM then reads... It's kind of messy though...
Brian Postow
Ah, then don't worry about the tell statement. If the AppleScript is embedded within a Perform AppleScript script step in FileMaker then any statements not directly targeted at an application will be targeted to the FileMaker application running the AppleScript. In my example above, all you need is the `set cell` statement. The `tell` statement is superfluous.
Chuck
Wait, really???? excellent. that's exactly what I needed!thanks!
Brian Postow
A: 

This was answered but I though I would add something I discovered lately. If you target another app, say the Finder, with a "Tell application Finder Activate" then those FMP calls will fail because your now IN the Finder till you do an "End Tell" or explicitly point back to FMP.

The solution that was pointed out to me was to do the out side calls in a single line such as

"Tell application Finder to [what ever you needed the Finder to do]"

This directs just that tell to the non FMP application but leaves you still IN FMP so your FMP calls will work.

This becomes an issue with runtimes since the runtime name will be different from your development application name.

ScottK