# Programming HP Calculators/Commands/Branch Commands
## IF

Syntax
Or for "nesting" IF statements:
Or for running IF such that no action is performed should the test be false:
Detail
* IF statements are a set of commands used to test certain equations or inequations. If the result is "true", then a set of actions are performed. If not, no action is performed, or a different set of actions are performed as per ELSE.
* Tests can be combined with AND or OR.
Example
This is a basic example, only checking for one result. Here's a more complex one, although multiple IF...THEN statements are usually best replaced with CASE.
Note that the additional "ELSE IF" commands displayed are not actually commands per se. What is actually happening is that the result of the previous test, when evaluated as "false", moves on to the ELSE result, where it encounters IF, telling it to start another IF statement. This is what the "ELSE END" commands do - they close off the secondary statements nested within the original statement.

## CASE

Syntax
Detail CASE is the command that is used in the place of multiple statements.
The best way of describing this is with a flowchart, seen right. Compare to the lower IF flowchart, and you can see how the CASE command is more efficient when there is more than one option.
Example CASE is especially useful when accepting input from a CHOOSE list. For example:
The first five lines initiate the CHOOSE menu. Of particular note is the 1?A at the start, this sets the default value of the menu to 1 (ie. the first option) and thus ensures that the menu operates correctly (if the value of A begins as outside the acceptable value for the menu, the highlighting will not operate correctly).
CASE initiates the CASE statement. You can then see three branches of this statement; one for each of the three menu options specified in CHOOSE. The basic syntax is:
Importantly (and counter-intuitively), the END at the end of an IF/THEN/END statement within CASE does not contain a full-colon at the end of it! However, the final END completing the CASE does require one.
You should be familiar with the MSGBOXs in each action set, these are a simple way of displaying text in a dialog and FREEZEing at the same time. The final MSGBOX is included to demonstrate what happens once the command completes; it skips to the final END:, so if you had somehow tricked the program into giving a non-valid answer (ie. changing the input for A) the program would just display the final MSGBOX. The same happens after the appropriate clause has been run for A==?.

## RUN

Syntax
Detail
* Ceases running the current program, and runs <program-name> instead.
* You can self-reference using this command, creating an infinite loop.
Dangers
* The program name you reference is case-sensitive; that is, "ProGramNaME" is not the same as "programname".
Example This program is called "INFINITE".
It should be noted that you can "escape", just press ON - this usually cancels the current command from running and this feature is designed specifically to allow users to cancel programs stuck in an infinite loop due to a programming error or malicious intent by the software author.

## STOP

Syntax
Detail
* Exits the program immediately. Compare it to BREAK.
Example This program is called "EXAMPLE".
This command is practically self-explanatory.