Own Gooooaaal!!!! ? AppleScripts within FileMaker

Hi scripters,

as far as I can see I shot myself into my foot by opening a FileMaker Database with FM 8.5 instead of FM 8.0 Advanced which I use usually.
By looking up some of the scripts and partly pasting them into the scripteditor I have the impression, that ‘tell application “FileMaker Pro Advanced”’ was replaced with ‘tell application “FileMaker Pro”’ which prevented some scripts within FileMaker to use the right fields/cells.

My question now:
a) Shouldn’t AS within FM use the right version automatically?
b) Is there a way to use a global as a substitute instead - in order to use always the correct version?

Hope I could make myself understood…

Any suggestions would be appreciated,

Thanks,

Andreas

Yes, you can specifically pick an application by setting it’s path and then referencing that… like so…

set appPath to ((path to applications folder) as string) & "Calculator.app"
tell application appPath
	activate
end tell

Nitpick: You’re getting an alias from path to and then coercing it to text; It’s slightly more efficient to use the as parameter of path to itself. Also, I’d use Unicode text instead of string unless you have a particular reason for it (string is depreciated as of AppleScript 1.9.2).

set appPath to (path to applications folder as Unicode text) & "Calculator.app"

Hi regulus,

this won’t work.
For example, this doesn’t compile

set F to "Finder"
tell application F
	get name of folder 1
end tell

to solve the problem, you need IMHO two separate scripts compiled once with Filemaker Pro and once with Filemaker Pro Advanced
and something like this to detect the current version

tell application "Finder"
	set pList to name of (get 1st file of (path to preferences folder) whose name begins with "com.filemaker")
	set FM to name of application file id (text 1 thru -7 of pList)
end tell
if FM is "FileMaker Pro Advanced.app" then
	-- run FMP Adv script
else
	-- run FMP script
end if

I understand, I’m performing 2 operations when it could be done in one. I’m glad you pointed it out.

Wow, I did not know that! I did a quick search and you’re right… “as unicode text” from now on! That should be a major headline on this website for all to see. FYI: see this document for the reasons.

I didn’t understand at first but searching turned up this explanation. I see now that any non-standard terms will cause a problem with my code.

:smiley: You two pounded me! That must have been the worst line of code I’ve ever written! :smiley:

Not at all. :slight_smile:
The problem is, that the compiler can only resolve the terminology,
if the tell application argument is a literal string,
or if the lines are wrapped in a using terms from application block.
However this block needs also a literal string for the application’s name

Wow folks!
You did a lot of work while “golden slumbers kissed my eyes”!
That’s really a great thread - and I learned a lot about the inner procedures of my Mac.
But… if I may say, I still have this gentle doubt if it would work within my FM construction.
There are a lot of scripts and if I would follow the ingenious proposals of Stefan there still might be the possibility that with a newer version of FM (or any other application) the alternatives would quickly be spent, exhausted {FM, FM Adv,} But what if they release FileMaker Superdooper 7.2} ? (Assumed I understood all correctly!)

The scripts are running within FM: so, isn’t there a way to store the current FM version into a global in FM and use the global like:
set FM to FMGLOBAL
tell application FM

end tell

I tried that, but until now I wasn’t sucessful…

Andreas

…and thanks to all for these fantastic comments so far!

I described in my latest post, why :wink:

Unless: tell application “FileMaker whatever” is inside another app’s tell block, it is unnecessary to tell FileMaker when you are running the AppleScript with a Perform AppleScript script step. It is implied. You can move any embedded tells within other apps tell blocks to subroutines.

My method is to write and test the entire AppleScript in Script Editor, then, when it’s working, copy/paste it into a FileMaker Perform AppleScript step, then comment out all the tell app “FileMaker whatever” steps. I keep the stand-along AppleScript also, for further editing; as it’s kind of a pain to edit AppleScript inside FileMaker.