Tip of the Month (July 2006) Controlling a Macro by Using an "if" Expression in a SKIP Command Button When your macro is running, you may want to skip some steps based on some condition. For example, you may have a macro that creates a total and, if an total is more than $100.00, you may want to apply a 10% discount. You can do this using a SKIP command button as one of the steps of your macro. There are two kinds of SKIP's. The first skips a specific number of steps in your macro. The second (introduced in Visual CE 12.0) allows you to skip to a specific place in your macro.
Skipping a Specific Number of Steps When skipping a specific number of buttons, the number of buttons to skip would be designated by an "if" expression:
The second step tests the total and, if it is less than $100.00, it skips over one step (the step that applies a 10% discount). In the example above the "else" part of the "if" was just a very simple expression (in particular, just 1). But the "else" part can be any expression, even another "if" statement. For example, you may want to apply a 75% discount if the total is more than $1000.00 and apply a 10% discount if the total is is between $100.00 to $1000.00:
Note that by nesting one "if" inside another, you effectively create "if ... else if ... else" expressions. Skipping to a Specific Place in Your Macro Starting in Visual CE 12.0, you can label specific places in your macro and, when the macro is running, jump right to that place. Using this technique, the first macro above can be rewritten as:
The second step tests the total and, if it is less than $100.00, it skips right to the label. |