A variable is used in a expression, but was neither passed as argument nor set before.

Declare or define as argument the variable you need to use, or remove the reference to the undefined variable.

NOTE: You can enable a Best Practice option of this rule to apply following additional validations:

Noncompliant Code Example

Following code will compile, but on runtime the Add method will fail with "UNDEFINED error" message.

Method Add()
{
    Set a=1
    Set c=a+b // b is UNDEFINED
    Write !,c
}

Compliant Solution

Method Add(b AS %Numeric)
{
    Set a=1
    Set c=a+b
    Write !,c
}

Exceptions

Methods with ProcedureBlock=0 are not checked because those methods can use variables from global scope.

It is not necessary to define "i" when calling $I(i) as it intiates the variable automatically.

A variable passed by reference does not need to be initialized as it is expected to be set inside the method called.

A variable used in a macro does not need to be initialized neither declared as it is expected to be set inside the macro.