Using Variables in Procedures

How to:

Reference:

A variable is a named storage location capable of containing a certain type of data that can be modified during program execution. You also create variables as part of a class definition or function.

Maintain Data variables have four attributes:

Procedure: How to Create a New Variable

  1. In the Requests & Data Sources panel, or within the Maintain Data Editor, right-click the procedure that you want the variable to be part of and select New variable.

    The New Variable dialog box is displayed.

  2. Type a name for the variable.
  3. Specify a data type for the variable. You can do this in one of two ways:
    • Select a Type using the drop-down list of recently-applied data types.
    • Click the ellipsis button to open the Type Wizard.
  4. Specify an initial value for your variable by clicking the x=? Initialize tab and typing a value in the box (Optional).
  5. Click the Description tab and enter a description (Optional).
  6. Click OK.

    This variable is global, meaning it is available to any code written in this procedure. To use it in another procedure, you must pass it to the other procedure.

Procedure: How to Edit a Variable

  1. Right-click the variable in the Resources & Data panel, and from the shortcut menu, click Edit.
  2. Make any changes in the Edit Variable dialog box and click OK.

Procedure: How to Edit Source Code in a Variable

  1. The WebFOCUS App Studio Maintain Data application generates Maintain Data language code for variables. You can edit this code directly in the Maintain Data Editor.
  2. Right-click the variable in the Resources & Data panel, and from the shortcut menu, click Edit Source.
  3. Make your changes to the code after the DECLARE variable name keyword and before the semicolon (;).

    For more information, see the WebFOCUS App Studio Maintain Data Language Reference content.

Reference: Variable Editor: Declaration Tab

When you create or edit a variable, WebFOCUS App Studio Maintain Data opens the New Variable or Edit Variable dialog box. The Edit Variable dialog box is shown in the following image.
Maintain Edit Variable DB

This dialog box includes the following options:

Name

Contains the name of the variable, argument, or return value you are specifying.

Type

Contains the data type of the variable or argument or return value you are specifying. This information can be entered directly in the field, you can select a recently used data type from the drop-down list, or you can use the ellipsis button to open the Type Wizard. For more information on the Type Wizard, see Using the Type Wizard.

Note: The Type Wizard does not create specifications for the following data types: date-time, packed-decimal, and text. For more information on specifying packed-decimal or text, see the Describing Data With WebFOCUS Language content.

Reference: Variable Editor: x=? Initialize Tab

When you are creating or editing a variable in an existing Maintain Data request, use the x=? Initialize tab in the New Variable or Edit Variable dialog box to enter a value for your variable, as shown in the following image. This value can be any expression. For more information, see Expressions Reference in the App Studio Maintain Data Language Reference content.