Is there a user-friendly way to get a Mathematica notebook to choose between
If statements according to the value of a variable?
I would like the user to be able to choose one of several conditions and also (perhaps somewhat later) to be able to write their own condition if they wish.
At the moment a chunk of the code looks like this:
(* If [condition 1] *) (* Description of what this does *) (* If [condition 2] *) (* Description of what this does *) (* If [condition 3] *) (* Description of what this does *) (* If [condition 4] *) (* Description of what this does *) ...
and the user chooses which condition they wish to apply and removes its commenting out, leaving all the other conditions commented out and therefore not applied.
This would be easier if I could describe in a comment what each condition is for and then ask the user to set a single variable, like this:
(* Condition 1 does [description] Condition 2 does [description] Condition 3 does [description] Condition 4 does [description] *) Please set the variable COND to determine which condition is used. *) COND=2 ;
Then all the user has to do is change that 2 to the number for whatever condition they want to use. They don't have to delete or add any asterisks or parentheses.
The question is how can I make the program choose among the
If statements according to the value of COND? I need the
If statements to be described as neatly as they are in the existing code, so that the user can add a new one in later. Surrounding them with too many parentheses and commas could cause confusion. Then if the user writes a new
If statement they should be able to assign it its own number. For example here they would call it condition 5.