returning the name of the application to the application

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!

Mac Mini, Mac OS X (10.6)

Posted on Jan 20, 2010 1:24 PM

Reply
13 replies

Jan 20, 2010 3:32 PM in response to Brian Postow

I don't have FileMaker, but you can use the path or bundle identifier in addition to an application's name, for example:
id of application "/Applications/TextEdit.app"
name of application id "com.apple.TextEdit"

When using a variable in a tell statement, you need to enclose it in a using terms from statement so that the *Script Editor* knows what application (on your machine) to get the terms from:
using terms from application "FileMaker"
tell application FMName
set cell "gFMName" of current record to FMName
end tell
end using terms from

Jan 21, 2010 7:22 AM in response to red_menace

If I knew the name to say "using terms from" then I wouldn't have to use the variable in the first place... although that's a useful idea for some other project I'm working on.

and again, if I know the bundle identifier, I wouldn't have to do any of this... The point is to tell FileMaker it's own application name/bundle ID, etc...

Current strategy is to write it to a file in /tmp and then have FileMaker read it into a field (which is a trial in it's own right...)

Jan 21, 2010 12:21 PM in response to Brian Postow

I am guessing that you have at least one of the FileMaker versions that you are wanting to script. If all of the different versions have a similar scripting dictionary, then you can just use what you have installed to compile the terms your script is using.

Similarly, if you know the bundle identifiers of the various versions you are wanting to script (for example, by getting them from the versions you have), you can use those to target the appropriate application independent of a name or path. Bundle identifiers are normally used when dealing with applications on other machines, since they will work even if the application has been moved or renamed by the user.

Sometimes the bundle identifiers are the same with different versions of an application, so in that case you could use the bundle identifier to target whatever application the user has installed.

Jan 21, 2010 1:20 PM in response to red_menace

All of the Filemaker flavors share the same (or same enough) dictionary. The problem is that I don't know the NAME of that dictionary, and so when I try to use it as a variable, it doesn't accept the call... I can't just compile it with my dictionary because then I'm not using a variable as the application target...

Also, I don't think that the different flavors use the same bundle identifier...

Jan 21, 2010 2:50 PM in response to Brian Postow

Hello

It seems you misunderstand the 'using terms from' statement.
It is a compiler directive to tell AppleScript compiler which application-specific terminology dictionany it uses at compile-time. It does nothing at run-time.

Provided you have application A1 and a user has application A2 and AppleScript terminologies of A1 and A2 are identical, you may write a script in your environment as follows, which will neither affect nor be affected by whatever the name A2 is :

set APPNAME to "A2"
using terms from application "A1"
tell application APPNAME
-- here's application specific code
end tell
end using terms from


However, there may or may not be particular requirement in writing AppleScript script run within FileMaker, that I don't know.

H

Jan 21, 2010 2:58 PM in response to Brian Postow

If the scripting dictionaries are more-or-less the same (the terms you are using are the same), just use the application you have - the Script Editor will use the terms from that application when compiling the script, but will send them to the application you target at run time.

If the bundle identifiers are different, that makes things a little easier, since you can trap the errors, for example:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #B5FF6C;
overflow: auto;"
title="this text can be pasted into the Script Editor">
try
set FMName to "com.whatever.FileMakerPro"
get application id FMName -- test
on error -- pro not found
try
set FMName to "com.whatever.FileMakerProAdvanced"
get application id FMName -- test
on error -- advanced not found
display alert "application not found"
return -- or quit
end try
end try

using terms from application "FileMaker" -- this is the application on your machine
tell application id FMName -- this will be the application on the target machine
get it's name -- the application name
set cell "gFMName" of current record to the result
end tell
end using terms from</pre>

Jan 21, 2010 3:45 PM in response to Brian Postow

Ah, then you'd need to use raw codes so that the compiler is not required to use the application-specific dictionary at compile-time.

Try something like :

set FMName to "FileMaker Pro" -- e.g.
tell application FMName
tell its «class pCRW»
set its «class ccel» "gFMName" to FMName
end tell
end tell

in lieu of :

set FMName to "FileMaker Pro" -- e.g.
tell application FMName
tell current record
set cell "gFMName" to FMName
end tell
end tell


Cheers,
H

Jan 23, 2010 2:15 AM in response to Brian Postow

Hello

Well, yes it should raise error when «class pCRW» object or «class ccel» object does not exist in the context at run-time.

But honestly I'm afraid I'm not quite following what you're trying to achieve here.
Now I'd presume you're using the code as source for 'perform AppleScript' step that is defined via ScriptMaker of FileMaker Pro. In such case, you can simply use 'tell current application' statement to tell whatever FileMaker Pro in the run-time environment if I'm not mistaken.

E.g.

tell current application
tell current record
set cell "X" to "Y"
end tell
end tell


H

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

returning the name of the application to the application

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.