- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: best way to pause a section of code
That's perfect! Thanks again!