Git Product home page Git Product logo

logicgoose's Introduction

logicgoose

A simple class that will construct and deconstruct buffers (which is actually just a single) to be passed into an ILE program. This is particularly useful when it comes to working with data structures.

Don't fancy writing all this code manually? Check out this nifty tool to do it for you!

Example

const inputDS = new rpgleDS(...);
const responseDS = new rpgleDS(...);

static async getHistoryHeader(header) {
  console.log(inputDS.getSize());
  console.log(responseDS.getSize());

  const inBuffer = inputDS.toBuffer(header);

  const results = await db2.callProcedure(SCHEMA, 'PROGRAM', [inBuffer, undefined]);

  return responseDS.fromBuffer(results.parameters[1]);
}

JS Types and ILE Types

JS Type ILE Type
String Char
Number Zoned
Boolean Char(1) / Ind

Simple types example

{
  "name": "25",
  "number": 25
}
const base = new rpgleDS(
[
    {
        "name": "name",
        "length": 25
    },
    {
        "name": "number",
        "length": 11,
        "decimals": 2
    }
]
);
Dcl-Ds base Qualified Template;
  name Char(25);
  number Zoned(11:2);
End-Ds;

Many dimentions

The class can easily handle many levels of structs (likeds(x) qualified).

{
  "name": "25",
  "number": 25,
  "substructA": {
    "a": "10",
    "b": 10
  }
}
const substructA = new rpgleDS(
[
    {
        "name": "a",
        "length": 10
    },
    {
        "name": "b",
        "length": 11,
        "decimals": 2
    }
]
);

const base = new rpgleDS(
[
    {
        "name": "name",
        "length": 25
    },
    {
        "name": "number",
        "length": 11,
        "decimals": 2
    },
    {
        "name": "substructA",
        "like": substructA
    }
]
);
Dcl-Ds substructA Qualified Template;
  a Char(10);
  b Zoned(11:2);
End-Ds;

Dcl-Ds base Qualified Template;
  name Char(25);
  number Zoned(11:2);
  substructA LikeDS(substructA);
End-Ds;

Struct arrays

We also support substructs that are arrays.

{
  "name": "25",
  "number": 25,
  "substructA": [{
    "a": "10",
    "b": 10
  }]
}
const substructA = new rpgleDS(
[
    {
        "name": "a",
        "length": 10
    },
    {
        "name": "b",
        "length": 11,
        "decimals": 2
    }
]
);

const base = new rpgleDS(
[
    {
        "name": "name",
        "length": 25
    },
    {
        "name": "number",
        "length": 11,
        "decimals": 2
    },
    {
        "name": "substructA",
        "like": substructA,
        "dim": 5
    }
]
);
Dcl-Ds substructA Qualified Template;
  a Char(10);
  b Zoned(11:2);
End-Ds;

Dcl-Ds base Qualified Template;
  name Char(25);
  number Zoned(11:2);
  substructA LikeDS(substructA) Dim(5);
End-Ds;

logicgoose's People

Contributors

worksofliam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.