• 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: AppleScript and FileMaker problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript and FileMaker problem


  • Subject: Re: AppleScript and FileMaker problem
  • From: "Gary (Lists)" <email@hidden>
  • Date: Wed, 29 Mar 2006 12:12:01 -0500

"Dale J Martin" wrote:

> Hi all,
>
> I'm having a bit of a problem here with getting data into the correct
> FileMaker database. I have two database files open and I'm using the script
> below which states to use the database  "weather.fp5" but for some reason if
> the second database is the front most window it tries to use that one. I'm
> using FileMaker 6 with 10.4.
>
> Any thoughts .... one of the versions of the script is posted below.
>
>
> tell application "FileMaker"
> activate
> try
> activate database "weather.fp5"
> on error
> open "weather.fp5"
>
> end try
> set theRecord to create new record
> set cellValue of cell "Bar" of the theRecord to Bar
> set cellValue of cell
> "Temp_out" of the theRecord to Temp_out
> set cellValue of cell "Hum_out" of the
> theRecord to Hum_out --and so on


Dale, you're not alone in frustration over FM's AS caveats in FM 6.

Getting a lock on the correct DB is crucial, of course, but you'll have to
implement some checks yourself, just to make sure you've "got tow".

The key FM dictionary entries you'll want to review are:

exists [some object]
go to [some object]
show [some object]

Also, keep your eye out for error -1728, "Object not found."

It's relevant to note that FM does not need the correct (target) database to
be frontmost in its window order. (Or layout either.)(Although humans tend
to like that.)


TERMINILOGY refresher:

'show' -- show it, if possible, in the window where it is, but do not change
the layering of the window; 'show layout 2 in database 2' does not make
database 2 "frontmost", but it does show the layout, in the window, in the
background...it's now the active layout if you were to talk to that
window/document/database

'go to' -- is like "show, and bring forward"


Since I am a bit rusty on FM 6, I _did_ fire up Classic and FM 6 and test
the code fragments shown below. I hope this helps.


TO MAKE SURE SOME WINDOW IS OPEN (FOR YOUR SCRIPT, WHETHER FRONT OR NOT):

[this will not 'front' the window, just show it, as if maybe it had been
hidden with "Hide Window" menu, or some FM script]

    show database "some-other-file-b"


You can even show a particular layout, which makes it active for 'new
record' and other data requests...

    show layout 1 of database "some-other-file-b"
    show layout "weather" of database "some-other-file-b"


TO BRING SOME WINDOW TO THE FRONT (VISIBLE TO HUMANS):

    go to database "some-other-file-b" -- brings forward

-- or

    go to layout 1 of database "test-file-a"
    -- brings forward, and switches to that layout


TO VERIFY THAT THE CORRECT DATABASE IS OPEN:

Method I): go to

try
    go to database "blah"
on error msg number nbr
    -- [-1728] Object not found
    if nbr is -1728 then display dialog "Oops!" & return & nbr & "=" & msg
end try

Method II): exists

-- use 'exists', which does not error, but returns false
-- this is the method I find most useful

if (not (exists database "some-file-a")) then
    doSomeOpening() -- some fictitious handler
else
    doThis() -- or whatever
end if

Method III):  show

try
    show database "blah"
    -- or
    -- show database 17
on error msg number nbr
    -- [-1728] Object not found
    if nbr is -1728 then beep
end try



Remember that 'record' behaves the same as other objects. That is, you can
reference it without "seeing it" (with your eyes).  And, if you do not "go
to" it, then you will inadvertently set the data of the wrong record.

A example of a common problem (that you would have seen in your code, once
you got to targeting the correct file):

    create new record at end of records -- fine
    set cell "someFieldB" to "Harry" -- oops

This changed the value of data of the first record, not the new record you
just made!

You need to:

    go to database "some-other-file-b"
    go to layout 2
    go to (create new record at end of records)
    -- this makes, and target, and displays the new rec
    -- ...continue on your way

That should get you further along.

--
Gary

P.S.

You can say

    set cell "some-field" to "This value"

rather than

    set cellValue of cell "some-field"...



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >AppleScript and FileMaker problem (From: Dale J Martin <email@hidden>)

  • Prev by Date: Re: GUI scripting without permission
  • Next by Date: re: AppleScript and FileMaker problem
  • Previous by thread: AppleScript and FileMaker problem
  • Next by thread: re: AppleScript and FileMaker problem
  • Index(es):
    • Date
    • Thread