cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
daniel_harding
Level III

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!

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

View solution in original post

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

daniel_harding
Level III

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.

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

daniel_harding
Level III

Re: best way to pause a section of code

That's perfect! Thanks again!