Creating and Using a Conditional Object

Description

A conditional object is a multi-level rectangular frame used to conditionally display and hide groups of objects. Conditional objects behave like tabbed objects, except that instead of tabs, each page is automatically selected by Alpha Anywhere based on the expressions you enter. A page is selected when the expression evaluates to TRUE. If no expression evaluates to true, the default page is shown.

This example is appropriate for Alpha Anywhere Version 5. For an explanation and example of the procedure in Alpha Anywhere, see Placing a Conditional Object  in the Form Design section of the Alpha Anywhere User Guide.

The COND1 conditional object has four pages that become visible or invisible depending on the value of the variable vcLayoutType.

The form uses four variables to keep track of the user's selections.

  •  vcLayoutType

    Records whether the user has selected Reports, Labels, or Letters in the DROPDOWN1 list box.

  •  vcReports

    Records the user's report selection in the Listbox1 list box.

  •  vcLabels

    Records the user's label selection in the Listbox2 list box.

  •  vcLetters

    Records the user's letter selection in the Listbox3 list box.

 Procedure: Creating the Form's Variables

The COND1 conditional object assumes that the developer has created the necessary form variables:

  1. In the Form menu select Variables....

  2. Create the vcReports, vcLetters, and vcLabels variables as Level "Layout" and type "Character".

  3. Enter the variables' initial values of "Customer List", "Letter to Customers", and "Customer Labels". These values match entries in Listbox1, Listbox2, and Listbox3 and provide valid default selections.

  4. Create the vcLayoutType variable as Level "Session" and type "Character".

  5. Enter the default value of "Report" for vcLayoutType. This value matches a value in the Dropdown1 list box and provides a valid default selection.

  6. Click the OK button to return to the Form Editor.

 Procedure: Creating the COND1 Conditional Object

The following procedure assumes that the developer has opened the form in the Form Editor. Follow these instructions to create a conditional object similar to COND1 :

  1. Select the conditional object tool on the Toolbar.

  2. Sketch the object's dimensions on the form.

  3. Right click on the object and select Properties....

  4. Click the button on the first line of the Condition column.

  5. In the Expression Builder enter the following expression and click the OK button.

    Var->vcLayoutType = "Reports"
  6. Enter "Reports" into the first line of the Label column.

  7. Click the button on the second line of the Condition column.

  8. Enter the expression below and click the OK button.

    Var->vcLayoutType = "Labels"
  9. Enter "Labels" into the second line of the Label column.

  10. Click the button on the third line of the Condition column.

  11. Enter the expression below and click the OK button.

    Var->vcLayoutType = "Letters"
  12. Enter "Letters" into the third line of the Label column.

  13. Click the OK button to return to the Form Editor.

  14. Right click the conditional object to display the following menu.

    Alpha Anywhere automatically created the Default page.
  15. Right click the conditional object.

  16. Select Reports to display the Reports page.

  17. Place a list box on the page.

  18. On the Setup tab of the Field Properties dialog box, select "VAR->vcReports" in the Field list.

  19. Click the Choices tab.

  20. Select "Computed Automatically" from the Choices for control are list.

  21. Select "Report Layouts" in the Source list.

  22. Click the OK button to return to the Form Editor.

  23. Right click the conditional object.

  24. Select Letters to display the Letters page.

  25. Place a list box on the page.

  26. On the Setup tab of the Field Properties dialog box, select "VAR->vcLetters" in the Field list.

  27. Click the Choices tab.

  28. Select "Computed Automatically" from the Choices for control are list.

  29. Select "Letter Layouts" in the Source list.

  30. Click the OK button to return to the Form Editor.

  31. Right click the conditional object.

  32. Select Labels to display the Labels page.

  33. Place a list box on the page.

  34. On the Setup tab of the Field Properties dialog box, select "VAR->vcLabels" in the Field list.

  35. Click the Choices tab.

  36. Select "Computed Automatically" from the Choices for control are list.

  37. Select "Label Layouts" in the Source list.

  38. Click the OK button to return to the Form Editor.

See Also