hi guys,
i have a problem in understanding how to write wokring code for a fiscal printer. its epson tm-t88v from customer.
my question:
do i need to create the input-file binary or in ascii?
how to use the escape-commands with sample code that works.
if binary, has it to be in decimal or in hex?
if ascii, how to enter the escape commands. i understand something lie \ESC ... but doesn't work.
i couldn't find in the web something useful.
i created ascii-file with the escape commands, but the printer has printed the entire ascii text how it is and did not interpret it.
then i worte a new code by using chr() and another with asc() to create the file, also not useful result.
then i tried to create a binary file with the escape sequences and ascii-strings in binary-code. also not a useful output.
i haven't any idea what i can do else. i understand the escape commands but i have no idea how to describe the printer the code in the way that the printer accepts.
the printer is connect to usb. there is a program called dosprinter.exe, to find by goolge in the web. that program sends the file correctly to the printer and cuts if the file is finished. but the content has to be right for the printer, so you get the right output. that's my problem, i have no idea how to create a working output.
i need working samples. console-based not by using api of the operating system. has anyone an idea how to solve that problem?
thanks
kurt
fiscal printer epson tm-t88v
Re: fiscal printer epson tm-t88v
Hi,
if you send raw data to a printer it is always binary.
And it doesn't matter if you send hex or dez, a byte is a byte
\ESC means $1B or 27
But how do you send the bytes to the printer?
Do you want to use this dosprint.exe?
Where is the documentatation about it?
For the ESC code I found only stuff up to T88 III and not V:
http://content.epson.de/fileadmin/conte ... escpos.pdf
Bernd
if you send raw data to a printer it is always binary.
And it doesn't matter if you send hex or dez, a byte is a byte
\ESC means $1B or 27
But how do you send the bytes to the printer?
Do you want to use this dosprint.exe?
Where is the documentatation about it?
For the ESC code I found only stuff up to T88 III and not V:
http://content.epson.de/fileadmin/conte ... escpos.pdf
Bernd
Re: fiscal printer epson tm-t88v
Did you contact Epson?5mware wrote:hi guys,
i have a problem in understanding how to write wokring code for a fiscal printer. its epson tm-t88v from customer.
my question:
do i need to create the input-file binary or in ascii?
how to use the escape-commands with sample code that works.
if binary, has it to be in decimal or in hex?
if ascii, how to enter the escape commands. i understand something lie \ESC ... but doesn't work.
i couldn't find in the web something useful.
i created ascii-file with the escape commands, but the printer has printed the entire ascii text how it is and did not interpret it.
then i worte a new code by using chr() and another with asc() to create the file, also not useful result.
then i tried to create a binary file with the escape sequences and ascii-strings in binary-code. also not a useful output.
i haven't any idea what i can do else. i understand the escape commands but i have no idea how to describe the printer the code in the way that the printer accepts.
the printer is connect to usb. there is a program called dosprinter.exe, to find by goolge in the web. that program sends the file correctly to the printer and cuts if the file is finished. but the content has to be right for the printer, so you get the right output. that's my problem, i have no idea how to create a working output.
i need working samples. console-based not by using api of the operating system. has anyone an idea how to solve that problem?
thanks
kurt
I'm thinking that most printer companies will send you the detailed programming specifications for their devices.
About twenty one years ago, after I asked for the programming specs for their Deskjet 500C, HP sent me a huge physical manual which actually cost them cash to ship.
Nowadays the delivery would probably be electronic and fast.
Keep it BASIC.
Re: fiscal printer epson tm-t88v
i did not contact epson but found a lot of stuff in the internet also from epson itself.
but i am not sure why the code does not work. i get an output, but its wrong.
here a part of the code:
but i am not sure why the code does not work. i get an output, but its wrong.
here a part of the code:
Code: Select all
Enumeration
#schrift_klein ; Font size small
#schrift_mitte ; middle
#schrift_gross ; large
; ***
#schrift_kursiv_1 ; italic
#schrift_kursiv_2 ; italic
; ***
#schrift_fett_1 ; bold
#schrift_fett_2 ; bold
; ***
#schrift_courier_new ; fonts
#schrift_lucida_console
#schrift_arial
#schrift_impact
#schrift_verdana
#schrift_tahoma
; ***
#schrift_linksbundig ; alignemnt left
#schrift_zentriert ; mid
#schrift_rechtsbundig ; right
EndEnumeration
Global bon_pos.w = 0
; Width of the paper
Global bon_bandbreite.w = 44 * 6
Global cpi10.w = 13, cpi12.w = 16, cpi15.w = 21
; writes over
Procedure.s bon_druberschreiben( ziel.s, quelle.s )
Define p.w = 0, t.s = ""
; ***
If Len(ziel) > Len(quelle)
For p = 1 To Len(ziel)
If p <= Len(quelle)
t + Mid( quelle, p, 1 )
Else
t + Mid( ziel, p, 1 )
EndIf
Next
ElseIf Len(ziel) = Len(quelle)
t = quelle
ElseIf Len(ziel) < Len(quelle)
For p = 1 To Len(ziel)
t + Mid( quelle, p, 1 )
Next
EndIf
; ***
ProcedureReturn t
EndProcedure
Procedure.s bon_abstand( position.w )
If position < 10
ProcedureReturn " "
ElseIf position < 100
ProcedureReturn " "
Else
ProcedureReturn " "
EndIf
EndProcedure
; find the right part
Procedure.s bon_passender_anteil( schriftg.a, schriftt.a, ruckabstand.s, text.s )
Select schriftg
Case #schrift_klein
Select schriftt
Case #schrift_courier_new : LoadFont( 2000, "Courier New", cpi10 )
Case #schrift_lucida_console : LoadFont( 2000, "Lucida Console", cpi10 )
Case #schrift_arial : LoadFont( 2000, "Arial", cpi10 )
Case #schrift_impact : LoadFont( 2000, "Impact", cpi10 )
Case #schrift_verdana : LoadFont( 2000, "Verdana", cpi10 )
Case #schrift_tahoma : LoadFont( 2000, "Tahoma", cpi10 )
EndSelect
Case #schrift_mitte
Select schriftt
Case #schrift_courier_new : LoadFont( 2000, "Courier New", cpi12 )
Case #schrift_lucida_console : LoadFont( 2000, "Lucida Console", cpi12 )
Case #schrift_arial : LoadFont( 2000, "Arial", cpi12 )
Case #schrift_impact : LoadFont( 2000, "Impact", cpi12 )
Case #schrift_verdana : LoadFont( 2000, "Verdana", cpi12 )
Case #schrift_tahoma : LoadFont( 2000, "Tahoma", cpi12 )
EndSelect
Case #schrift_gross
Select schriftt
Case #schrift_courier_new : LoadFont( 2000, "Courier New", cpi15 )
Case #schrift_lucida_console : LoadFont( 2000, "Lucida Console", cpi15 )
Case #schrift_arial : LoadFont( 2000, "Arial", cpi15 )
Case #schrift_impact : LoadFont( 2000, "Impact", cpi15 )
Case #schrift_verdana : LoadFont( 2000, "Verdana", cpi15 )
Case #schrift_tahoma : LoadFont( 2000, "Tahoma", cpi15 )
EndSelect
EndSelect
; ***
Define p.w, t.s = ""
; ***
If CreateImage( 2000, bon_bandbreite, 100 ) And StartDrawing(ImageOutput(2000))
ww.w = TextWidth(text)
; ***
If TextWidth(ruckabstand) + ww <= bon_bandbreite
t = text
Else
For p = 1 To Len(text)
If TextWidth(ruckabstand) + TextWidth(t) < bon_bandbreite
t + Mid(text,p,1)
Else
Break
EndIf
Next
; ***
If Len(t) > 1
t = Mid( t, 1, Len(t) - 1 )
EndIf
EndIf
; ***
StopDrawing()
EndIf
; ***
ProcedureReturn t
EndProcedure
; add spaces
Procedure.s bon_leerfeld( text.s )
Define p.w = 0, t.s = ""
; ***
For p = 1 To Len(text)
t + " "
Next
; ***
ProcedureReturn t
EndProcedure
; move the text to middle or right
Procedure.s bon_ruck( schriftg.a, schriftt.a, text.s, rechtsbunding.a = #False )
Select schriftg
Case #schrift_klein
Select schriftt
Case #schrift_courier_new : LoadFont( 2000, "Courier New", cpi10 )
Case #schrift_lucida_console : LoadFont( 2000, "Lucida Console", cpi10 )
Case #schrift_arial : LoadFont( 2000, "Arial", cpi10 )
Case #schrift_impact : LoadFont( 2000, "Impact", cpi10 )
Case #schrift_verdana : LoadFont( 2000, "Verdana", cpi10 )
Case #schrift_tahoma : LoadFont( 2000, "Tahoma", cpi10 )
EndSelect
Case #schrift_mitte
Select schriftt
Case #schrift_courier_new : LoadFont( 2000, "Courier New", cpi12 )
Case #schrift_lucida_console : LoadFont( 2000, "Lucida Console", cpi12 )
Case #schrift_arial : LoadFont( 2000, "Arial", cpi12 )
Case #schrift_impact : LoadFont( 2000, "Impact", cpi12 )
Case #schrift_verdana : LoadFont( 2000, "Verdana", cpi12 )
Case #schrift_tahoma : LoadFont( 2000, "Tahoma", cpi12 )
EndSelect
Case #schrift_gross
Select schriftt
Case #schrift_courier_new : LoadFont( 2000, "Courier New", cpi15 )
Case #schrift_lucida_console : LoadFont( 2000, "Lucida Console", cpi15 )
Case #schrift_arial : LoadFont( 2000, "Arial", cpi15 )
Case #schrift_impact : LoadFont( 2000, "Impact", cpi15 )
Case #schrift_verdana : LoadFont( 2000, "Verdana", cpi15 )
Case #schrift_tahoma : LoadFont( 2000, "Tahoma", cpi15 )
EndSelect
EndSelect
; ***
Define p.a, t.s = ""
; ***
If CreateImage( 2000, bon_bandbreite, 100 ) And StartDrawing(ImageOutput(2000))
ww.w = TextWidth(text)
; ***
If rechtsbunding = #False
ww = ( ( bon_bandbreite - ww ) / 2 )
Else
ww = bon_bandbreite - ww
EndIf
; ***
ww + TextWidth(" ")
; ***
For p = 1 To 40
t + " "
; ***
If TextWidth(t) >= ww
Break
EndIf
Next
; ***
If Len(t) > 1
t = Mid( t, 1, Len(t) - 1 )
Else
t = ""
EndIf
; ***
StopDrawing()
EndIf
; ***
ProcedureReturn t
EndProcedure
; write text
Procedure.s bon_text( schriftg.a, schriftt.a, textstrom.s, ausrichtung.a = 13 )
Dim schrift.s(13)
; Schriftgrößen
schrift(0) = "ESC P" ; 10 cpi
schrift(1) = "ESC M" ; 12 cpi
schrift(2) = "ESC g" ; 15 cpi
schrift(3) = "ESC 4" ; Kursiv -> Select
schrift(4) = "ESC 5" ; Kursiv -> Cancel
schrift(5) = "ESC E" ; Fett -> Select
schrift(6) = "ESC F" ; Fett -> Cancel
; Schriftarten
schrift(7) = "ESC k 0" ; Courier New
schrift(8) = "ESC k 1" ; Lucida Console
schrift(9) = "ESC k 5" ; Arial
schrift(10) = "ESC k 6" ; Impact
schrift(11) = "ESC k 15"; Verdana
schrift(12) = "ESC k 16"; Tahoma
Define t.s = "", text.s = ""
Select ausrichtung
Case #schrift_linksbundig : text = textstrom
Case #schrift_zentriert : text = bon_ruck(schriftg, schriftt, textstrom, #False) + textstrom
Case #schrift_rechtsbundig : text = bon_ruck(schriftg, schriftt, textstrom, #True ) + textstrom
EndSelect
t + schrift(schriftg) + #CRLF$ +
schrift(schriftt) + #CRLF$ +
text
ProcedureReturn t
EndProcedure
; write text to left and right sides
Procedure.s bon_opp_text( schriftg.a, schriftt.a, tlinks.s, trechts.s )
Dim schrift.s(13)
; Schriftgrößen
schrift(0) = "ESC P" ; 10 cpi
schrift(1) = "ESC M" ; 12 cpi
schrift(2) = "ESC g" ; 15 cpi
schrift(3) = "ESC 4" ; Kursiv -> Select
schrift(4) = "ESC 5" ; Kursiv -> Cancel
schrift(5) = "ESC E" ; Fett -> Select
schrift(6) = "ESC F" ; Fett -> Cancel
; Schriftarten
schrift(7) = "ESC k 0" ; Courier New
schrift(8) = "ESC k 1" ; Lucida Console
schrift(9) = "ESC k 5" ; Arial
schrift(10) = "ESC k 6" ; Impact
schrift(11) = "ESC k 15"; Verdana
schrift(12) = "ESC k 16"; Tahoma
Define t.s = "", links.s = bon_ruck( schriftg, schriftt, trechts, #True )
links = bon_druberschreiben( links, tlinks )
t + schrift(schriftg) + #CRLF$ +
schrift(schriftt) + #CRLF$ +
links + trechts
ProcedureReturn t
EndProcedure
; write tabbed text
Procedure.s bon_tab_text( schriftg.a, schriftt.a, text1.s, text2.s = "", text3.s = "" )
Dim schrift.s(13)
; Schriftgrößen
schrift(0) = "ESC P" ; 10 cpi
schrift(1) = "ESC M" ; 12 cpi
schrift(2) = "ESC g" ; 15 cpi
schrift(3) = "ESC 4" ; Kursiv -> Select
schrift(4) = "ESC 5" ; Kursiv -> Cancel
schrift(5) = "ESC E" ; Fett -> Select
schrift(6) = "ESC F" ; Fett -> Cancel
; Schriftarten
schrift(7) = "ESC k 0" ; Courier New
schrift(8) = "ESC k 1" ; Lucida Console
schrift(9) = "ESC k 5" ; Arial
schrift(10) = "ESC k 6" ; Impact
schrift(11) = "ESC k 15"; Verdana
schrift(12) = "ESC k 16"; Tahoma
Define t.s, t2.s, t3.s = ""
t2 = bon_passender_anteil( schriftg, schriftt, text1 + text2, text3 )
If t2 <> text3
t3 = Mid( text3, Len(t2) + 1 )
EndIf
t + schrift(schriftg) + #CRLF$ +
schrift(schriftt) + #CRLF$ +
text1 + text2 + t2
; ***
If t3
t + bon_leerfeld(text1 + text2) + t3
EndIf
ProcedureReturn t
EndProcedure
; add to the output file
Procedure bon_datei( dateiNummer.l, strom.s )
Define satz.s = Trim(strom), es.a = 0
; ***
; If FindString( satz, "ESC " ) > 0 Or FindString( satz, "ESC" + Chr(9) ) > 0
; es = 1
; EndIf
; ***
satz = ReplaceString( satz, "ESC k 0", "\" + Str(Asc("k")) + "\" + "0" )
satz = ReplaceString( satz, "ESC k 1", "\" + Str(Asc("k")) + "\" + "1" )
satz = ReplaceString( satz, "ESC k 5", "\" + Str(Asc("k")) + "\" + "5" )
satz = ReplaceString( satz, "ESC k 6", "\" + Str(Asc("k")) + "\" + "6" )
satz = ReplaceString( satz, "ESC k 15", "\" + Str(Asc("k")) + "\" + "15" )
satz = ReplaceString( satz, "ESC k 16", "\" + Str(Asc("k")) + "\" + "16" )
satz = ReplaceString( satz, "ESC P", "\" + Str(Asc("P")) )
satz = ReplaceString( satz, "ESC M", "\" + Str(Asc("M")) )
satz = ReplaceString( satz, "ESC g", "\" + Str(Asc("g")) )
satz = ReplaceString( satz, "ESC 4", "\" + "4" )
satz = ReplaceString( satz, "ESC 5", "\" + "5" )
satz = ReplaceString( satz, "ESC E", "\" + Str(Asc("E")) )
satz = ReplaceString( satz, "ESC F", "\" + Str(Asc("F")) )
satz = ReplaceString( satz, "ESC R 2", "\" + Str(Asc("R")) + "\" + "2" )
satz = ReplaceString( satz, "ESC ! 4", "\" + Str(Asc("!")) + "\" + "4" )
If FindString( satz, "\" ) > 0
Select CountString( satz, "\" )
Case 1 : WriteByte( dateiNummer, Val(take(1,"\",satz)) )
WriteByte( dateiNummer, 0 )
Case 2 : WriteByte( dateiNummer, Val(take(1,"\",satz)) )
WriteByte( dateiNummer, Val(take(2,"\",satz)) )
WriteByte( dateiNummer, 0 )
EndSelect
Else
WriteStringN( dateiNummer, satz )
EndIf
; ***
ProcedureReturn 0
satz = ReplaceString( satz, "ESC", "#" )
; ***
Define c.w
; ***
If es = 1; Mid(satz,1,1) = "#"
WriteByte( dateiNummer, 27 )
; ***
;Debug satz + " >> " + take(1," ",satz) + " <> " + take(2," ",satz)
Debug ">>" + satz
Select FindString( satz, " " )
Case 1 ; ESC n
WriteByte( dateiNummer, Asc(take(1," ",satz)) )
WriteByte( dateiNummer, 1 )
Case 2 ; ESC n m
WriteByte( dateiNummer, Asc(take(1," ",satz)) )
; ***
ni.l = Val(take(2," ",satz))
; ***
WriteByte( dateiNummer, ni )
WriteByte( dateiNummer, 1 )
EndSelect
Else
Debug satz
WriteStringN( dateiNummer, satz, #PB_Ascii )
EndIf
EndProcedure
; create the printer output-file and send it to the printer
Procedure drucken_bon(belegnr.s,zahlungsart.s,zahlbetrag.d)
bon_pos = 0
Define drucker.s, martop.a, marbot.a, titel.s, text1.s, text2.s, text3.s, text4.s, text5.s
Define zeichensatz.s = "ESC R 2" ; Deutsch
Define trennstrich.s = "ESC ! 4" ; 0 Pica, 1 Elite, 4 Condensed, 8 Emphasized, 16 Double Strike, 128 Underline
Define knu.s, beldat.s, beltyp.s, bonjob.s, bonid.l
Define netto.d, brutto.d, mwst.d
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
; BON-Drucker Einstellungen einlesen
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
dbDO( #db_open, #DB_CORE )
; ***
If DBAC(#DB_CORE)
If DatabaseQuery(DBAC(#DB_CORE), "SELECT * FROM einstellungen ORDER BY id")
While NextDatabaseRow(DBAC(#DB_CORE))
wert$ = Trim(GetDatabaseString(DBAC(#DB_CORE), 3))
; ***
Select GetDatabaseString(DBAC(#DB_CORE), 1)
Case "bondrucker"
Select GetDatabaseString(DBAC(#DB_CORE), 2)
Case "drucker" : drucker = " /SEL'" + Trim(wert$) + "' "
Case "margintop" : martop = Val(wert$)
Case "marginbot" : marbot = Val(wert$)
Case "titel" : titel = wert$
Case "text1" : text1 = wert$
Case "text2" : text2 = wert$
Case "text3" : text3 = wert$
Case "text4" : text4 = wert$
Case "text5" : text5 = wert$
EndSelect
EndSelect
Wend
FinishDatabaseQuery(DBAC(#DB_CORE))
EndIf
EndIf
; ***
dbDO( #db_quit, #DB_CORE )
dbDO( #db_open, #DB_BELE )
; ***
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
; Rechnungskopfdaten einlesen
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
If IsDatabase(DBAC(#DB_BELE))
If DatabaseQuery(DBAC(#DB_BELE), "SELECT * FROM rechnungen WHERE belegnr = " + q(belegnr) + " LIMIT 1")
While NextDatabaseRow(DBAC(#DB_BELE))
knu = Trim(GetDatabaseString(DBAC(#DB_BELE),1))
beldat = FormatDate( "%dd.%mm.%yyyy", Val(GetDatabaseString(DBAC(#DB_BELE),4)) )
; ***
Select Trim(GetDatabaseString(DBAC(#DB_BELE),2))
Case "rech" : beltyp = "QUITTUNG"
Case "gut2" : beltyp = "GUTSCHEIN"
Case "gut1" : beltyp = "GUTSCHRIFT"
Default
beltyp = ""
EndSelect
; ***
netto = ValD(ReplaceString(GetDatabaseString(DBAC(#DB_BELE),11),",","."))
mwst = ValD(ReplaceString(GetDatabaseString(DBAC(#DB_BELE),10),",","."))
brutto = ValD(ReplaceString(GetDatabaseString(DBAC(#DB_BELE),12),",","."))
Wend
; ***
FinishDatabaseQuery(DBAC(#DB_BELE))
EndIf
EndIf
; ***
dbDO( #db_quit, #DB_BELE )
dbDO( #db_open, #DB_CUSP )
; ***
If beltyp = ""
infobox( #infobox_error, "Abbruch", "Der Bondrucker kann nur Rechnungen quittieren, Gutscheine und Gutschrifte ausdrucken. Andere Belegarten können nur auf normalem Drucker ausgedruckt werden!" )
EndIf
; ***
If knu = "" : ProcedureReturn 0 : EndIf
If Trim(beldat) = "" : ProcedureReturn 0 : EndIf
; ***
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
; Kundendaten einlesen
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
If IsDatabase(DBAC(#DB_CUSP))
If DatabaseQuery(DBAC(#DB_CUSP), "SELECT * FROM kunden WHERE kdnr = " + q(knu) + " LIMIT 1")
While NextDatabaseRow(DBAC(#DB_CUSP))
firma1$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),3))
firma2$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),4))
firma3$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),5))
; ***
kfname$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),7))
ksname$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),8))
; ***
kadres$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),9))
kpostl$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),10))
kregio$ = Trim(GetDatabaseString(DBAC(#DB_CUSP),8))
Wend
; ***
FinishDatabaseQuery(DBAC(#DB_CUSP))
EndIf
EndIf
; ***
dbDO( #db_quit, #DB_CUSP )
; ***
dbDO( #db_open, #DB_CORE )
; ***
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
; Firmendaten einlesen
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
If IsDatabase(DBAC(#DB_CORE))
If DatabaseQuery(DBAC(#DB_CORE), "SELECT * FROM einstellungen WHERE kennung = " + q("setup") + " ORDER BY id")
While NextDatabaseRow(DBAC(#DB_CORE))
Select LCase(Trim(GetDatabaseString(DBAC(#DB_CORE),2)))
Case "firma"
mfirma$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "strasse"
mstras$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "plz"
mpostl$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "ort"
mregio$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "steuernummer"
msteuer.s = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "usidnr"
mumstr$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "hre"
mhandl$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "vorname"
mvornm$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "nachname"
mnachn$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
EndSelect
Wend
; ***
FinishDatabaseQuery(DBAC(#DB_CORE))
EndIf
EndIf
; ***
If IsDatabase(DBAC(#DB_CORE))
If DatabaseQuery(DBAC(#DB_CORE), "SELECT * FROM einstellungen WHERE kennung = " + q("kontakt") + " ORDER BY id")
While NextDatabaseRow(DBAC(#DB_CORE))
Select LCase(Trim(GetDatabaseString(DBAC(#DB_CORE),2)))
Case "telefon1"
mtelef$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "fax1"
mtefax$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "mobil"
mmobil$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "email"
memail$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
Case "webseite"
mwebsi$ = Trim(GetDatabaseString(DBAC(#DB_CORE),3))
EndSelect
Wend
; ***
FinishDatabaseQuery(DBAC(#DB_CORE))
EndIf
EndIf
; ***
dbDO( #db_quit, #DB_CORE )
; ***
dbDO( #db_open, #DB_BELE )
; ***
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
; Druckauftrag vorbereiten (Bon erstellen)
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
bonjob = "C:\temp\bonjob.bin"
; ***
If FileSize( bonjob ) > 0
DeleteFile( bonjob )
EndIf
; ***
bonid = CreateFile( #PB_Any, bonjob )
; ***
If bonid
bon_datei( bonid, zeichensatz )
; ***
For m = 0 To martop
bon_datei( bonid, " " )
Next
; ***
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_verdana, beltyp, #schrift_zentriert ) )
bon_datei( bonid, "" )
bon_datei( bonid, bon_text( #schrift_gross, #schrift_impact, titel, #schrift_zentriert ) )
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, mfirma$, #schrift_zentriert ) )
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, mstras$, #schrift_zentriert ) )
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, mpostl$ + " " + mregio$, #schrift_zentriert ) )
bon_datei( bonid, "" )
; ***
If Trim(mtelef$)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, "Tel: " + Trim(mtelef$), #schrift_zentriert ) )
EndIf
; ***
If Trim(memail$)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, "E-Mail: " + Trim(memail$), #schrift_zentriert ) )
EndIf
; ***
If Trim(msteuer)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, "St.-Nr.: " + Trim(msteuer), #schrift_zentriert ) )
EndIf
; ***
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, "Kundennummer: " + knu ) )
; ***
If firma1$
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, firma1$ ) )
; ***
If firma2$
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, firma2$ ) )
EndIf
; ***
If firma3$
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, firma3$ ) )
EndIf
ElseIf kfname$
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, kfname$ + " " + ksname$ ) )
Else
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, "Ladenkunde" ) )
EndIf
; ***
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, "Beleg Nr.: " + belegnr ) )
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial, "Datum: " + FormatDate( "%dd.%mm.%yyyy", Date() ) + " " + FormatDate( "%hh:%ii:%ss", Date() ) ) )
; ***
bon_datei( bonid, trennstrich )
; ***
dbDO( #db_open, #DB_BELE )
; ***
If IsDatabase(DBAC(#DB_BELE))
If DatabaseQuery(DBAC(#DB_BELE), "SELECT * FROM beleg WHERE belegnr = " + q(belegnr) + " ORDER BY id")
While NextDatabaseRow(DBAC(#DB_BELE))
bon_pos + 1
; ***
bon_datei( bonid, bon_tab_text( #schrift_mitte, #schrift_arial,
Trim(GetDatabaseString(DBAC(#DB_BELE),6)),
bon_abstand(bon_pos), Trim(GetDatabaseString(DBAC(#DB_BELE),4)) ) )
; ***
bon_datei( bonid, bon_text( #schrift_mitte, #schrift_arial,
Trim(GetDatabaseString(DBAC(#DB_BELE),3)) + " " +
Trim(GetDatabaseString(DBAC(#DB_BELE),5)) + " " +
Trim(GetDatabaseString(DBAC(#DB_BELE),8)) ) )
Wend
; ***
FinishDatabaseQuery(DBAC(#DB_BELE))
EndIf
EndIf
; ***
dbDO( #db_quit, #DB_BELE )
; ***
bon_datei( bonid, " " )
bon_datei( bonid, bon_opp_text( #schrift_mitte, #schrift_arial, "Gesamtbetrag:", ReplaceString(StrD(brutto,2),".",",") + " EUR" ) )
bon_datei( bonid, trennstrich )
; ***
bon_datei( bonid, bon_opp_text( #schrift_mitte, #schrift_arial, "/" + ReplaceString(StrD(brutto,2),".",",") + " " + zahlungsart, ReplaceString(StrD(zahlbetrag,2),".",",") + " EUR" ) )
bon_datei( bonid, bon_opp_text( #schrift_mitte, #schrift_arial, "zurück/Rest", ReplaceString(StrD(zahlbetrag - brutto,2),".",",") + " EUR" ) )
bon_datei( bonid, bon_opp_text( #schrift_mitte, #schrift_arial, "Betrag Netto", ReplaceString(StrD(netto,2),".",",") + " EUR " ) )
bon_datei( bonid, bon_opp_text( #schrift_mitte, #schrift_arial, "19% MwSt enthalten", ReplaceString(StrD(mwst,2),".",",") + " EUR " ) )
; ***
bon_datei( bonid, " " )
; ***
If Trim(text1)
bon_datei( bonid, bon_text( #schrift_gross, #schrift_courier_new, Trim(text1), #schrift_zentriert ) )
EndIf
; ***
If Trim(text2)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, Trim(text2), #schrift_zentriert ) )
EndIf
; ***
If Trim(text3)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, Trim(text3), #schrift_zentriert ) )
EndIf
; ***
If Trim(text4)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, Trim(text4), #schrift_zentriert ) )
EndIf
; ***
If Trim(text5)
bon_datei( bonid, bon_text( #schrift_klein, #schrift_courier_new, Trim(text5), #schrift_zentriert ) )
EndIf
; ***
For m = 0 To marbot
bon_datei( bonid, " " )
Next
; ***
CloseFile(bonid)
EndIf
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
; Druckauftrag an den Drucker senden
; ------------------------------------------------------------------------------------------------ ;
; ------------------------------------------------------------------------------------------------ ;
RunProgram( myPath + "thdpartymo\DOSPrinter.exe", drucker + bonjob, "" )
EndProcedure
Last edited by 5mware on Mon Dec 14, 2015 4:09 pm, edited 1 time in total.
Re: fiscal printer epson tm-t88v
I don't know what dosprint.exe expect.
But...
ESC P for example means:
$1B $50
Or
27 80
And not "ESC P"
Bernd
But...
ESC P for example means:
$1B $50
Or
27 80
And not "ESC P"
Bernd
Re: fiscal printer epson tm-t88v
Oh yeah, nowadays they got the stuff already on the net.
Cool.
Good luck.
Some of that programming is difficult to accomplish until you determine the obscured correct code sequences.
I hated it.
Give me Calcomp or Versatec anyday.
This PB site needs to implement "Show"/"Hide" (spoiler) button functionality because those long source codes break up the conversation a bit much.
While at it, as this is a programmer's forum, add a "Copy All" button.
Cool.
Good luck.
Some of that programming is difficult to accomplish until you determine the obscured correct code sequences.
I hated it.
Give me Calcomp or Versatec anyday.
This PB site needs to implement "Show"/"Hide" (spoiler) button functionality because those long source codes break up the conversation a bit much.
While at it, as this is a programmer's forum, add a "Copy All" button.
Keep it BASIC.


