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 variables have four attributes:


Top of page

x
Procedure: How to Create a Variable in a Procedure
  1. Select the procedure that you want the variable to be part of.
  2. Right-click the procedure, click New in the shortcut menu, and click Variable (Declare) in the submenu.

    or

    Click the New variable button on the Maintain Objects toolbar.

  3. In the New Variable dialog box, type a name for your variable in the Name box.
  4. Specify a data type for your variable. You can do this in one of two ways:
    • Click the ellipsis button ellipsis button to open the Wizard. For more information, see Using the Type Wizard.

      or

    • The Type field contains a drop-down list of recently-applied data types. Select one from the list.
  5. Optionally, specify an initial value for your variable by clicking the x=? Initialize tab and typing a value in the box.
  6. Optionally, click the Description tab and type a description.
  7. 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. For more information, see Passing Parameters Between Maintain Procedures: FROM...INTO.


Top of page

x
Procedure: How to Edit a Variable
  1. Right-click the variable in the Project Explorer.
  2. In the shortcut menu, click Edit.
  3. Make any necessary changes in the Edit Variable dialog box.
  4. Click OK.

Top of page

x
Procedure: How to Edit Source Codes in a Variable

WebFOCUS Maintain generates Maintain language code for variables. You can edit this code directly in the Procedure Editor.

  1. Right-click the variable in the Project Explorer.
  2. In the shortcut menu, click Edit Source.
  3. Make your desired changes to the code after the DECLARE variablename keyword and before the semicolon (;).

    For more information, see the Maintain Language Reference manual.

  4. Close the Procedure Editor.

Note: You can obtain Help on any Maintain language keyword by selecting the keyword and pressing F1 key.


Top of page

x
Procedure: How to Move a Variable to Another Procedure
  1. In the Project Explorer, ensure that you can see both the variable and the procedure to where you want to move it.
  2. Select the variable and drag it to the procedure to where you want to move it.

Top of page

x
Procedure: How to Copy a Variable to Another Procedure
  1. In the Project Explorer, ensure that you can see both the variable and the procedure to where you want to move it.
  2. Select the variable, hold down the Ctrl key, and drag the variable to the procedure to where you want to move it.

Top of page

x
Reference: Variable Editor: Declaration Tab

When you create or edit a variable, WebFOCUS Maintain opens the New Variable or Edit Variable dialog box.

When you define a function argument or return value from the Edit Function dialog box, define a variable as part of a class, or define a computed column for a data source stack, WebFOCUS Maintain opens the Function Parameter or the Function Return, or the Computed Stack Column dialog box. This dialog box looks like the Edit Variable dialog box, shown in the following image, but without the x=? Initialize tab.

Edit Variable dialog box

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. If you want to specify a data type, you can select a recently used data type from the list or type in the specification for the data type.

ellipsis button

Opens the Type Wizard, where you can specify a new data type for the argument or return value. For more information, 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 manual.


Top of page

x
Reference: Variable Editor: x=? Initialize Tab

When you are creating or editing a variable, 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 image below. This value can be any expression. For more information, see Expressions Reference in the Maintain Language Reference manual.

Edit Variable dialog box


Top of page

x
Reference: Variable Editor: Description Tab

When you are creating or editing a variable, function argument, function return value, or computed data source stack column, use the Description tab to enter a description, as shown in the image below.

You can view the description of a variable in the Project Explorer with the Show description command. For more information, see How to View the Description of a Procedure Component.

Edit Variable dialog box


WebFOCUS