Welcome! Log In Create A New Profile

Advanced

reading binary data from IBM POS machine

Posted by Mitchell 
Mitchell
reading binary data from IBM POS machine
January 20, 2012 07:42AM
how to read binary data file "data0001.dat" from IBM POS machine using Windev?
sample binary data file link : binary data file

support pls....
Arie
Re: reading binary data from IBM POS machine
January 20, 2012 09:01AM
Mitchell,
Afaik you need a BUFFER variable when using binary data.
How is this machine connected? Serial, tcpip, other?
Mitchell
Re: reading binary data from IBM POS machine
January 20, 2012 11:52AM
Hi Arie,
I had tried buffer variable, but no luck...

I am writing price checker app using WD14, and run it on IBM POS machine, the data are residing on IBM POS MACHINE as binary file...

I tried floadtext but no luck also...I tried using clarion also but no luck...
Arie
Re: reading binary data from IBM POS machine
January 20, 2012 12:19PM
Do you use fRead() ?
Maybe you can post your code and an show us where it goes wrong?
Mitchell
Re: reading binary data from IBM POS machine
January 20, 2012 12:34PM
Hi Arie,
on my first post link , that's the format of the binary data, generated by IBM POS, I want to read on the same data binary file from my price checker application.

if you can download the data and try to read or put it on table and let me know how possible it is...

i tried all options but no luck....
Gianni Spano
Re: reading binary data from IBM POS machine
January 20, 2012 12:38PM
Hello Mitchell

Your link to download the file is not available.

Pls, can you check the link?

Gianni
Mitchell
Re: reading binary data from IBM POS machine
January 20, 2012 01:48PM
Hi Arie,
.dat extension are block by the ftp provider server...

you can download on this link [www.waysatech.com]

and after downloading, rename the file into "eamitemr.rar into "eamitemr.dat"
Piet van Zanten
Re: reading binary data from IBM POS machine
January 20, 2012 02:36PM
Hi Mitchell,

Just to be shure: you know that you need to unrar (=unzip) the file before you can use it?

Regards,
Piet
Mitchell
Re: reading binary data from IBM POS machine
January 20, 2012 02:55PM
Hi piet,
thanks, but its not a compressed file, i just rename it to .rar for the reason that it will not be block by ftp, .dat extension will be block by ftp.


regards
mitch
Arie
Re: reading binary data from IBM POS machine
January 20, 2012 03:05PM
Mitchell,
this piece of code will read the file block-by-block and writes these bytes to a copy-file.
Instead of writing you can do whatever you want.
Main thing here is: you have to know the format of the data inside this file. I suppose you (or IBM) have documentation about this file.
I tried reading the file line-by-ine, but that doesn't work. Apparently the file does not hold lines of data ended by carriage return and/or linefeeds.


nFileID is int
nFileID2 is int
sStringRead is string fixed on 1024

// Opening the file
nFileID = fOpen("D:\Dev\Testing\eamitemr.dat", foRead)
nFileID2 = fOpen("D:\Dev\Testing\eamitemr_copy.dat", foWrite+foCreate)
IF nFileID <> -1 THEN

	// Read the file
	WHILE fRead(nFileID, 1024, &sStringRead) > 0
		// write a copy
		fWrite(nFileID2,sStringRead,1024)
	END

	// Close the files
	fClose(nFileID)
	fClose(nFileID2)
ELSE
	Error()
END

Mitchell
Re: reading binary data from IBM POS machine
January 20, 2012 03:19PM
Thanks Arie,
I did the same thing what you have done, but the main thing is I don't know the IBM machine coding, some are telling that by using a QBASIC or DOS QBASIC will read the binary file.... but where to find those oldies?

thanks for the effort....
Andres Sanchez <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: reading binary data from IBM POS machine
January 20, 2012 04:32PM
Mitchell:

Is not that you cannot read the file, the thing is that you need the file structure in order to read it correctly. I see some TEXT embedded i suppose is the item description, the price should be there in binary format, if there is only the price, I guess you can do it by try and error, but you need to know the correct price of some items, in order to check if the result is correct.

Andres Sanchez
Arie
Re: reading binary data from IBM POS machine
January 20, 2012 04:45PM
OK.
But a binary format as such isn't a standard. It just tells you the file holds all kinds of characters including chr(0) instead of lines of texts (ascii).
You need to contact IBM. They can tell you how to interpret all these characters.

I had something like this reading Unitech handheld database files:
First xxx bytes are a header containing the recordlayout.
After that, you get chunks of bytes for each record.
First nn bytes of each record tell you the length of that particular record.
WIth this info you can read alle records one after one.
Steve M
Re: reading binary data from IBM POS machine
January 20, 2012 10:49PM
Given that this is an IBM POS system, are you sure the data is in ASCII format and not EBCDIC ?

Steve
Mitchell
Re: reading binary data from IBM POS machine
February 03, 2012 10:24AM
for sure this is an EBCDIC format, and i search in google for 3 days now to find a tools to convert this file into ascii or any database readable format....

still not solved.... :-(
Steve M
Re: reading binary data from IBM POS machine
February 03, 2012 11:49PM
What about these links?

VB Example:
[www.planet-source-code.com]
[support.microsoft.com]
[www.codeproject.com]

EBCDIC / ASCII Translation Tables:
[www.simotime.com]

Steve
Mitchell <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: reading binary data from IBM POS machine
February 04, 2012 11:20AM
I am not in .net development, can someone help me to convert the .net code below into windev?

// Start of Code
''' <summary>
''' Translates a file from EBCDIC to ASCII.
''' </summary>
''' <param name="sourceEbcdicFilePath">The full path of the EBCDIC file.</param>
''' <param name="newAsciiFilePath">The full path of the new ASCII file
''' that will be created.</param>
''' <remarks></remarks>
Private Sub TranslateFile(ByVal sourceEbcdicFilePath As String, _
ByVal newAsciiFilePath As String)

'Set the encoding to the EBCDIC code page.
Dim encoding As System.Text.Encoding = _
System.Text.Encoding.GetEncoding(37)

'Set this to the length of an EBCDIC line or block.
Dim lineLength As Integer = 134

'Buffer used to store characters read in from the statement input file.
Dim buffer(lineLength - 1) As Char

'Open the EBCDIC file for reading using the EBCDIC encoding.
Dim reader As New IO.StreamReader(sourceEbcdicFilePath, encoding)

'Open a file to write out the data to.
Dim writer As New IO.StreamWriter(newAsciiFilePath, _
False, System.Text.Encoding.Default)

'This is a string to store the translated line.
Dim strAscii As String = String.Empty

'This variable increments every time a block of data is read
Dim iLoops As Integer = 0

'Loop through the EBCDIC file.
Do Until reader.EndOfStream = True

'Read in a block of data from the EBCDIC file.
reader.ReadBlock(buffer, 0, lineLength)

'Translate the string using the EBCDIC encoding.
strAscii = encoding.GetString(encoding.GetBytes(buffer))

'Write the translated string out to a file.
writer.WriteLine(strAscii)

'Only call DoEvents every 1000 loops (increases performance)
iLoops += 1
If iLoops = 1000 Then

Application.DoEvents()

iLoops = 0 'reset

End If

Loop

'Close files.
reader.Close()
writer.Close()

'Release resources.
reader.Dispose()
writer.Dispose()

End Sub

// End of Code

the actual link copied from this: [www.codeproject.com]
Andres Sanchez <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: reading binary data from IBM POS machine
February 08, 2012 05:31AM
Mitchell:

I do not believe your file is in EBCIDIC format. If you look the file with a hex editor you should see text, it is the description of the items.

If the file were EBCIDIC you should not recognize any text even with a hex editor.

the reason you cannot recognize the other data is that they are real numbers in binary format. I believe that they are the unit price and or cost information.

Arie is right with this:
Quote
I had something like this reading Unitech handheld database files:
First xxx bytes are a header containing the recordlayout.
After that, you get chunks of bytes for each record.
First nn bytes of each record tell you the length of that particular record.
WIth this info you can read alle records one after one.


Andres Sanchez



Edited 1 time(s). Last edit at 02/08/2012 05:34AM by Andres Sanchez.
Andres Sanchez <img src="images/world-s.png" class="global" alt="Global User" title="Global User" />
Re: reading binary data from IBM POS machine
February 08, 2012 06:58AM
STData is structure
&nbsp;&nbsp;&nbsp;rPrice is real
&nbsp;&nbsp;&nbsp;sDescription is string fixed on 18
END
arrData is array of STData

nFileID is int
sHeader is string fixed on 512
s is composed of
&nbsp;&nbsp;&nbsp; //sFiller is string ASCIIZ on 1
&nbsp;&nbsp;&nbsp; rPrice1 is int
&nbsp;&nbsp;&nbsp; rPrice2 is int
&nbsp;&nbsp;&nbsp; rPrice3 is int
&nbsp;&nbsp;&nbsp; rPrice4 is int
&nbsp;&nbsp;&nbsp; rPrice5 is int
&nbsp;&nbsp;&nbsp; rPrice6 is int
&nbsp;&nbsp;&nbsp; rPrice7 is int
&nbsp;&nbsp;&nbsp; //sFiller2 is string ASCIIZ on 20
&nbsp;&nbsp;&nbsp; sDescription is string ASCIIZ on 18
END

// Opening the file
nFileID = fOpen("C:\Users\Andres\Downloads\eamitemr.dat", foRead)
IF nFileID <> -1 THEN

&nbsp;&nbsp;&nbsp; // Read the file
&nbsp;&nbsp;&nbsp; fRead(nFileID, 512, &sHeader)
&nbsp;&nbsp;&nbsp; WHILE fRead(nFileID, 46, &s) > 0
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n is int = ArrayAdd(arrData)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arrData[n].rPrice = s.rPrice1
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; arrData[n].sDescription = s.sDescription
&nbsp;&nbsp;&nbsp; END

&nbsp;&nbsp;&nbsp; // Close the files
&nbsp;&nbsp;&nbsp; fClose(nFileID)
ELSE
&nbsp;&nbsp;&nbsp; Error()
END

This should read some data. You will have to know some data in order to check which data is correct and if the binary's are 4-byte, 8-byte or ints.

Best Regards

Andres Sanchez
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: