Jump to content

Setting Field Formulas


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

Recommended Posts

The situation I have is an applescript that works in one db but doesn't work in a duplicate db. What the script does is set a text field showing the calculation used on a particular set of fields. I have checked and rechecked to make sure the script is the same in both db's. What am I missing?

The error I am receiving is:

Expected end of line but found identifier. (Error -2741)

Set Field Formulas FileMaker Script

Set Field ["gCounter", ""1""]

Loop

Perform Applescript [cApplescriptFieldDefinition"]

Set Field ["gCounter", "gCounter + 1"]

Exit Loop If [gCounter = 151]

End Loop

The following is the cApplescriptFieldDefinition field.

"tell application" & tquote & "FileMaker Pro" & tquote & "

Link to comment
Share on other sites

Your applescript looks fine to me. I use almost the identical one in a database documentor that I built. The only thing different is that you haven't specified a database. That may cause problems if the correct database is not active.

As a suggestion, you would probably find it easier to understand and debug if you set up a template script in a global field gScriptTemplate. Use merge fields for anything that will change like this:

code:


tell database "<<MyDatabase>>" of application "FileMaker Pro"

set fieldInfo to the formula of field "<<cExport>><<gCounter>>"

set cell "<<gFieldDefinition>><<gCounter>>" to fieldInfo

end tell


Then you don't have to mess around with all the quotes in special fields. You can even include indents to make it easier to follow. This also makes it way easier to revise the script as necessary. Most importantly, it looks just like the script that you will execute, so mistakes will be more obvious.

To execute it, just set the formula for cApplescriptFieldDefinition to:

Substitute(Substitute(Substitute(Substitute(gScriptTemplate,

"<<MyDatabase>>" ,"WhateverThisDatabaseIsCalled"),

"<<cExport>>",cExport),

"<<gCounter>>",gCounter),

"<<gFieldDefinition>>",gFieldDefinition)

Link to comment
Share on other sites

quote:

Originally posted by BobWeaver:

Substitute(Substitute(Substitute(Substitute(gScriptTemplate,

"<<MyDatabase>>" ,"WhateverThisDatabaseIsCalled"),

"<<cExport>>",cExport),

"<<gCounter>>",gCounter),

"<<gFieldDefinition>>",gFieldDefinition)

You can take this one step further by employing the Status(CurrentFileName) function in place of "WhateverThisDatabaseIsCalled".

Link to comment
Share on other sites

This topic is 8221 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.