开发者

Communication between applescript and FileMaker

开发者 https://www.devze.com 2022-12-16 21:12 出处:网络
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 withi

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 filem开发者_StackOverflow中文版aker 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!


I know this thread is a bit stale now, but here's what I do - use an if statement. Use the Get(ApplicationVersion) function to find out what kind of FileMaker is running:

If ( PatternCount ( Get ( ApplicationVersion ) ; "Advanced" ) ; 
"tell application \"FileMaker Pro Advanced\""   ; 
"tell application \"FileMaker Pro\""  )

I have taken this a step further and set it up as a custom function so I don't have it repeated in many different scripts.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号