fthiella / icread Goto Github PK
View Code? Open in Web Editor NEWQuick and dirty ICobol .XD file reader
License: Apache License 2.0
Quick and dirty ICobol .XD file reader
License: Apache License 2.0
Before i've found your project, i started by myself the same idea using node js
I managed to make all alphanumeric work however some UNSIGNED DISPLAY fields (with odd precision and scales) did'nt worked.
I guessed its some funny BCD decoding but was unable to figure it out.
I would say that the xdt is wrong but it is working with the ODBC driver from icobol
than i've found your perl code, and i see that you are reading it as 8 bit ###, and finding the decimal placement from the precision, which doesnt work too with my fields.
I also tested your tool as is and got the same results
any idea?
Here is my code
BTW i found the javascript ini parser to be more forgivable then the perl Config:INI
var fs=require("fs"),ini = require('ini')
var template=ini.parse(fs.readFileSync("inventory.xdt")+'')
//console.log(template)
var buf=fs.readFileSync("./INVFILE.XD")
var records=[]
var headerlength=521
var recordlength=266
var recordcount=((buf.length-headerlength)/recordlength)-1
for (i=0;i<recordcount;i++){
var record={}
var raw=buf.slice(headerlength+(i*recordlength),headerlength+(i*recordlength)+recordlength)
for (key in template.Columns)
{
var fld=template[key]
if (fld.Type=='ALPHANUMERIC'){
record[key]=raw.slice(parseInt(fld.Position),parseInt(fld.Position)+parseInt(fld.Length)).toString()
} else if (fld.Type=='UNSIGNED DISPLAY'){
//record[key]=raw.readUIntBE(parseInt(fld.Position),parseInt(fld.Length))/parseInt("1"+("0").repeat(parseInt(fld.Scale)))
record[key+"src"]=raw.slice(parseInt(fld.Position),parseInt(fld.Position)+parseInt(fld.Length))
//record[key+"srcdec"]=[...record[key+"src"]]
record[key]=raw.slice(parseInt(fld.Position),parseInt(fld.Position)+parseInt(fld.Length)).toString()
} else {
console.log(fld,key)
}
}
records.push(record)
//console.log(raw.toString())
//console.log("Prodline",raw.slice(2,3).toString())
}
console.log(records
//.filter(v=>v.IVendorId.includes("BX")).length)
.filter(v=>v.InventoryKey.trim()=="BXWPF")
//.filter(v=>v.ILastRecvdQty.includes("BXBP12"))
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.