codefori / vscode-rpgle

RPGLE language tools for VS Code
MIT License
39 stars 20 forks source link

Free Form Conversion of LIKE Definitions with a Length Increment/Decrement Result in an Invalid Syntax #241

Closed BrianGodsend closed 1 year ago

BrianGodsend commented 1 year ago

When a stand-alone or subfield is defined LIKE another variable, the length of the field can be incremented or decremented by including a +n or -n value in the length position of the D-Spec. When converting these lines to **FREE, the +n or -n length is treated as the variable's field length, but should be moved to the optional second parameter of the LIKE() function.

Note that a leading + or - on the length adjustment is required.

Fixed form example:

     d char7_t         s             10a   template
      *
     d char11          s             +4    like(char7_t)
     d char5           s             -2    like(char7_t)

       *inLR = *ON;
       return;

After **FREE conversion:

**FREE
dcl-s char7_t      Char(10)   template;

// The following two lines were created by the "Convert to Free Format" and have invalid syntax
dcl-s char11       Char(+4)   like(char7_t);
dcl-s char5        Char(-2)   like(char7_t);

// These two lines are the correct format of the like declarations
// Note that increment/decrement length _must_ be preceded by either a "+" or "-".
dcl-s char11                  like(char7_t: +4);
dcl-s char5                   like(char7_t: -2);

*inLR = *ON;
return;

For reference, I am running the latest version of VS Code on an up-to-date Windows 11 Pro 64-bit system. The Code for IBM i version is v2.0.2 and the RPGLE extension is v0.20.2.

worksofliam commented 1 year ago

Wrong extension. You want vscode-rpgfree.

BrianGodsend commented 1 year ago

Sorry for the incorrect reporting.

Anyone accidentally stumbling on this should note that not only did I report this in the wrong project, but, it is a duplicate of issue number BrianGarland/vscode-rpgfree#48.