My.ADVISOR.com Sign-In
Username
Password
Sign Up 
Go to Article
Advanced Search 

ADVISOR TIPS

Delete FileMaker Pro Files Elegantly

Find out how to delete a file from your local hard drive or a shared volume using a couple of script steps.

By John Mark Osborne, Database Pros president and owner, and FileMaker Advisor technical editor


Technical Editor Bob Bowers showed me this tip and it really knocked my socks off. I couldn't believe you could delete a file from your local hard drive or a shared volume using a couple of script steps. It's easy if you already know how to specify a dynamic file path using a variable. For those of you who aren't familiar with the technique, I'll go over it briefly

In past issues, I've demonstrated how to save PDF files or export data from FileMaker Pro with a dynamic file name and path. All you have to do is declare a script variable with the path where you want to save the file and a file name. For example, the following script steps save a PDF file on your desktop with the name stored in the "myfile" field:

Set Variable [$Path; Value: "file:" & Get(DesktopPath) & MYTABLE::myfile & ".pdf"]
Save Records as PDF [Restore; No dialog; "$Path"; Records being browsed]

Instead of specifying the output file path with a static path, you can use a variable to declare a dynamic file path using calculations. There are half a dozen functions that locate paths on the local hard drive:

Get(DesktopPath)
Get(DocumentsPath)
Get(FilePath)
Get(PreferencesPath)
Get(FileMakerPath)
Get(TemporaryPath)

After you understand how to save a file dynamically, you can also delete it dynamically. Using the same Set Variable script step and the Export Field Contents script step, you can delete a file anywhere on your local hard drive or a shared volume:

Set Variable [$Path; Value: "file:" & Get(DesktopPath) & MYTABLE::myfile & ".pdf"]
Export Field Contents ["$Path"]

The key to this technique is not specifying a target field on the Export Field Contents script step. Only specify the path using the script variable and you'll delete the file, not just overwrite it.

What do YOU think about this topic? Share your advice and thoughts using this form.

Your Name

REQUIRED : PUBLIC

Your E-Mail

REQUIRED : PRIVATE

Job, Company

OPTIONAL : PUBLIC

City, State, Country

OPTIONAL : PUBLIC

Your Web Site

OPTIONAL : PUBLIC

Your Comment

Please help everyone by keeping your comments on-topic, using clean language, and not defaming or making personal attacks.


Your e-mail address is required, but it will not be displayed to the public or given to anyone. See our Privacy Policy. Comments become visible after they pass our spam filter, and spammers and abusers are permanently blocked. Please report spam or abuse.

John OsborneTechnical editor John Mark Osborne is president and owner of Database Pros, offering FileMaker resources on the Internet. He is author of Scriptology, a speaker at FileMaker Developer Conferences and Macworld conferences, and a trainer for the Professional Training series created by FileMaker, Inc. http://www.databasepros.com jmo@filemakerpros.com

Printer-friendly
page layout

Keyword Tags: FileMaker, FileMaker Development, FileMaker FileMaker Pro

ADVISORAMA
Nothing lasts as long as a box of cereal you don't like.

ARTICLE INFO

FileMaker Advisor

Print Edition: February/March 2008, Page 38

FREE ACCESS FREE ACCESS

Subscribe to FileMaker Advisor Magazine

Read the advanced guide to creating custom business database solutions with FileMaker software. Subscribe now to gain access to all the archives and downloads.

FileMaker.Advisor.com

Subscribe to Advisor Basics of FileMaker Pro

Learn the fundamentals of using FileMaker Pro software. Every issue gives you step-by-step instructions on creating the databases you need. Subscribe now!

FileMaker.AdvisorBasics.com

Showcase Your Smarts

Submit your tips, techniques and advice and let Advisor promote your business and build your career. Show the world what you know!

AdvisorTips.com

Use of this or any other site, content, product or service of Advisor Media constitutes acceptance of Terms of Use.
Portions copyright ©1983-2008 Advisor Media, Inc. All Rights Reserved.
Reuse or reproduction of any portion or quantity of Advisor Media's copyrighted content, in any form, for any purpose, requires written permission.
ADVISOR®, the ADVISOR logo, and other names and logos that incorporate ADVISOR are registered trademarks, trademarks or service marks of Advisor Media, Inc. in the United States and/or other countries.
Other trademarks are used for identification, editorial or descriptive purposes and are the property of their owners.
Hosted by Prominic.NET Website powered by
LOTUS SOFTWARE
osboj037-02 posted 12/17/2007 modified 07/21/2008 03:40:24 AM ztfmfd/ztfmfd
domino-144.advisor.com my.advisor.com 07/26/2008 05:27:32 PM