Using Variables in Procedures
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:
- A name
- A data type (for example: integer, alphanumeric, or a user-defined class)
- A value (optional)
- A description (optional)
Create a New Variable
- Procedure
- 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.
- Type a name for the variable.
- 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.
- Specify an initial value for your variable by clicking the x=? Initialize tab and typing a value in the box (Optional).
- Click the Description tab and enter a description (Optional).
- 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.
Edit a Variable
- Procedure
- Right-click the variable in the Resources & Data panel, and from the shortcut menu, click Edit.
- Make any changes in the Edit Variable dialog box and click OK.
Edit Source Code in a Variable
- Procedure
- 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.
- Right-click the variable in the Resources & Data panel, and from the shortcut menu, click Edit Source.
- 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.
Variable Editor: Declaration Tab
This dialog box includes the following options:
Contains the name of the variable, argument, or return value you are specifying.
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 Data Source Stacks in Procedures.
Variable Editor: x=? Initialize Tab