ryankivi Posted May 27, 2014 Posted May 27, 2014 I have a script I would like to execute with a button click. The script works fine, but I would like to pass two variables into the script. I'm not sure how to do this, but I've been trying to use the Specify Calculation to do this. The following is the script: I would like to replace the fun and the 000000 with information from the database. Could anyone point me in the correct direction, or provide a hint for me. do shell script "osascript NewFromTemplatePlaceImage.scpt fun 000000" Regards,
ryankivi Posted May 27, 2014 Author Posted May 27, 2014 I've tried to use Set Variable [$variable ; ] but I get an error "The specified table cannot be found"
Wim Decorte Posted May 28, 2014 Posted May 28, 2014 FM scripts only take one parameter. But you can make that one parameter a return delimited list of your parameters. There are also a wide array of different approaches to tackle this. Here's one: http://www.modularfilemaker.org/2013/07/parameters/ 1
eos Posted May 28, 2014 Posted May 28, 2014 do shell script "osascript NewFromTemplatePlaceImage.scpt fun 000000" Try it like this: Set Variable [ $AS ; "do shell script " & Quote ( "osascript NewFromTemplatePlaceImage.scpt " & YourTable::fieldForFun & " " & YourTable::fieldFor000000 ) ] Perform AppleScript [ calculated: $AS ]
ryankivi Posted May 28, 2014 Author Posted May 28, 2014 Thank you for the help. When I try and save this it gives me the same message: The specified table cannot be found, and it highlights "Set Variable"
ryankivi Posted May 28, 2014 Author Posted May 28, 2014 The only relationship I have setup is an order number field between two tables.
comment Posted May 28, 2014 Posted May 28, 2014 I've tried to use Set Variable [$variable ; ] but I get an error "The specified table cannot be found" Set Variable[] is a script step. The error you show is a calculation syntax error. You cannot type script steps into a formula - that just makes no sense. I would like to replace the fun and the 000000 with information from the database. Could anyone point me in the correct direction, or provide a hint for me. do shell script "osascript NewFromTemplatePlaceImage.scpt fun 000000" What exactly is the Filemaker script step that you are calling here?
ryankivi Posted May 28, 2014 Author Posted May 28, 2014 Well I'm clearly confused. I have a button that I want to trigger the script above. This script needs a few items of information from the FileMaker tables to function. I have created a button and when setting it up I have chosen the perform applescript script option. Then I am presented with 2 options. 1.) Calcuated Applescript 2.) Native applescript I've tried to use both, but maybe I'm totally down the wrong path. Sorry for my ignorance.
eos Posted May 28, 2014 Posted May 28, 2014 Please read up on the difference between Script steps and calculations, and how they work in tandem. If you attach a script to your button you can define several steps; one of these could be a Set Variable[] step that calculates the AppleScript code, the next one the Perform AppleScript[] step that also uses a calculation – but this calculation is then simply a reference to the previously defined variable and returns its (the variable's) value, i.e. your code. As shown above: Set Variable [ $AS ; "do shell script " & Quote ( "osascript NewFromTemplatePlaceImage.scpt " & YourTable::fieldForFun & " " & YourTable::fieldFor000000 ) ] Perform AppleScript [ calculated: $AS ] If you attach a step directly to a button, you can only perform this one single step; so you need to select the Perform AppleScript[] step, and – since now you have no intermediate Set Variable[] – calculate the result (.i.e the code) directly in the Edit dialog you get when you click the “Calculated AppleScript” option. Perform AppleScript [ calculated: "do shell script " & Quote ( "osascript NewFromTemplatePlaceImage.scpt " & YourTable::fieldForFun & " " & YourTable::fieldFor000000 ) ] Maybe it is a bit confusing …
ryankivi Posted May 28, 2014 Author Posted May 28, 2014 Wow thanks eos! Finally I see some progress. If I want to use the values from a selected portal row, how would I designate that instead of the table entries?
eos Posted May 28, 2014 Posted May 28, 2014 If by “selected” you mean “the portal row I click a button in“, then you can simply refer to the fields from the TO of the portal (actually, the relationship branch …); as an illustration: On an Orders layout, clicking a button (entering a field) in row #2 of a line items portal lets you refer to that related record; so LineItems::qty returns 6, and LineItems::priceExtended 4.20, while #3 would give you 4 and 6, respectively (and the total is a bit more complicated ). You get the drift … Order # 283,376,492 Product qty ext. --------------------------------- Portal to go 4 3.20 Variables (local) 6 4.20 Relationship de jour 4 6.00 Functions (custom) 5 5.75 ---------------------------------
Recommended Posts
This topic is 3923 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