|GSAK (Geocaching Swiss Army Knife)|
Rather than having many If statements, use BeginCase with "case" statements. Implementation is in the form:
BeginCase signals the start of the case block. Case signals the evaluation of an expression that must result in true for the following statements to execute. In this sense, "Case" behaves very similar to the "If" command (they both evaluate an expression which must return true or false)
When a case expression evaluates to true all statements after it are executed until the next case statement, then we go to the EndCase statement. If none of the case statements evaluate to true then the statements after OtherWise are run. The Otherwise statement is optional.
Each case expression should be mutually exclusive (though this is not enforced) and the first matching case statement "wins" to execute that block of code. Only one block of code will ever run between BeginCase and EndCase.
Note: there does not have to be a matching case expression. If there is no OtherWise statement and no matching case expression, then no code in this block will be run.
Like IF and WHILE commands, nesting of BEGINCASE commands is also permitted.
For an example see the EditForm() function
Alpha List Category List
Copyright 2004-2015 CWE Computer Services |