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
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 )
|
The result of this calculation looks like this:
size:266,309 image:../../../../../quilt database/sale quilt pix/batik squares.jpg imagemac:/babycakes/current work/quilt database/sale quilt pix/batik squares. jpg
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.