Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Ok i have read some of the other posts about geeting infomrationfrom/into cells in filemaker 7 and none of them seem to help!

tell app "Filemaker Dveloper 7"

tell database "mydb"

tell current record

set theone to cell "ONE" --this is on the visible layout so it returns a result

set thetwo to cell "TWO" -- this is not visible on the layout so "Object is not found"

end tell

end tell

end tell

Ok, so how can i get the value of cell "TWO" from the current record, when that field it is not visible on the layout. Just can't seem to get it to work! Any help very greatly appreciated.

Posted

Do not use the "tell current record" statement, use

set theID to ID of (current record)

set theone to cell "ONE" of record ID theID of table "table name"

set thetwo to cell "TWO" of record ID theID of table "table name"

  • 2 weeks later...
Posted

I find that this approach (specifying table name in script) does not work, but specifiying a layout containing the field does work. It would probably be cleaner code to specify a table rather than layout, so I would be interested into insight why h2o.be's approach doesn't seem to work for me. Does it work for others?

To be clear, I find that:

set theone to cell "ONE" of record ID theID of table "table name"

...won't even compile, but...

set theone to cell "ONE" of record ID theID of layout "layout name"

...compiles and works fine.

rrr

Posted

A few things. There's confusion because, from AppleScript, a FileMaker "table" is not a "base table," it is a Table Occurrence, one of the names on the Relationship Graph. Which make sense, because that is what the layout belongs to, not the base table (except indirectly).

set theTables to name of every table

Second point. If a script will not compile because of the word "table," it is possible that you have both FileMaker 6 & 7 on your computer, with the same name, possibly both open. The easiest solution is to quit 6 and rename the application with a 6 on the end. Of course, then your 6 scripts may need to be edited accordingly; but how often are you writing AppleScripts for 6 anymore B)-?

Lastly, some things should not be referenced directly from "database." Specifically, "current record" is not an object of "database."

It is an object of "window 1" (top window, default) or document "name of document" or layout "layout name" or current layout (default, therefore superfluous).

Or it can be directly under the tell application statement. But not under "database," because that refers to the file as a whole, and has different objects. Look at the containment hierarchy in the "Apple Events Reference.fp7" file, in English Extras folder (on mine), in the FileMaker application folder. It makes a big difference in 7.

As you noticed, if a cell is not on the current layout, then you need to reference where it is. This will work, but only if a window of that file is frontmost.

tell application "FileMaker Developer"

Posted

Fenton:

Thanks. This provides some good insight into understanding nuances of AppleScripting in FMP7 vs FMP6.

Let me ask you this... The majority (99%) of integration I do in FMP-based AppleScript (passing data in and out of FMP "cells"), is done on global fields in FMP, so the concept of "current record" is not especially important to me, as long as I am able to get/put data into a specific global field in the correct table occurence.

Based on that knowledge, what do you think would be the cleanest, most elegant (and generic and portable) way to write references to these global "cells" in AppleScript? Specifying a layout name on which these fields reside would be OK, I guess, but it would be ideal if I didn't have to worry about whether or not the file's window was frontmost, or about having to update layout names in AppleScripts when porting AppleScript code to similar files with different layout names.

Opinion?

rrr

Posted

I think the most generic way would be to keep such globals in one table (TO named "globals").* It needs to have at least 1 record. (I can't seem to get the global with AppleScript if there's none.) But you'd still need to hard-code the file name.

tell application "FileMaker Developer"

tell database "OpenSort"

set theText to cell "_gTest" of record 1 of table "Globals"

end tell

end tell

This phrase also works with the term document, but not if you're inside a different "tell layout" block (duh). If you keep the location and record reference on the end of each line you can mix these globals in with other layouts' cell references. Or put them outside such blocks.

(Which is what h2o.be was saying, that it's best not to start off with "tell current record".)

*These globals would have some functionality limits internally however. They'd be good for passing values, but no good for combining with regular fields to filter relationships, etc.. So I wouldn't put all my globals in there, but probably most. I like the idea. Many times I have the same global in 2 tables, and can't be sure whether I've set it yet, in complex (to me B)-) modular scripts (ie., with subscripts I can't see all at once); less of a problem in 7.

Posted

Again, thanks, Fenton.

I agree. A globals table for globals that are used for value passing is a great idea.

In testing your example script, I am back to my problem eariler in this thread. I simply can't get it to compile with the "table" qualifier in it.

Here is the code I adapted from your example:

tell application "FileMaker Pro"

tell database "test"

set cell "gText" of record 1 to "example data from applescript" of table "test"

end tell

end tell

When I try to paste this into FMP ScriptMaker's Perform AppleScript step, or try to compile this code in ScriptEditor, I get the following message:

Expected end of line but found

Posted

Yeah, try as I might, I just can't refer to tables with AppleScript.

The following script works as expected:

tell application "FileMaker Pro"

tell document "test" -- 'database' also works fine here in place of 'document'

set the_result to the name of every layout

end tell

end tell

But this script won't compile:

tell application "FileMaker Pro"

tell document "test" -- 'database' also fails here in place of 'document'

set the_result to the name of every table

end tell

end tell

Error message is: Expected class name but found application constant or consideration.

Help!

rrr

Posted

A couple things. First, AppleScript is much like English. What you've got there is in the wrong order. It would be:

set cell "gText" of record 1 of table "test" to "example data from applescript"

(of table "test") is the location of the cell and record, so it needs to follow them, not hang off the end after the text.

Also, when you're in a Perform AppleScript step you do not need the (tell "FileMaker Pro") and its (end tell) steps (unless nested inside another app's tell block). FileMaker is running the AppleScript itself, and it knows who it is. It's not an error, but it's not recommended.

Generally I leave the lines, but just comment them out. That way I can write and test the entire code in Script Editor, then comment them out and paste into a FileMaker Perform AppleScript step.

Posted

Yes, thanks. I do understand that the 'of table "Test"' needs to preceed the text. That was a misprint in my posting.

However, as I described in my following post, I am still unable to reference a "table" at all. If you have any comments on my post #150540, I'd be very interested. (Maybe it's a dumb oversight on my part that I'm overlooking, but I can't think what that would possibly be.)

rrr

Posted

I have FileMaker Pro 6 and FileMaker Developer 7 on my machine. If I run your script as is, "FileMaker Pro" 6 launches (because that's whose name is called by your script), and I get that error. You had "FileMaker Developer" in your earliest post. Which is your version 7?

It is possibly "a dumb oversight on my part that I'm overlooking"?

Posted

I am not the Original Poster of this thread. If you look back to the earliest post and the mention of "Filemaker Developer", you will see that the post is from another author.

I will do some testing on another machine to determine if I am running up against quirky version issues or if something else is at play, and report back.

Thanks

rrr

Posted

Sorry, mix up. But you were saying that it wouldn't compile with the word "table" or "tables". I've only seen this when version 6 involved, and it's hard to fix if both 6 and 7 are on the machine named the same thing.

  • 5 weeks later...
Posted

Hi its me again who orginally started this thread.

In the end i went for a slightly different option.

My solution in the end was this:

Create a new layout with all the fields of the database on it. Then, whenever i needed to write to a cell, i referred to this layout. This is not as elegant as the other method, but was far simpler for me when it came to adapting all the scripts. The changes are shown in red. Tell DATABASE also has to be changed to Tell DOCUMENT

tell app "Filemaker Dveloper 7"

tell [color:"red"]document "mydb"

[color:"red"] tell layout "ALL"

tell current record

set theone to cell "ONE" --this is on the visible layout so it returns a result

set thetwo to cell "TWO" -- this is not visible on the layout so "Object is not found"

end tell

[color:"red"]end tell

end tell

end tell

Hope this helps someone else!

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