BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
daniel_harding
Community Trekker

best way to pause a section of code

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!

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: best way to pause a section of code

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...

0 Kudos
4 REPLIES 4
pmroz
Super User

Re: best way to pause a section of code

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...

0 Kudos
Highlighted
daniel_harding
Community Trekker

Re: best way to pause a section of code

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.

0 Kudos
pmroz
Super User

Re: best way to pause a section of code

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...

0 Kudos
daniel_harding
Community Trekker

Re: best way to pause a section of code

That's perfect! Thanks again!

0 Kudos