• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: FileMaker 8 "create new record" again....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FileMaker 8 "create new record" again....


  • Subject: Re: FileMaker 8 "create new record" again....
  • From: kai <email@hidden>
  • Date: Sun, 12 Nov 2006 17:12:37 +0000


On 11 Nov 2006, at 04:03, David Crowe wrote:

The following code, running against a database file that has two tables, "Table1" and "Table2" creates a record in "Table1" when the current layout shows that table and the following code is executed:

tell application "FileMaker Pro Advanced" to tell database "Test" to tell table "Table2"
create new record
end tell


Yet, the following code, which I would think is equivalent, does the 'right' thing and creates a record in Table2 as specified:

tell application "FileMaker Pro Advanced"
       create new record in table "Table2" of database "Test"
end tell

Any explanations?

Just a general observation really, David.

A tell statement specifies the default target (the object to which a command is sent if a direct parameter is omitted). In the case of a partial reference (one that doesn't specify every container of an object), AppleScript normally tries to use the default target to complete it.

So something like this...
----------------
tell application "Finder"
	activate
	open {trash, home}
	tell window 2 to close
end tell
----------------

... is interpreted as:
----------------
tell application "Finder"
	activate
	open {trash, home}
	close window 2
end tell
----------------

However, some application commands (make/create, move, duplicate, etc.) include a parameter (in/at/to) to explicitly reference a target location. If that parameter is omitted, the application may either return an error - or use the default object for the command in question. In the case of FileMaker's 'create' command, the default is evidently influenced by the current layout. In Finder, 'make' defaults to the desktop (though originally, IIRC, to the current insertion location), while 'duplicate' uses the same container as the original object. Since Finder's 'move' requires an explicit target location, its omission will result in an error [number -10010: errAECantHandleClass].

OK, that's probably more than you wanted to know (and may be inviting further caveats/comments). But what it boils down to is that, with such commands, it's generally safer to explicitly specify the location reference. (An exception might be where one knows there's a default object, understands what it will be in a given situation - and deliberately intends to target it.)

So while your examples might *seem* equivalent, the significant difference between them is that only the second uses the 'in' parameter to specify the location reference.

Using Finder again to demonstrate, the following should create a folder on the desktop:
----------------
tell application "Finder" to make folder
--> folder "untitled folder" of folder "Desktop" of folder "username" of folder "Users" of startup disk of application "Finder"
----------------


In spite of including an additional application object in a nested tell statement, this does something very similar:
----------------
tell application "Finder" to tell folder (choose folder) to make folder
--> folder "untitled folder 2" of folder "Desktop" of folder "username" of folder "Users" of startup disk of application "Finder"
----------------


However, since this uses the 'at' parameter to specify the target location, that's where the new folder is created:
----------------
tell application "Finder" to tell folder (choose folder) to make folder at it
--> folder "untitled folder" of folder "chosen folder" of folder "Desktop" of folder "username" of folder "Users" of startup disk of application "Finder"
----------------


All of which is a rather long-winded way of suggesting you try something like this as an equivalent form:
----------------
tell application "FileMaker Pro Advanced" to tell database "Test" to tell table "Table2"
create new record in it
end tell
----------------


---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden
References: 
 >FileMaker 8 "create new record" again.... (From: David Crowe <email@hidden>)

  • Prev by Date: Re: Icon Files - Where?
  • Next by Date: Re: FileMaker 8 "create new record" again....
  • Previous by thread: FileMaker 8 "create new record" again....
  • Next by thread: Re: FileMaker 8 "create new record" again....
  • Index(es):
    • Date
    • Thread