Jarvis Posted March 21, 2009 Posted March 21, 2009 Is there a way to call a script from a field called "LAST SCRIPT"? I have a database that describes different products my cabinet shop makes. A lot of the initial design parameters are called via different scripts. I run a script then typically perform some other maintenance on the file, etc. When I am done with this maintenance I would like to be able to run the script again without having to select it from a drop down list. i.e. I would l like the computer to remember which script was last in play and run it again. I don't want to do this with the "pause" feature within a particular script. Is there a way to script a button to perform [color:red]GET(last script)? Thanks for any clues here. Jarvis
Fenton Posted March 21, 2009 Posted March 21, 2009 (edited) FileMaker itself does not have Perform Script [ script name as text ]. You must specify the script. Which would mean a series of IF tests. That would not be too terrible, if there were not that many scripts you wanted to call with this. It does have a Get (ScriptName) function. So you could have each script set its name into a global field. Then test for it to see which to run. Another method, on a Mac is to use AppleScript, in a Perform AppleScript FileMaker script step. AppleScript calls FileMaker scripts by name; in fact it can ONLY call them by name (so would break if you changed a script's name). do script FileMaker script "Some script name" You could set the script name into an AppleScript variable, then call it: set LastScript to field "_gScriptName" of table "Globals" do script FileMaker script LastScript The attached file does that. I included 2 scripts (doing the same thing) using AppleScript, to show the different methods of error capture. Either FileMaker or AppleScript can capture the error and show a dialog. In this case the AppleScript dialog is better, for a few reasons: 1. It can tell you the text of the error, not just the number. 2. It can go away after a set number of seconds. 3. It can have an icon :-] You would want a Startup script to clear the global script name, at least before you put it up on the network. [The Globals table is a 1-record table. We are referring to it by name, so its name must also not change. We are using "field" not "cell" because it is a global in a 1-record table. Other situations, using a regular data field, would require a different syntax.] ScriptLastRun.fp7.zip Edited March 21, 2009 by Guest
Jarvis Posted March 24, 2009 Author Posted March 24, 2009 Thanks Fenton, I think for now I will try the Get(Scriptname) function. My application has a fair number of scripts but calling them from a global field seems simple enough. I've always been curious about Applescript. Maybe in my next lifetime I will take that project on. Thanks for your help, Jarvis
Recommended Posts
This topic is 5724 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now