Declaring an Unknown Local Identifier as a Local Variable

When editing a JADE method, you can declare an unknown local identifier as a local variable.

To declare a local identifier as a local variable

  1. Position the cursor on the identifier.

  2. Right-click and then select the Declare Local Variable command from the Refactor submenu of the Edit menu.

  3. If the identifier is assigned by an expression or it is used as an assignment value, the type of the local variable is determined from that expression.

The type is determined by the type of a foreach variable using the type of expression in the in section of the foreach instruction. If the in expression is:

If the type of the expression cannot be determined, the Declare Local Variable Name dialog is displayed, prompting you to specify or select in the Variable Type combo box the primitive type of the variable and then click the OK button.

Text in the status line displays the result of the action; for example:

Local variable docExample : String was added to the method vars

A local variable of the determined or selected type is added to the vars section of the method, which is created if it does not exist. The cursor remains at its previous position.

Examples of an unknown indx local identifier in a method are as follows.

indx := 0;

posn := indx;

Positioning the cursor over indx, where this is undefined, would result in the following code fragment.

vars
...
indx : Integer;
begin
...