NZMac.com - Supporting the New Zealand Mac community : Monday, 08 September 2008
Making a FileMaker movie review database Print
Written by Philip Roy   
Wednesday, 01 January 2003
Article Index
Making a FileMaker movie review database
Page 2

Making buttons

You can script a button or make an image a button that performs a task

If you start me up
On starting the database file up, a script sorts the database and leads us to the splash screen, where there are two buttons we need to program. We are going to use scripts for each of these, even though we could program the buttons just to move to a certain layout. For the Browse button, create a script called "Go to the first record" and script it as follows:

Go to Layout [Movie Info][Refresh window]
Perform Script ["Sort database if needed"]
Go to Record/Request/Page [First]
Set Field [Record Number, NumToText(Status(CurrentRecordNumber)) & " of " & NumToText(Status(CurrentRecordCount))]

To set the button, change to layout mode, select the appropriate graphic and go to the Format menu and choose Button. Most of the script is self explanatory, except perhaps the last part. On the screen you are moving to, there's a field called Record Number and in the final part of the script we set a field to indicate on our layout, just where we are in the database÷"1 out of 15" for example.

Good FileMaker Design

You might notice that I've written some simple scripts that could be done with a simple action instead. You'll soon find that you are always coming back to your database and improving it. When you do, it's always easier to have scripts ready that you can work on and alter.

You'll also notice in the version on my website that I've put comments in the script no matter how basic they are. It just makes life so much easier when you leave a database for 6 months and come back to it.

Finally, learn the art of 'subroutines'. If you are having a recurring series of commands appearing in your database, spin these off as a separate script that you call from within other scripts.

The script to take us to the search screen is basic, with it resetting to the two temp fields we might use during our search÷

Perform Script ["Sort database if needed"]
Set Field [Movie Title Temp, ""]
Set Field [Movie Year Temp, ""]
Go to Layout [Search Screen][Refresh window]

Let's move to the Search layout next. The Browse button is easy, as it uses exactly the same script as we just used on the splash screen. For the Search button, we need to make a script that performs a Find for us÷

If [IsEmpty(Movie Title Temp) and IsEmpty(Movie Year Temp)]
Show Message [Buttons: "OK", "", ""; Data: "You didn't enter any information to search on."]
Exit Script
End If
# Enter Find Mode and Perform Find"
Enter Find Mode
Set Field [Movie Title, Movie Title Temp]
Set Field [Movie Year, Movie Year Temp]
Perform find [Replace Found Set]
If [Status(CurrentFoundCount) = 0]
Show Message [Buttons: "New", "Stop", ""; Data: "There are no records that match the details you have entered. Do you want to try a new search ?"]
If [Status(CurrentMessageChoice) = 1]

Making calculations

FileMaker allows for complex number and text calculations

Exit Script
Else
Perform Script ["On Startup"][Sub-scripts]
Halt Script
End If
End If
# If 1 record is found then go there"
If [Status(CurrentFoundCount) = 1]
Perform Script ["Go to record via unique ID"]
Halt Script
Else
Go to Layout [Movie List][Refresh window]

This script checks to make sure there is actually something entered before going into find mode and trying to find matching records. If there are no matches, it asks what the user wants to do. If one match is found, it goes instantly to that record and if more than one is found, it goes to the screen that lists all the found records. That's where we're headed next also.

Lights, camera÷.lists
On the movie list layout, any movies (more than 1) that matched our search appear. The only button here uses a script that we linked to in the last script. It's job is to identify the record we want to view, sort the database and then take us to that record, wherever it might be. So create a script called "Go to record via unique ID" and attach it to the graphic on this screen.

Enter Browse Mode
# Set the records ID with the FMP ID value"
Set Field [Search Temp, Status(CurrentRecordID)]
Freeze Window
Perform Script ["Sort database if needed"]
# Using a loop, work through the records"
Go to Record/Request/Page[First]
Loop
Exit Loop If [Search Temp = Status(CurrentRecordID)]
Go to Record/Request/Page [Next, Exit after last]
End Loop
Set Field [Record Number, NumToText(Status(CurrentRecordNumber)) & " of " & NumToText(Status(CurrentRecordCount))]
Go to Layout [Movie Info][Refresh window]

FMPro and the web

You may be aware that companies can run their website from a FileMaker database. Although FileMaker does have some in-built web capability, if you are seriously going to develop a database-driven website, then you are going to need a product like Lasso from Blueworld (www.blueworld.com). Lasso provides connectivity between the web pages and your website files on a server.

Just the facts Ma'm
We've now arrived at the most detailed and most complex layout, the Movie Info layout where we show all our facts about the movie. You can start by formatting the Search button to use the "Go to Search Screen" script. The navigation buttons (to go to the first, previous, next and last records) are very easy. I chose to use scripts for these also, to make sure the database was sorted and to set the field that displays the current record number. For the Delete Record button just remember to ask more than once before a record is deleted and tidy things up with a Sort at the end. If you go to my website (www.bluengrey.com) after this article is published, the database file will be available to download in the Software section and have these scripts included if you are stumped.

The Internet Movie Database (IMDB) logo is used to trigger a script that starts by seeing if the movie in question has an IMDB ID code stored. If it doesn't, the user can either enter the number, connect to the IMDB website by the movie name, or cancel. If entering the ID, it will then ask if the user wants to connect as before.

If [IsEmpty(IMDB reference)]
Show Message [Buttons: "Connect", "Enter", "Cancel"; Data: "There is no IMDB code stored for this movie. Do you want to connect to the IMDB site by using the Movie's title or do you want to enter an IMDB code now?"]
If [Status(CurrentMessageChoice) = 3]
Exit Script
Else
If [Status(CurrentMessageChoice) = 1]
Set Field [IMDB reference temp, "http://us.imdb.com/Title?" & Movie Title]
Open URL ["IMDB reference temp"][No dialog]
Exit Script

Connecting to the net

The 'IMDB' script lets you connect to the internet to find out information about the movie

Else
# Prompt user to enter an IMDB reference ID"
Show Custom Dialog [Title: "Enter IMDB Code"; Message: "Please enter the code that the IMDB website uses (usually a 6 digit code) to reference this movie."; Buttons: "Enter code", "Cancel", ""; Input #1: IMDB reference, IMDB reference]
If [Status(CurrentMessageChoice) = 2]
# User cancels entering an ID"
Exit Script
End If
End If
End If
End If
Show Message [Buttons: "Yes", "Cancel", ""; Data: "Shall I connect using the IMDB code now?"]
If [Status(CurrentMessageChoice) = 2]
Exit Script
Else
Set Field [IMDB reference temp, "http://us.imdb.com/Title?" & IMDB reference]
Open URL ["IMDB reference temp"][No dialog]
End If

The final set of buttons (those next to the Actor fields) are actually going to require 5 scripts. In this case, each script for each button will set a field (Search Temp) to the contents of the field closest to it. Then, each script will move to the final script that does the actual searching.

Allow User Abort [Off]
Set Error Capture [On]
Set Field [Actor Temp, Case(Search Temp="1", Actor 1, Search Temp="2", Actor 2, Search Temp="3", Actor 3, Search Temp="4", Actor 4)]
# Enter Find Mode
# Enter to search for the actor as record 1
Insert Calculated Result [Actor 1, Actor Temp][Select entire contents]
# Enter to search for the actor as record 2
New Record/Request
Insert Calculated Result [Actor 2, Actor Temp][Select entire contents]
# Enter to search for the actor as record 3

Tidy scripts

Using fake/empty scripts (the ones starting with '----') is a nice way to section off your script list

New Record/Request
Insert Calculated Result [Actor 3, Actor Temp][Select entire contents]
# Enter to search for the actor as record 4
New Record/Request
Insert Calculated Result [Actor 4, Actor Temp][Select entire contents]
# Perform Find
Perform Find [Replace Found Set]
# If only one record found, then sort and leave user at the appropriate record"
If [Status(CurrentFoundCount) = 1]
Show Message [Buttons: "OK", "", ""; Data: "This is the only movie featuring that actor."]
Perform Script ["Go to record via unique ID"]
[Sub-scripts]
Else
Go to Layout [Movie List][Refresh window]
End If

This script will take some working out, but when you see it in the database from my website, there'll be more comments in the scripts to explain what is happening. And that's it. You now have a very workable and helpful database that you can use to store movie information. If you have suggestions as to more features you like to see in the database, drop me a line and we may continue working on it for Macguide readers.
 

 

 


* The symbols '' are used in the scripts where the web page cannot recreate the 'does not equal' symbol. In FileMaker, you need to use the correct symbol, which is an equals sign with a line through it.
 

 

© Parkside Media 2003
For permission to use this document, email This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

Comments (0)add comment

Write comment
This content has been locked. You can no longer post any comment.
You must be logged in to a comment. Please register if you do not have an account yet.

busy

Last Updated ( Sunday, 07 January 2007 )
 
Advertisement
Site developed by Bluengrey.com :: Joomla Template by Joomlashack
Joomla Templates by JoomlaShack Joomla Templates by Compass Design