VSCode warning in RPG-LE ("Subroutines should not be defined in the global scope")

51 Views Asked by At

When I write free rpg code in VS Code (with the usual extensions for IBM i), I get a warning that subroutines should not be declared in the global scope.

I want to keep working with subroutines, only using procedures when needed.

2

There are 2 best solutions below

3
Victor Pomortseff On

To avoid such a warning in a full free RPG, you can do this:

ctl-opt main(Main);

...

dcl-proc Main;
  dcl-pi *n;
    ...
  end-pi;

  ...

  return;

  begsr ...;
    ...
  endsr;
end-proc;

This way you can use subroutines inside Main (as well as inside any other procedure) and they won't be in the global scoupe

1
Michiel de Ruyter On

All,

sorry as I may have posted this question prematurely. I found the answer to my own question, and maybe this will help others.

The solution is alter a line in the lint code:

{
  "indent": 2,
  "PrototypeCheck": true,
  "NoOCCURS": true,
  "NoSELECTAll": true,
  "UppercaseConstants": true,
  "IncorrectVariableCase": true,
  "NoSQLJoins": true,
  "PrettyComments": true,
  **"NoGlobalSubroutines": false**,
  "NoExternalTo": [
    "QCMD",
    "QP2TERM",
    "QSH",
    "SYSTEM",
    "QCMDEXC"
  ]
}

I did restart VSCode to make sure it was active.