FileMaker and DataBase EVents
FileMaker and DataBase EVents
- Subject: FileMaker and DataBase EVents
- From: Jason Bruce <email@hidden>
- Date: Tue, 15 Jun 2010 12:51:53 -0700 (PDT)
Hi Ed,
You're trying to "play" the interface rather than do it the AppleScript way. If your data is text data in a regular format -- as you know -- you can parse that with AppleScript's text item delimiters, which is also -- as you know -- very fast. Read all the data in as text to variable "foo", set AppleScript's TIDs to the delimiters which separate each record, and then set a list "bar" to "text items of "foo" -- walla-- you've got your list which you can iterate thru to create records in FMP. Now, repeat with loopvariable in bar -- set TID's to the delimiters which delimit each field of each record in loopvariable -- and set foobar to text items of loopvariable -- walla -- you've got the data ready for each FMP record. Test the number of items of foobar to see if it's a TV show or a movie. If count of text items is 10 (a TV show), go to layout "TV Show" (layout with only fields needed for tv show) and create a new record with data foobar; If it's
movie data, go to layout "Movie" (layout with only fields needed for movie) and create a new record with data foobar. Also, freeze the window so the interface doesn't update during all of this, and put the script in a "perform applescript" FileMaker script step -- which you can call from a regular Applescript script by saying do script filemaker script "Process TV Data" or something to that effect. This shouldn't take long and should be only a few lines of AppleScript.
To get your data out of FMP, you can get all of the records at once in one command from FMP which will give you a list of lists of text. Add a field in FMP which indicates whether the record is a TV show or movie. Say you get a list of 3000 items. Each item has 20 fields. Movies use fields 1,5, 6, and 10 - 20. TV shows use fields 1,2,3,4, 6-10, and 11. When you loop thru each item, you test text item 1 to see if it is a movie or tv record. If it's a movie, create a database events record from items 1, 5, 6, etc. of loopvariable. If it's a tv show, create a database events records with items 1,2,3,4 etc. of loopvariable.
Don't fight FileMaker. It's tailor made for this very thing -- which is why you will often see it demonstrated in AppleScript workflow examples -- particularly in the publishing industry -- which is why I'm a bit surprised that you're not more comfortable with it.
By the way, you can create an AppleScript script on the fly by setting a global field to a valid AppleScript text and calling the "perform applescript" scriptmaker script by telling the scriptmaker script to use this global field as the source of the Applescript.
HTH
The data is tv listings in a pipe
> delimited format. It data on every program airing on a list of about 100
> channels. The data comes in files separated by day of week.
Each day's
> file starts with data for shows beginning at 6 am and through shows that begin
> at 5:45 am the following day.
The fields in the data for movies and
> sports are different than the fields for all other programs.
The data
> needs to be manipulated to include date; timeslot (half-hour start); end time
> and each pipe delimited field must have needs to have it's own field in
> Filemaker. (see below)
The Database events side uses the same data, but
> we do not need to populate every field on a one to one basis.
The purpose
> is to for a script to access all the listings for a particular channel for a
> specified time period, and parse them to give insert into an indesign document
> at runtime.
At runtime a user makes a selection from the table, activates
> a script, the script reads and parses the data and then either replaces the text
> in the cell or gives the user a choice of what to insert into the
> field.
The goal, and the point of this thread is to not have to
> manipulate the same raw data twice, once for FileMaker and once for
> DE.
I'm going to try once suggestion in the thread, to export from
> FileMaker to DE.
I'm also going to try to speed up the conversion process
> with some shell scripting (ug) and more advanced data manipulation, to avoid
> repeating through each line.
I'm thinking about making three import
> scripts in filemaker, one for movies, sports, and the rest, and extracting
> movies and sports listings from the raw data and saving those as separate input
> files.
This is all probably TMI.
ES
This is what the
> raw data looks like
7:30 pm|(TNT)|SPORTS|NBA Basketball|Denver Nuggets at
> Phoenix Suns|From US Airways Center in Phoenix.|||||(cc)|||2 hrs. 30
> mins.|(Live)
8:00 pm|(KTTV)|MUSIC|American Idol||The remaining nine finalists
> perform; former ``American Idol'' runner-up Adam Lambert mentors the
> contestants.|||(TVPG-D,L)|(s)|(cc)|(Tape)||1 hr. 28 mins.|
8:00
> pm|(KFTR)|MOVIE|Hijos de la Mafia|HH|||(2001)|John Malkovich, Dennis Hopper.|El
> hijo de un gángster hace hasta lo imposible para recuperar una bolsa llena de
> dinero que fue perdida en un pueblo de Montana.|||(R)|1 hr. 33
> mins.|(cc)||
8:00 pm|(KOCE)|LOG|Antiques Roadshow|Reading|Butcher's shop
> model; painting.||||||||30 mins.|
8:00 pm|(AMC)|MOVIE|Troy|HHH|||(2004)|Brad
> Pitt, Eric Bana.|The fierce warrior Achilles leads Greek forces in the Trojan
> War, ignited when Paris abducts Helen of Troy.|||(R)|2 hrs. 42
> mins.|(cc)||
8:00 pm|(APL)|SPECIAL|The Bear Whisperer||Steve Searles acts as
> a bear wrangler, handling 20 to 30 calls per week from panicky residents at
> Mammoth Lakes, Calif.|||(TVPG-V)|(s)|(cc)|||2 hrs.|
8:00 pm|(BBCA)|LOG|Doctor
> Who|Journey's End|As Davros and the Daleks threaten the entire universe, the
> Doctor's companions join forces. However, the prophecy declares that one of them
> will die.|||(TVPG)|(s)|(cc)|||1 hr.|
8:00 pm|(CNBC)|FINANCE|Mad Money||Money
> manager Jim Cramer discusses Wall Street investments.||||||||1 hr.|
8:15
> pm|(SHOW)|MOVIE|My Best Friend's Girl|H||(s)|(2008)|Dane Cook, Kate
> Hudson.|Complications crop up when an unlikable cad dates his best pal's
> ex-girlfriend in the pal's scheme to convince her to go back to him.|||(R)|1 hr.
> 43 mins.|||
THis is the same data ready to import into
> filemaker.
(The day of the week and date are derived from the file
> name)
04-13-2010 Tuesday
> SPORTS 7:30 pm 7:30 pm
> 10:00 p.m. PrimeTime (TNT)
> NBA Basketball 2 hrs. 30
> mins. (cc)
>
> (Live)
> Denver Nuggets at Phoenix Suns From US
> Airways Center in Phoenix.
04-13-2010
> Tuesday MUSIC 8:00 pm 8:00
> pm 9:28 p.m. PrimeTime
> (KTTV) American Idol The
> remaining nine finalists perform; former ``American Idol'' runner-up Adam
> Lambert mentors the contestants. 1 hr. 28
> mins. (cc) (s)
> (TVPG-D,L)
> (Tape)
>
04-13-2010
> Tuesday MOVIE 8:00 pm 8:00
> pm 9:33 p.m. PrimeTime
> (KFTR) Hijos de la Mafia
> El hijo de un gángster hace hasta lo imposible para recuperar una bolsa llena de
> dinero que fue perdida en un pueblo de Montana. 1 hr. 33
> mins. (cc)
> (R)
> (2001) John Malkovich, Dennis Hopper.
> HH
04-13-2010
> Tuesday LOG 8:00 pm 8:00
> pm 8:30 p.m. PrimeTime
> (KOCE) Antiques Roadshow
> Reading Butcher's shop model; painting. 30
> mins.
>
>
>
04-13-2010 Tuesday
> MOVIE 8:00 pm 8:00 pm
> 10:42 p.m. PrimeTime (AMC)
> Troy The fierce warrior Achilles leads
> Greek forces in the Trojan War, ignited when Paris abducts Helen of
> Troy. 2 hrs. 42 mins. (cc)
> (R)
> (2004) Brad Pitt, Eric
> Bana. HHH
>
04-13-2010 Tuesday
> SPECIAL 8:00 pm 8:00 pm
> 10:00 p.m. PrimeTime (APL)
> The Bear Whisperer Steve Searles acts as a
> bear wrangler, handling 20 to 30 calls per week from panicky residents at
> Mammoth Lakes, Calif. 2 hrs.
> (cc) (s)
> (TVPG-V)
>
>
04-13-2010 Tuesday LOG
> 8:00 pm 8:00 pm 9:00 p.m.
> PrimeTime (BBCA) Doctor
> Who Journey's End As Davros and the Daleks
> threaten the entire universe, the Doctor's companions join forces. However, the
> prophecy declares that one of them will die. 1
> hr. (cc) (s)
> (TVPG)
>
>
04-13-2010 Tuesday
> MOVIE 8:00 pm 8:15 pm 9:58
> p.m. PrimeTime (SHOW) My
> Best Friend's Girl Complications crop up
> when an unlikable cad dates his best pal's ex-girlfriend in the pal's scheme to
> convince her to go back to him. 1 hr. 43
> mins. (s)
> (R)
> (2008) Dane Cook, Kate Hudson.
> H
-------------- next part
> --------------
An HTML attachment was scrubbed...
URL:
> href="http://lists.apple.com/mailman/private/applescript-users/attachments/20100615/09b15e94/attachment.html"
> target=_blank
> >http://lists.apple.com/mailman/private/applescript-users/attachments/20100615/09b15e94/attachment.html
------------------------------
Message:
> 3
Date: Tue, 15 Jun 2010 13:41:16 -0400
From: "Steve Valenti" <
> ymailto="mailto:email@hidden"
> href="mailto:email@hidden">email@hidden>
Subject:
> FileMaker - Scripting Remote DataBase
To: "liste AppleScript US" <
> ymailto="mailto:email@hidden"
> href="mailto:email@hidden">email@hidden>
Message-ID:
> <
> ymailto="email@hidden"">mailto:email@hidden"
> href="email@hidden"">mailto:email@hidden">email@hidden>
Content-Type:
> text/plain; charset="us-ascii"
I built scripting to automatically
> populate a database and everything
works great when I open the database on
> the machine. Now I need to move
this database to FileMaker Server and open it
> on a client as a remote
database and run my scripting to keep populating it.
> However scripting
of a remote database doesn't behave the same. Here are two
> examples when
trying to script a remote database that you don't get any
> results to
work with. If you were to run one at a time it really shouldn't
> error.
FileMaker Server 11 doesn't seem to be the trouble because I tried
> just
sharing from FileMaker Pro 10 software with the same results.
>
tell application "FileMaker Pro Advanced"
> tell database "NameOfDataBase.fp7"
> show every record
> delete every
> request
> set MyRequest to create new request --Error
> --Object not found. (-1728)
>
> set NewRecord to create new
> record --Error
> --Object not found. (-1728)
> end tell
end tell
Does anyone have any experience in
> scripting remote databases? The show
every record command works. What makes
> remote DB different?
Thanks!!!
-------------- next part
> --------------
An HTML attachment was scrubbed...
URL:
> href="http://lists.apple.com/mailman/private/applescript-users/attachments/20100615/5e323c42/attachment.html"
> target=_blank
> >http://lists.apple.com/mailman/private/applescript-users/attachments/20100615/5e323c42/attachment.html
------------------------------
Message:
> 4
Date: Tue, 15 Jun 2010 14:20:03 -0400
From: Geoff Graham <
> ymailto="mailto:email@hidden"
> href="mailto:email@hidden">email@hidden>
Subject: Re:
> FileMaker - Scripting Remote DataBase
To: liste AppleScript US <
> ymailto="mailto:email@hidden"
> href="mailto:email@hidden">email@hidden>
Message-ID:
> <
> href="email@hidden"">mailto:email@hidden">email@hidden>
Content-Type:
> text/plain; charset="windows-1252"
Try throwing a "go to layout
> layoutname" in there right after the tell database. For what you're doing, you
> really shouldn't have to, but I've seen that work before.
Geoff
On
> Jun 15, 2010, at 1:41 PM, Steve Valenti wrote:
> I built scripting to
> automatically populate a database and everything works great when I open the
> database on the machine. Now I need to move this database to FileMaker Server
> and open it on a client as a remote database and run my scripting to keep
> populating it. However scripting of a remote database doesn’t behave the same.
> Here are two examples when trying to script a remote database that you don’t get
> any results to work with. If you were to run one at a time it really shouldn’t
> error. FileMaker Server 11 doesn’t seem to be the trouble because I tried just
> sharing from FileMaker Pro 10 software with the same results.
>
>
> tell application "FileMaker Pro Advanced"
>
> tell database "NameOfDataBase.fp7"
>
> show every record
>
> delete every
> request
>
> set MyRequest to create new request --Error
>
> --Object not found.
> (-1728)
>
>
>
> set NewRecord to create new record --Error
>
> --Object not found.
> (-1728)
> end tell
> end
> tell
>
> Does anyone have any experience in scripting remote
> databases? The show every record command works. What makes remote DB
> different?
>
> Thanks!!!
>
> _______________________________________________
> Do not post admin
> requests to the list. They will be ignored.
> AppleScript-Users mailing
> list (
> href="mailto:email@hidden">email@hidden)
>
> Help/Unsubscribe/Update your Subscription:
>
> target=_blank
>
> Archives:
> target=_blank >http://lists.apple.com/archives/applescript-users
>
>
> This email sent to
> href="mailto:email@hidden">email@hidden
--------------
> next part --------------
An HTML attachment was scrubbed...
URL:
> href="http://lists.apple.com/mailman/private/applescript-users/attachments/20100615/65a6851a/attachment.html"
> target=_blank
> >http://lists.apple.com/mailman/private/applescript-users/attachments/20100615/65a6851a/attachment.html
------------------------------
_______________________________________________
AppleScript-Users
> mailing list
> href="mailto:email@hidden">email@hidden
> href="http://lists.apple.com/mailman/listinfo/applescript-users" target=_blank
> >http://lists.apple.com/mailman/listinfo/applescript-users
End of
> AppleScript-Users Digest, Vol 7, Issue
> 319
*************************************************
_______________________________________________
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/archives/applescript-users
This email sent to email@hidden