Mandu Posted March 14, 2008 Posted March 14, 2008 I want a script to put up a window in Preview mode, pause, and allow the user to either (a) proceed to a Print step, or (: cancel but allow the script to continue running. As far as I know, there is no way to put active buttons on a window in Preview mode. What I'm trying, then, is the following: Allow User Abort [On] /* Cause Cancel button to be shown */ Allow Error Capture [On] /* Let me handle errors */ Show/Hide Status Area [show] /* Display side bar and buttons */ Enter Preview Mode [] /* Show current layout in Preview mode */ Pause/Resume Script [indefinitely] /* Wait for user to click Continue or Cancel */ Set Variable [ $errcd ; Value: Get( LastError ) ] /* Try and learn what was pressed */ If [ $errcd = 0 ] /* The user clicked Continue */ Else /* The user clicked Cancel */ End If Unfortunately, if I press Cancel in the Status area sidebar, it cancels the script immediately, instead of allowing me to handle it. Is there any way to do this? Thanks, Chap
Vaughan Posted March 14, 2008 Posted March 14, 2008 Show the status area so the "Continue" button is visible. When the script is resumed, show the print dialog. Users can just cancel it to avoid printing. Set user abort to off so the "Cancel" button doesn't appear in the status area. Also, get OUT of the habit of turning error capture on by default. This suppresses FMP's error messages. The error messages can actually warn you and the user when something is wrong. Only turn it on when you want to trap for errors (like after a find) and turn it back off again straight afterwards. ... Allow User Abort [Off] Show/Hide Status Area [show] Enter Preview Mode [] Pause/Resume Script [indefinitely] Print [] ... If you want to see whether the user printed, trap the error from the Print step. The error code is 1 when the user clicks cancel. Allow User Abort [Off] Show/Hide Status Area [show] Enter Preview Mode [] Pause/Resume Script [indefinitely] Set Error Capture [on] Print [] Set Variable [$error] Set Error Capture [off] If [$error = 0] #user printed the document Else If [$error = 1] #user cancelled print step Else #some other error occurred that stopped the print from happening End If
Mandu Posted March 14, 2008 Author Posted March 14, 2008 Well, that's better than nothing, I guess - one extra dialog box. (I wonder why they decided that Cancel from Print could be trapped, while Cancel from Pause couldn't....) Thanks - Chap
corn Posted March 14, 2008 Posted March 14, 2008 Well, that's better than nothing, I guess - one extra dialog box. (I wonder why they decided that Cancel from Print could be trapped, while Cancel from Pause couldn't....) In the case of the former, you are canceling the Print script step; the remainder of the script continues running once the dialog is dismissed. In the latter the thing that is "paused" is the script, therefore canceling the script, um, cancels the script. There's no script running, having been canceled, to capture the cancel.
corn Posted March 14, 2008 Posted March 14, 2008 .... Set Error Capture [on] Print [] Set Variable [$error] Set Error Capture [off] .... That Set Variable script step should of course be: Set Variable [$error; Get ( LastError )]
ecoplunge Posted September 1, 2009 Posted September 1, 2009 If only the "Cancel' button for a paused script really did cancel - if it were labeled correctly it would say 'Halt'. If it actually did cancel then I could run a subscript to do the printing, let the user print or cancel, and then go about my merry way using the parent script to navigate back to where I need to be. I can't tell you how many clients look at me funny when I tell them that they have to continue to cancel while printing. It may be filemaker's shortcoming but it's me that it makes look bad.
Recommended Posts
This topic is 5563 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now