• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Using the If Command

Once you've figured out what kind of conditional step you need, you create the script in ScriptMaker. The syntax for a simple If statement to print a statement isn't much more complex than plain English.

To use the If command step:

Choose Scripts > ScriptMaker.

When the Define Scripts dialog box appears, type a name for the script (in this case Account Balance) and click Create.

The Script Definition dialog box will appear with the default script in the assembly window on the right. Click Clear All to delete the default steps.

From the Control category in the left window, double-click If (Figure 8.1).

Figure 8.1. Double-click If to add it to the assembly window.

When you add If to a script, you will see two lines in the script steps: If and End If (Figure 8.2). End If is added by default every time you choose If to mark the place in the script where the If steps end. Everything you want in your If statement must be placed between If and End If.

Figure 8.2. When you add an If step to a script, the End If is added automatically.

In the Options section, click Specify to bring up the Specify Calculation dialog box.

The If step uses the same formula builder you use to create a Calculation Field (see Chapter 4).

In the field list on the left, scroll to find your field (we're using Balance Due). Double-click to add it to the formula box (Figure 8.3).

Figure 8.3. Choose the field you want the script to test in the If statement.

Choose the greater than (>) symbol from the Operators scrolling list by double-clicking it.

Type a zero (0), then click OK (Figure 8.4).

Figure 8.4. Type a zero manually in the formula builder.

The Script Definition dialog box now displays the highlighted If statement with its condition (Figure 8.5).

Figure 8.5. Your conditional statement is added automatically to the If statement brackets.

From the step list on the left, double-click the action you want performed. In this example, we chose Perform Script, because we want to run an existing print statement script we created (Figure 8.6).

Figure 8.6. Steps inside other steps are indented.

The new step is added below the If step. It's also indented from the left to show that it's inside the If step. This line is just a standard script command. (For more information about Perform Script, see Chapter 7.) Any script steps can be placed inside an If step—even another If step.

From Options, choose the script you want performed if there's a balance due (Figure 8.7). Since you don't have anything else you want the script to do if there's no balance due, the If statement is finished.

Figure 8.7. This step runs the sub-script “Print Statement.”

Click OK, then Done to close ScriptMaker.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint