Skip to content

Commit

Permalink
more bindec and packed fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Garland committed Jan 6, 2022
1 parent 4026e96 commit 80b6c65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-rpgfree",
"displayName": "RPGLE Free",
"description": "Visual Studio Code extension to convert fixed format RPGLE to free format",
"version": "0.0.20",
"version": "0.0.21",
"keywords": [
"ibmi",
"rpgle",
Expand Down
21 changes: 19 additions & 2 deletions src/specs/D.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ module.exports = {
type += `(` + len + `)`;
break;
case `B`:
type = `Bindec` + `(` + len + `)`;
if (pos != ``) {
// When using positions binary decimal is only 2 or 4
// This equates to 4 or 9 in free
if (Number(len) == 4) {
type = `Bindec(9)`;
} else {
type = `Bindec(4)`;
}
} else {
// Not using positions, then the length is correct
type = `Bindec` + `(` + len + `)`;
}
break;
case `C`:
type = `Ucs2` + `(` + len + `)`;
Expand Down Expand Up @@ -122,7 +133,13 @@ module.exports = {
type = `Ind`;
break;
case `P`:
type = `Packed` + `(` + String(Number(len)*2+1) + `:` + decimals + `)`;
if (pos != ``) {
// When using positions packed length is one less than double the bytes
type = `Packed` + `(` + String(Number(len)*2-1) + `:` + decimals + `)`;
} else {
// Not using positions, then the length is correct
type = `Packed` + `(` + len + `:` + decimals + `)`;
}
break;
case `S`:
type = `Zoned` + `(` + len + `:` + decimals + `)`;
Expand Down

0 comments on commit 80b6c65

Please sign in to comment.