POS file formats
Moderators:daleadmin, Dale Harris, Alan, Andrew
- Dale Harris
- Forum Owner
- Posts:1171
- Joined:Sun Dec 28, 2003 10:19 pm
- Location:Chicago
- Contact:
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
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
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.
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
Re:
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.
Re: POS file formats
All the examples are in QuickBasic, unless otherwise noted.
Re: POS file formats
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.
Re: POS file formats
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.
Basically, I was inserting 'spaces' where I should have inserted binary 00 at the end of every record.
Re: POS file formats
Could you post the final working source code please?
Re: POS file formats
They updated the source code in the post above.vxlancin wrote:Could you post the final working source code please?
Re: POS file formats
That's correct. Its updated above. Let me know if its useful.
Re: POS file formats
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 (93.56 KiB) Viewed 41186 times
Re: POS file formats
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.
Also, try escaping the - symbol like this "\-"
Last resort, try python 2.6 which is the version I used.
Re: POS file formats
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:
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()
Re: POS file formats
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.
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.
Re: POS file formats
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
print 'this text' no longer works. Beware
Re: POS file formats
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
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
Who is online
Users browsing this forum: No registered users and 153 guests