Giter VIP home page Giter VIP logo

icread's People

Stargazers

 avatar

Watchers

 avatar  avatar

icread's Issues

Some UNSIGNED DISPLAY are not working

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"))

)

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.