Tag Archive for 'scripts'

Simpler Printing

Recent improvements in Filemaker have let me take a second look at the way I do many tasks in databases I have designed.  This month I will review printing scripts.

Most databases have a set of scripts that handle printing tasks.  Using a single set of scripts accomplishes XX tasks at the same time. 1) it is a great exercise in learning how to write more modular code.  Write it once and use the same code all over your solution. 2) at the same time it creates a unified way to accomplish the task.  No matter where the user is in the database, they know how to print and what will happen when they hit the print button.

In solutions using Filemaker 7 through 9, I typically handle printing with a script that gives the user this experience;

  1. Click a print button
  2. Ask if you are printing the current record or the found set
  3. Ask if you want to print or save as PDF
  4. Bring up a new window showing the report, in Preview mode, paused.
  5. The User clicks ‘continue’
  6. The Print dialogue comes up
  7. User prints (or cancels)
  8. New window closes, leaving the user where they started.

Here is a typical Print script:
PrintScript1

The problem I always had with this is that it is not always obvious for a novice.  Although obvious to the developer, I think I have had to tell every single user I have ever trained, “After you click the Print button, you have to hit the ‘continue’ button, it is on the left”  The expected action, clicking the close window widget, doesn’t work, since the script is paused.

This is all different in Filemaker 10.  Taking advantage of FM 10 gives us two advantages.  1) scripting can be more flexible and simpler 2) the users can have more flexibility.  In a Filemaker 10 solution, here is how I now handle a typical printing routine;

  1. Click a print button
  2. Bring up a new window showing the report in preview mode, expose the toolbar
  3. User clicks the Save as PDF, or Print button in the toolbar
  4. Closes the window using the window button.

The main differences from the users perspective is that they can chose the PDF, or Print options after seeing the printout.  They can close the window using the window tool, or leave the report up for later.  Since there is no script running, the user can leave the window open and return to the solution, if they want.  I have given the users more choice and saved myself script steps too.

Here is a typical Print Script that I am now using;
PrintScript2

If you want to perform any actions after printing, you can perform them using custom menus.  Attach a script to the “Print” menu item that perfoms your script when the print command is successfully completed.  But in general, being aware of the new features in Filemaker 10 lets you give the users more power in their solutions and at the same time letting you use less scripting.

 

Tips and Tricks: Start Script Debugger Quickly

Have you ever been too lazy to click twice and select Tools>Script Debugger when you were about to run a script from the Script Manager? I thought so, because I am. A quick shortcut is to hold down the shift key as you click on the Run button. Voila! The Script Debugger magically opens and pauses on the first script step.