CASE: Difference between revisions

From ASCEND
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
The ''CASE'' statement is used within [[WHEN]], [[SWITCH]] and [[SELECT]] blocks. These all handle modeling alternatives within a single definition. The easy way to remember the difference is that
The '''CASE''' statement is used within [[WHEN]], [[SWITCH]] and [[SELECT]] blocks. These all handle modeling alternatives within a single definition. The easy way to remember the difference is that
* [[WHEN]] picks which equations to solve '''when''' discrete variables have certain values
* [[WHEN]] picks which equations to solve '''when''' discrete variables have certain values
* [[SELECT]] '''selects''' which statements to compile based on discrete constants.  
* [[SELECT]] '''selects''' which statements to compile based on discrete constants.  

Revision as of 08:10, 15 August 2010

The CASE statement is used within WHEN, SWITCH and SELECT blocks. These all handle modeling alternatives within a single definition. The easy way to remember the difference is that

  • WHEN picks which equations to solve when discrete variables have certain values
  • SELECT selects which statements to compile based on discrete constants.
  • SWITCH statements handle flow of control in methods, in a slightly more generalized form than the C language switch statement.

See also conditional modelling.