Containers in Calculations

Although it isn't a typical calculation data type, you can do a few interesting things with container fields in calculations. You don't have the same vast options you do with other types. It would be great if you could subtract Cousin Clem.jpg from Family Reunion.jpg to get the scoundrel out of the picture, but alas, the technology's not quite there yet. Nevertheless, FileMaker doesn't leave containers entirely out in the cold when it comes to calculations.

10.5.1. Calculations with Pictures, Sounds, Movies, and Files

When you create a calculation field (Section 9.1.1), you can set its result type to Container. You can't create container data in a calculation, but you can refer to other container fields. When you do, the picture, sound, movie, or file in the referenced container field shows in the new calculation field.

You can, for example, make a calculation field that shows the contents of one container field when you're in Browse mode and another in Preview mode. This field lets you use low-resolution images when you view on the screen, and higher resolutions when you print. (You'll learn to do that in the next chapter, when you learn about calculations with that kind of decision-making ability.)

You might also want to use container fields in a calculated replace. Suppose you have a found set of 30 records that don't have a low-resolution image. You have to have something in that field, so you decide to take the hi-res image for those few records and plunk them down in the low-resolution image field. Choose Records images/U2192.jpg border=0> Replace Field Contents and perform this calculated replace:

	Graphics::High Resolution Image

The entire calculation consists of a reference to a field of that name in the Graphics table. The calculation does the grunt work of copying the high-resolution image into the low-resolution field in each record.

10.5.2. Calculations with References

If a container field holds a reference to a picture, movie, sound, or file, instead of the object itself (Section 2.7.4), you can do even more. When you treat such a field as text, FileMaker gives you some information about the referenced file.

If you have a field called Product Shot (see Figure 10-4) that holds a reference to a photograph file, you can use this calculation:

	GetAsText ( Product Shot )

Figure 10-4. FileMaker also includes two paths identifying the file's location. One's a relative path, starting from the location of the database file. The second's an absolute path, meaning it starts from the top level of your computer's system of files and folders.

The result of this calculation looks like this:

	image:../../../../../quilt database/sale quilt pix/batik squares.jpg
	imagemac:/babycakes/current work/quilt database/sale quilt pix/batik squares.

As shown in Figure 10-4, FileMaker tells you the size (width and height in pixels) and location of the file (if this weren't a picture, you wouldn't see the "size:" line).

You can use this calculation to help you keep track of a set of images that the whole company needs to use. You really need two container fields for this purpose. One holds the graphic itself, or a low-resolution copy, if you don't want the file size to balloon. Then, when you place the graphic as a reference in the second container field, the calculation stores the graphic's original location. The calculation's not dynamic, however, so the path serves as a reference of where the file should be, not where it really is. Company policy about putting things back where you found them has to reinforce your good data practices.

Part I: Introduction to FileMaker Pro

Your First Database

Organizing and Editing Records

Building a New Database

Part II: Layout Basics

Layout Basics

Creating Layouts

Advanced Layouts and Reports

Part III: Multiple Tables and Relationships

Multiple Tables and Relationships

Advanced Relationship Techniques

Part IV: Calculations

Introduction to Calculations

Calculations and Data Types

Advanced Calculations

Extending Calculations

Part V: Scripting

Scripting Basics

Script Steps

Advanced Scripting

Part VI: Security and Integration


Exporting and Importing

Sharing Your Database

Developer Utilities

Part VII: Appendixes

Appendix A. Getting Help

FileMaker Pro 8. The Missing Manual
FileMaker Pro 8: The Missing Manual
ISBN: 0596005792
EAN: 2147483647
Year: 2004
Pages: 176 © 2008-2020.
If you may any questions please contact us: