Jump to content
Sign in to follow this  
Mandu

Pause/Resume - where's resume?

Recommended Posts

I have a situation in which a script ("Edit Invoice") has opened a foreground window and has Paused. The window is normally closed by clicking a DONE button which is defined to resume current script and to run a small script that essentially just does a Close Window.

I would like to add a keystroke equivalent, so I created a script called "Done" that is bound to Command+0 in the Scripts menu. How can the Done script have the same behavior as the DONE button; i.e. is there a script step to "resume current script"? I don't really see how Pause/Resume can do it.

Thanks,

Chap

Share this post


Link to post
Share on other sites

You could split the script into two scripts.

The first script is the existing script up to and including the pause. Add a Perform Script [ 'Resume' ] to call the second, Resume script, of the original script.

The second, Resume script, is the last part of the original script after the pause step. Add a Halt Script step to the end of this script to stop the Pause in the original script.

Share this post


Link to post
Share on other sites

You could split the script into two scripts.

I assume you're referring to the "Edit Invoice" script.

The first script is the existing script up to and including the pause. Add a Perform Script [ 'Resume' ] to call the second, Resume script, of the original script.

The second, Resume script, is the last part of the original script after the pause step. Add a Halt Script step to the end of this script to stop the Pause in the original script.

Okay, so are you saying that my DONE button should Perform Script('Resume'), and that Resume should also be available in the Scripts menu to be selected by a cmd-0?

I may have again committed the error of posting a simplified version of my problem, on the assumption that I could safely judge what details weren't relevant.

Here's EXACTLY what I'm trying to do:

Main window is a list of invoices. You click a button labeled "New Invoice", which drives a script that creates a new invoice record and then calls Edit Invoice, which puts up the invoice up in a new window and pauses. When you click DONE it drives a script that does error checking, commits the record, closes the edit window, and exits. DONE is defined to resume current script. So "Edit Invoice" resumes executing and simply exits.

At this point you would normally click New Invoice for the next invoice. I want to reduce the sequence of (1) click DONE, (2) click New Invoice, to a single keystroke that drives a script called "Save and Create Another", which functionally duplicates those two button-clicks.

So I lied, and you caught me :B I really want not only to use a script to close the edit window and allow "Edit Invoice" to complete, I also want then to simulate clicking "New Invoice". And I'm seeing that "Save and Create Another" cannot possibly cause its parent script to terminate, yet plow ahead on its own!!

Obviously I've implemented this thing all wrong and inside-out. Sheesh - I wonder if anyone can follow this.

Share this post


Link to post
Share on other sites

At this point you would normally click New Invoice ...

But not always !

What if someone may want to do something else ?

What he have to do with that empty invoice ?

Share this post


Link to post
Share on other sites

But not always !

What if someone may want to do something else ?

What he have to do with that empty invoice ?

If he wants to do something else, he should click DONE which saves the most recent invoice, closes the window, and returns him to a view of the list of invoices.

I should maybe have said that he "often" wants to create another invoice. That's why I want to give him a shortcut. And, I've put some special-case logic in so that if he creates a new invoice and clicks DONE before typing anything in, the new record is backed out and the invoice serial number is decremented, as if he never clicked New Invoice in the first place.

[Another confession - the main reason I want the shortcut is to make it easy to enter a stack of 1000 hand-written paper invoices. Once those are entered, we can switch to using this FM solution, avoiding hand-written invoices altogether. When that happens there may never be a need to batch-enter invoices, and there won't be a real need for the shortcut!]

Share this post


Link to post
Share on other sites

It's a little bizarre, but there is a Resume Script script step, but it's not accessible in Scriptmaker, only in Custom Menus.

Some options:

1) Create a Custom Menu with your keystroke command. You can specify the Resume Script script step in a custom menu.

If you're reluctant to use Custom Menus for some reason...

2) Instead of an Indefinite Pause in your script, you can Loop a 2 second pause with an Exit Loop If [$$resume = 1]. Your 'Resume' script would be Set Variable [$$resume =1]. (You'd need to clear the variable before or after the Loop).

Share this post


Link to post
Share on other sites

You could use a looping script with a modifier key sequence.

If the DONE button is clicked while the Shift key is down, the script will loop back and start again allowing quick entry. If the user does not want a new invoice, simply click the DONE button.

This will provide the same presentation, same script, and only one extra key stroke for very different results.

Share this post


Link to post
Share on other sites

You could use a looping script ... [snip]

That's what I'm looking at now.

Main script (triggered by clicking New Invoice on invoice list)???

Loop

-- Put up new window, create new record, go to Edit Invoice layout

-- Pause (keep edit window in foreground, prevent user from accessing invoice list during edit session)

-- If user finished editing invoice with indication he does not want any more new invoices, exit loop.

End Loop

When the user clicks the DONE button on the Edit Invoice interface, I want to run some final validations, and in the event of errors, put up a custom dialog and then return to the Edit Invoice window. If the data is valid, go ahead and commit the record, and close the Edit Invoice window. At this point I'd also like the Pause in the main script loop to resume.

I like the idea of holding a modifier key to indicate "give me another, please." But I am still not sure how to cause the main script to resume. Perhaps I should shift the logic for final validation from where it is now (tied to the DONE button) to just after Pause in the Main script, and have the DONE button do nothing except resume the Main script?

Share this post


Link to post
Share on other sites

When you create a button, under perform script there will be an option to Halt the current script rather than the default "Pause" option.

Share this post


Link to post
Share on other sites

When you create a button, under perform script there will be an option to Halt the current script rather than the default "Pause" option.

As I understand it, "Halt" will prematurely terminate the current script. That's not what I want to do - I actually don't want pressing the button to have any effect on the current script, since it's up to the validation routines to decide whether to allow the invoice to be saved (and to allow the current script to resume its loop), or to require further corrections be made first.

Share this post


Link to post
Share on other sites

You should do the validation in a second script. The button would halt the last script of an infinate loop. If the validation is not passed, then it would prompt the user and then enters another infinate loop.

Share this post


Link to post
Share on other sites

You should do the validation in a second script. The button would halt the last script of an infinate loop. If the validation is not passed, then it would prompt the user and then enters another infinate loop.

I'm still not following you; sorry! ???-)

If you could frame your suggestion within the structure I described earlier, it would help me. Here is is:

Main script (triggered by clicking New Invoice on invoice list):)

Loop

-- Put up new window, create new invoice record, go to Edit Invoice layout in new window

-- Pause (keep edit window in foreground, prevent user from accessing invoice list during edit session)

-- If user finished editing invoice with indication he does not want any more new invoices, exit loop.

End Loop /* loop back, put up new window, etc.*/

DONE script (triggered by clicking DONE button on the Edit Invoice window - DONE button is flagged "Pause Current Script" because we may decide to refuse the DONE request.)

-- Perform validations on invoice.

-- If errors, put up dialog listing them and saying "you've got to fix these first, before continuing." Exit from DONE script. Main script remains paused.

-- If no errors, commit the record, close the Edit Invoice window, and SOMEHOW cause the Main script to resume from its Pause, check some indication of whether the user clicked or meta-clicked and either loop back or exit script accordingly.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.