POS file formats

Make comments, ask questions, or just complain about the software on this site. Or comment on any educational software.
Please note that by clicking on links that may appear in these posts that you may be leaving the Dale Harris Educational Software website and that the content of those sites is the sole resposibility of the authors of those sites.

Moderators: daleadmin, Dale Harris, Alan, Andrew

User avatar
Dale Harris
Forum Owner
Posts: 1171
Joined: Sun Dec 28, 2003 10:19 pm
Location: Chicago
Contact:

POS file formats

Post by Dale Harris » Sun Jan 01, 2006 1:55 pm

Want to write your own software to to enhance your use of the POS software? Then you will probably want to know how to access data from the POS data files.

Please note that many things in the data files are restricted, for example passwords, sales figures, transactions numbers, taxes paid, PIN numbers, etc. If others know how to access those things then they would be able to write software to change those things. For example software could be written to to reduce the taxes collected for a day so that a store could pay less tax than is actually owed. This would then make the Cash Register software untrustworthy and therefore useless.

But if you want to access non-sensitive information you will learn how on this page http://keyhut.com/fformat.htm
Dale

Peter
Posts: 1
Joined: Fri Feb 17, 2006 1:33 am

Post by Peter » Fri Feb 17, 2006 1:37 am

The below code will export the Barcode, Description and Inventory of your store for easy export into other software.

I'm currently working on an PHP/mySQL import program.

Code: Select all

DIM TB$(13)
FL$ = "C:\POS\POSFILENAME": COLOR 15, 1: CLS
OPEN FL$ + ".POS" FOR RANDOM AS 1 LEN = 80
OPEN FL$ + ".CSV" FOR OUTPUT AS #7
FIELD 1, 70 AS A$, 1 AS B$: GET 1, 1
RCC = ASC(B$): CLOSE 1:  'Get number of lines that are supposed to be in the stock table.
IF RCC = 32 THEN RCC = 15
RCC = (RCC - 10) * 1000
OPEN "R", 1, FL$ + ".TBL", 120: FIELD 1, 7 AS A$, 1 AS B$, 1 AS C$: GET 1, 1
RC = (ASC(C$) - 10) * 1000:  'Get number of lines that actually are in the stock table.
IF A$ <> "VERSION" OR B$ <> CHR$(6) THEN PRINT "Not stock table version 6": END
CLOSE 1
IF RCC < RC THEN RC = RCC
OPEN "R", 2, FL$ + ".TBL", 120
FIELD 2, 24 AS TB$(0), 7 AS TB$(1), 1 AS TB$(5), 1 AS TB$(2), 4 AS TB$(3)
FIELD 2, 37 AS NULL$, 4 AS TB$(4), 1 AS TB$(6), 4 AS TB$(7), 18 AS TB$(8)
FIELD 2, 64 AS NULL$, 4 AS TB$(9), 4 AS TB$(10), 4 AS TB$(11), 30 AS TB$(12)
FIELD 2, 106 AS NULL$, 4 AS TB$(13)
FIELD 2, 120 AS TB$
FOR A = 1 TO RC
   GET 2, A + 1
   CLS
   IF RIGHT$(TB$(8), 14) <> "              " THEN WRITE #7, RIGHT$(TB$(8), 14),TB$(0), CVL(TB$(7)) / 1000
NEXT
CLOSE
END

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re:

Post by roxy99 » Tue Dec 23, 2008 4:36 pm

Peter wrote:The below code will export the Barcode, Description and Inventory of your store for easy export into other software.

I'm currently working on an PHP/mySQL import program.

Code: Select all

DIM TB$(13)
FL$ = "C:\POS\POSFILENAME": COLOR 15, 1: CLS
OPEN FL$ + ".POS" FOR RANDOM AS 1 LEN = 80
OPEN FL$ + ".CSV" FOR OUTPUT AS #7
FIELD 1, 70 AS A$, 1 AS B$: GET 1, 1
RCC = ASC(B$): CLOSE 1:  'Get number of lines that are supposed to be in the stock table.
IF RCC = 32 THEN RCC = 15
RCC = (RCC - 10) * 1000
OPEN "R", 1, FL$ + ".TBL", 120: FIELD 1, 7 AS A$, 1 AS B$, 1 AS C$: GET 1, 1
RC = (ASC(C$) - 10) * 1000:  'Get number of lines that actually are in the stock table.
IF A$ <> "VERSION" OR B$ <> CHR$(6) THEN PRINT "Not stock table version 6": END
CLOSE 1
IF RCC < RC THEN RC = RCC
OPEN "R", 2, FL$ + ".TBL", 120
FIELD 2, 24 AS TB$(0), 7 AS TB$(1), 1 AS TB$(5), 1 AS TB$(2), 4 AS TB$(3)
FIELD 2, 37 AS NULL$, 4 AS TB$(4), 1 AS TB$(6), 4 AS TB$(7), 18 AS TB$(8)
FIELD 2, 64 AS NULL$, 4 AS TB$(9), 4 AS TB$(10), 4 AS TB$(11), 30 AS TB$(12)
FIELD 2, 106 AS NULL$, 4 AS TB$(13)
FIELD 2, 120 AS TB$
FOR A = 1 TO RC
   GET 2, A + 1
   CLS
   IF RIGHT$(TB$(8), 14) <> "              " THEN WRITE #7, RIGHT$(TB$(8), 14),TB$(0), CVL(TB$(7)) / 1000
NEXT
CLOSE
END



Is this QBasic or a DOS bat file? I'd like to do the sale tyoe of export with the sales details.

User avatar
Andrew
Site Administrator
Posts: 822
Joined: Sun Dec 28, 2003 3:40 pm
Location: New Zealand

Re: POS file formats

Post by Andrew » Tue Dec 23, 2008 10:28 pm

All the examples are in QuickBasic, unless otherwise noted.
Image
DHPOS Veteran (from v3.46, July 2002)

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Sun Dec 28, 2008 12:20 pm

I have successfully programmed in Python a utility import program to retreive customer information from a text csv file. For those willing to download the Pyhton interpreter this may be useful.

Code: Select all

import re
import binascii
custcst='c:/pos/test.cst'   #replace c:/pos/test.cst with actual .cst file
custcsv='c:/pos/book1.csv'  # and csv source containing customer info to import
salehistory="00"*102
hb=binascii.a2b_hex(salehistory)

custselectprint=True     #Print sample customer in cst file
recordselect=61           #test print record
testprint=False           #test print only set True

importdata=False          #If actual import set True then routine will import ***BACKUP CST SOURCE FIRST**


createdate='2008122720081227' ## Should be 2 times yyyymmddyyymmdd
p = re.compile(r'[^a-zA-Z0-9@\.\-]')  # Regex to filter out non-alphanumeric data


##Each block of customer data has length of 410 characters
recordplace=(recordselect-1)*410 
pointers=[                          \
    [0,78,'ID'],                    \
    [78,39,'Name'],                 \
    [117,39,'Address 1'],           \
    [156,39,'Address 2'],           \
    [195,17,'Tel1'],                 \
    [212,17,'Tel2'],                 \
    [229,63,'email'],                \
    [292,16,'create date']]


## Test print of a specific customer record in the test.cst file
## Test print data in current file
if custselectprint :   
    f=open(custcst,'r')                                   
    print '-'*80+'\n'+' '*5+'Test print of record #',recordselect,'\n','-'*80,'\n'
   
    for point in pointers:
        f.seek(point[0]+recordplace)
        line=f.read(point[1])
        newline=p.sub(' ',line).strip() #replace non-alpha data with blank spaces using regex p above
        pad=(20-len(point[2]))*' '       
        print pad+point[2]+':  '+newline
       
    print '\n'+'-'*80+'\n'+' '*5+'Test print of record #',recordselect,'\n','-'*80,'\n'
    print '\n\n\n'
    f.close()






newcol=''
temp=''
itemlist=[]

if not importdata: print 'TEST ONLY'

print 'Importing from '+custcsv+' to '+custcst

f=open(custcsv,'r')

for each in f:
    temp=''
    itemlist=[]
    for item in each.split(','):       
       
        if item.startswith('"'):
           temp=item           
        elif item.endswith('"'):
            temp=temp+''+item
            if temp!="\n": itemlist.append(temp.strip('"'))
            temp=''
           
        else:
            if len(temp.strip())==0 and item.strip()!="\n":
                if item.strip()!="\n" :
                    itemlist.append(item.strip("\n"))
                   
            else:
                temp=temp.strip("\n")+''+item.strip("\n")
     
    itemlist.append(createdate)   

    counter=-1
    g=open(custcst,'a')
    for e in itemlist:
        counter+=1       
        linedata=str(e)+' '*(int(pointers[counter][1])-int(len(e)))
       
        if testprint: print linedata
        if importdata:       
            g.write(linedata)
    g.close()
    g=open(custcst,'ab')

    if importdata:       
        g.write(hb)
       
       
           
   
f.close()           
g.close()       


Last edited by roxy99 on Sun Dec 28, 2008 3:59 pm, edited 1 time in total.

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Sun Dec 28, 2008 3:59 pm

I've solved my problem. Updated Python code above.
Basically, I was inserting 'spaces' where I should have inserted binary 00 at the end of every record.

vxlancin
Forum Regular
Posts: 27
Joined: Wed Dec 26, 2007 11:33 am
Location: uk

Re: POS file formats

Post by vxlancin » Fri Jan 02, 2009 11:03 am

Could you post the final working source code please?

User avatar
Andrew
Site Administrator
Posts: 822
Joined: Sun Dec 28, 2003 3:40 pm
Location: New Zealand

Re: POS file formats

Post by Andrew » Fri Jan 02, 2009 7:45 pm

vxlancin wrote:Could you post the final working source code please?

They updated the source code in the post above.
Image
DHPOS Veteran (from v3.46, July 2002)

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Fri Jan 02, 2009 9:15 pm

That's correct. Its updated above. Let me know if its useful.

vxlancin
Forum Regular
Posts: 27
Joined: Wed Dec 26, 2007 11:33 am
Location: uk

Re: POS file formats

Post by vxlancin » Mon Jan 05, 2009 11:29 am

Hi im using Python 3.0 gui. I receive a syntax error when i pasted in your source code above and tryed to run it. Shown in attachment.
Attachments
error.JPG
error.JPG (93.56 KiB) Viewed 7269 times

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Wed Jan 14, 2009 12:31 pm

That's odd. The syntax error is highlighting the single quote. Try replacing all single quotes with "
Also, try escaping the - symbol like this "\-"

Last resort, try python 2.6 which is the version I used.

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Wed Jan 28, 2009 8:31 am

Regarding the bug you're getting:

there are a couple of places where you see '... print of record # ...'

Change:

print '-'*80+'\n'+' '*5+'Test print of record #',recordselect,'\n','-'*80,'\n'

To

print '-' *80+'\n'+' '*5+'Test print of record No',recordselect,'\n','-'*80,'\n'

The # inside the quoted string is making the line end commented out and therefor python reads an unbalanced quoted string and is giving a syntax error. Thus use No instead of # inside the quote.

Also, you should name the file with py extension and not a txt extension as shown in your screen capture.

Here is the complete code with the change:

Code: Select all

import re
import binascii
custcst='c:/pos/test.cst'   #replace c:/pos/test.cst with actual .cst file
custcsv='c:/pos/book1.csv'  # and csv source containing customer info to import
salehistory="00"*102
hb=binascii.a2b_hex(salehistory)

custselectprint=True     #Print sample customer in cst file
recordselect=61           #test print record
testprint=False           #test print only set True

importdata=False          #If actual import set True then routine will import ***BACKUP CST SOURCE FIRST**


createdate='2008122720081227' ## Should be 2 times yyyymmddyyymmdd
p = re.compile(r'[^a-zA-Z0-9@\.\-]')  # Regex to filter out non-alphanumeric data


##Each block of customer data has length of 410 characters
recordplace=(recordselect-1)*410
pointers=[                          \
    [0,78,'ID'],                    \
    [78,39,'Name'],                 \
    [117,39,'Address 1'],           \
    [156,39,'Address 2'],           \
    [195,17,'Tel1'],                 \
    [212,17,'Tel2'],                 \
    [229,63,'email'],                \
    [292,16,'create date']]


## Test print of a specific customer record in the test.cst file
## Test print data in current file
if custselectprint :   
    f=open(custcst,'r')                                   
    print '-'*80+'\n'+' '*5+'Test print of record No',recordselect,'\n','-'*80,'\n'
   
    for point in pointers:
        f.seek(point[0]+recordplace)
        line=f.read(point[1])
        newline=p.sub(' ',line).strip() #replace non-alpha data with blank spaces using regex p above
        pad=(20-len(point[2]))*' '       
        print pad+point[2]+':  '+newline
       
    print '\n'+'-'*80+'\n'+' '*5+'Test print of record No',recordselect,'\n','-'*80,'\n'
    print '\n\n\n'
    f.close()






newcol=''
temp=''
itemlist=[]

if not importdata: print 'TEST ONLY'

print 'Importing from '+custcsv+' to '+custcst

f=open(custcsv,'r')

for each in f:
    temp=''
    itemlist=[]
    for item in each.split(','):       
       
        if item.startswith('"'):
           temp=item           
        elif item.endswith('"'):
            temp=temp+''+item
            if temp!="\n": itemlist.append(temp.strip('"'))
            temp=''
           
        else:
            if len(temp.strip())==0 and item.strip()!="\n":
                if item.strip()!="\n" :
                    itemlist.append(item.strip("\n"))
                   
            else:
                temp=temp.strip("\n")+''+item.strip("\n")
     
    itemlist.append(createdate)   

    counter=-1
    g=open(custcst,'a')
    for e in itemlist:
        counter+=1       
        linedata=str(e)+' '*(int(pointers[counter][1])-int(len(e)))
       
        if testprint: print linedata
        if importdata:       
            g.write(linedata)
    g.close()
    g=open(custcst,'ab')

    if importdata:       
        g.write(hb)
       
       
           
   
f.close()           
g.close()       


roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Fri Feb 06, 2009 8:44 am

I forgot to mention that you need to also create your csv source in excel with columns starting with:

ID->> Col A
Name->> Col B,
Address1->> Col C,
etc.

You should not use any row heading. The application as written assumes Column A is ID, B is name.
Last edited by roxy99 on Thu Mar 12, 2009 12:59 pm, edited 2 times in total.

roxy99
Forum Regular
Posts: 24
Joined: Mon Dec 22, 2008 1:44 pm

Re: POS file formats

Post by roxy99 » Thu Mar 12, 2009 12:56 pm

PS- Don't use python 3.0 !! They broke backward compatibility. print is now a function and needs this syntax print('this text')

print 'this text' no longer works. Beware

ciarannu
Posts: 3
Joined: Tue Feb 02, 2010 11:35 am

Re: POS file formats

Post by ciarannu » Tue Feb 02, 2010 11:43 am

Hi all,

I dont have an SEL (shelf edge label's) printer and wasnt going to spend more cash on this department so instead i made my receipt printer to print SEL's.
i created a small Visual Basic programm that takes all the info from the database and when you scan in the item, it prints the Item Discription, Item Retail Price and the barcode... Its very handy for us and suets our need.

Should anyone have any need for this programm please email me and i will send you a copy and how to set it up. I will also be willing to change the layout to accomindate your needs.

regards
Ciaran

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest