Subscribe Bookmark RSS Feed

best way to pause a section of code

daniel_harding

Community Trekker

Joined:

Jul 2, 2012

Hello,

I am trying to pause a program using an if statement. Basically I need to have a statement that pops up an error window and stops the process. I have tried this with stop () and throw () as well as try() used in conjunction with throw() but these stop the program completely and not that specific section of code. Here is what I've got so far:

(If( totlots > 50 | replicates > 50,

  New Window( "ERROR!", Beep(),

  V List Box( Text Box( "NUMBER OF LOTS OR NUMBER OF REPLICATES CANNOT NOT EXCEED 50" ), )

/* then I need some function to pause this section of  code after the window is displayed, but not the rest of the program like stop() and throw () have done. Thanks for any help!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

I would issue a throw() after the modal dialog box to stop the code:

totlots    = 61;

replicates = 51;

If( totlots > 50 | replicates > 50,

    New Window( "ERROR!",

        <<modal,

        Beep(),

        V List Box( Text Box( "Number of lots or number of replicates cannot exceed 50" ), )

    );

    throw();

);

// More statements here...

4 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

If you use a modal dialog box the program will stop, and then continue on once the user has hit OK.

totlots    = 61;

replicates = 51;

If( totlots > 50 | replicates > 50,

      New Window( "ERROR!",

            <<modal,

            Beep(),

            V List Box( Text Box( "Number of lots or number of replicates cannot exceed 50" ), )

      )

);

// More statements here...

daniel_harding

Community Trekker

Joined:

Jul 2, 2012

That's a great tip! Thanks! Is there a way to have the modal window close and not run the code? The way it is now, if the user clicks on the x button or hits ok, it runs the code even if the totlots or replicates variables are more than 50.

Solution

I would issue a throw() after the modal dialog box to stop the code:

totlots    = 61;

replicates = 51;

If( totlots > 50 | replicates > 50,

    New Window( "ERROR!",

        <<modal,

        Beep(),

        V List Box( Text Box( "Number of lots or number of replicates cannot exceed 50" ), )

    );

    throw();

);

// More statements here...

daniel_harding

Community Trekker

Joined:

Jul 2, 2012

That's perfect! Thanks again!