Jump to content
Server Maintenance This Week. ×

Button Script with a variable


This topic is 3625 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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,

Link to comment
Share on other sites

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 ]
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 …  :turned:

Link to comment
Share on other sites

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
---------------------------------
Link to comment
Share on other sites

This topic is 3625 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.