What is preferable for running AppleScripts in FileMaker databases: field value or script text? The PERFORM APPLESCRIPT script step in FileMaker offers both options.
It seems that storing the Applescript code in separate global fields may be easier to work with when you are editing & testing code frequently. But then there are all those fields to mess with.
Perhaps the script text method of embedding the Applescript in the FMP script is faster?
Your opinions or experiences are appreciated.
And MANY THANKS to all of you who participate in these invaluable forums – I learn so much reading your posts. Mahalo!
I prefer to use a field to store the code because I can then create a layout for easy access to all scripts. One downside to this is that there’s no way to know if the script will even compile, so I usually do my debugging in a script editor and then paste the finished product into the FileMaker field for storage.
Another advantage of using fields to store the code is that it makes it easier to share common code among various internal scripts. This eliminates duplication and, since the common code is in one place instead of being scattered among many scripts, one change/fix applies to all. On a large project, this can add up to a huge reduction of development time.
I agree with Rob… Also, I think it shouldn’t be any difference between “embed” and “field”, since none of these methods compiles the script, but executes it on-the-fly…
I won’t swear to it but I’m almost sure that the embedded scripts get compiled. If I recall correctly, I’ve had errors in scripts and the window would refuse to close until I fixed the code. Then again, maybe I’m wrong.
Hmmm… Seems that you are true, Rob! :oops:
I’ve checked a database in a plain text editor and I’ve seen the typical AS’ headers (“FasdUAS”) and tails (“FADEDEAD”), apart from the plain text code…
But I would say that this is a “new” feature, or at least it was not present in FM 5 and earlier versions, where didn’t work this kind of code…
my kaka's who()
script kaka
property okk : "hola"
to who()
display dialog okk
end who
end script
Maybe some FM expert (Rob?) could confirm this? :rolleyes: