|
Page 2 of 2
 |
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.
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]
 |
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]
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
 |
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
 |
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

|