Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to Open Cash Drawer With VFP
Message
 
À
03/09/2005 00:49:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP
Network:
Novell 4.x
Database:
Visual FoxPro
Divers
Thread ID:
01046513
Message ID:
01046534
Vues:
511
Leo

> When i want to open cash drawer i use this Font "control" and @0,0 say "A" it can
> open cash Drawer in RJ11 connector TM-U220 PB Epson Receipt Printer(Auto Cut) But
> the printer Print blank 2 cm of paper
>
> How I can open Drawer without print Blank paper
>

Yes this is very annoying, I know. I assume it is because You tell VFP actually to print something. The printer driver catches it and opens the drawer but VFP or the PrintEngine does not know this.

However there also IS and API available from Epson that allows to talk to the printer and tell it to open the drawer. I played with it .... ah, found the class that does it. Hope it helps although I remember I sometimes had problems with it. ... it's been a long time since I used it last.

This is for TM-T 88 but the code should be the same

Here is the code from the class:
**************************************************
*-- Class:        cstdrawer (d:\programm\vcx\kasse.vcx)
*-- ParentClass:  custom
*-- BaseClass:    custom
*-- Time Stamp:   09/05/02 09:08:01 PM
*
DEFINE CLASS cstdrawer AS custom


    Height = 34
    Width  = 58

    *-- Name des Drucker-Treibers
    c_driver = "EPSON TM-T88II(R) Receipt"

    *-- ErrorText
    c_errortext = "OK"

    *-- Wie lange pulsen?
    n_pulse  = 1

    *-- Drawer 1 oder 2
    n_drawer = 1

    Name = "cstdrawer"


    *-- Offnen des Schubs
    PROCEDURE opendrawer
        LOCAL ll_GoON, ll_RetVal, ln_Success, ln_Handle

        #define        TYPE_PORT                  1           && use port name  ("LPT1", "COM1"...)
        #define        TYPE_PRINTER               2           && use printer driver name 


        #define        EPS_BI_DRAWER_1            1           && Drawer 1
        #define        EPS_BI_DRAWER_2            2           && Drawer 2

        #define        EPS_BI_PULSE_100           1           && 100 m sec
        #define        EPS_BI_PULSE_200           2           && 200 m sec
        #define        EPS_BI_PULSE_300           3           && 300 m sec
        #define        EPS_BI_PULSE_400           4           && 400 m sec
        #define        EPS_BI_PULSE_500           5           && 500 m sec
        #define        EPS_BI_PULSE_600           6           && 600 m sec
        #define        EPS_BI_PULSE_700           7           && 700 m sec
        #define        EPS_BI_PULSE_800           8           && 800 m sec


        *open Monitor Printer
        Declare integer BiOpenMonPrinter in "EpsStmApi.Dll" INTEGER nType,  STRING pName 

        *close Monitor Priter
        Declare integer BiCloseMonPrinter in "EpsStmApi.Dll"  INTEGER nHandle 

        *-- Open the drawer
        Declare Integer BiOpenDrawer in "EpsStmApi.Dll" INTEGER nHandle, INTEGER Drawer,  INTEGER Pulse


        *-- Opeen Monitor
        ln_Handle = BiOpenMonPrinter(TYPE_PRINTER, This.c_Driver)

        if ln_Handle > 0
            ln_Success = BiOpenDrawer(ln_Handle, This.n_Drawer, This.n_Pulse)

            ll_RetVal  = This.ErrorText(ln_Success)

            =BiCloseMonPrinter(ln_Handle)

        else
            *-- Komme nicht ran
            ll_RetVal  = This.c_ErrorText(ln_Handle)
        endif

        return ll_RetVal
    ENDPROC


    *-- Schreiben des ErrorText
    PROCEDURE errortext
        lparameters    tn_Error
        LOCAL ll_RetVal

        #define        SUCCESS                      0        && Success
        #define        ERR_TYPE                -10        && nType error
        #define        ERR_OPENED                -20        && Already opened
        #define        ERR_NO_PRINTER            -30        && There is not printer driver  
        #define        ERR_NO_TARGET            -40        && Printer out of object
        #define        ERR_NO_MEMORY            -50        && No memory
        #define        ERR_HANDLE                -60        && Invalid handle
        #define        ERR_TIMEOUT                -70        && Ttime out
        #define        ERR_ACCESS                -80        && can not read/write
        #define        ERR_PARAM                -90        && param error
        #define        ERR_NOT_SUPPORT            -100    && not support
        #define        ERR_OFFLINE                -110    && now offline
        #define        ERR_NOT_EPSON            -120    && not epson printer
        #define        ERR_WITHOUT_CB            -130    && without callback function
        #define        ERR_BUFFER_OVER_FLOW    -140    && Read buffer over flow

        *lc_RetVal = ""
        ll_RetVal = .F.
        do case
        case tn_Error = SUCCESS
            This.c_ErrorText = "OK"
            ll_RetVal = .T.
        case tn_Error = ERR_TYPE
            This.c_ErrorText = "Typ-Fehler"
        case tn_Error = ERR_OPENED
            This.c_ErrorText = "Bereits geöffnet"
        case tn_Error = ERR_NO_PRINTER
            This.c_ErrorText = "Kein Drucker-Treiber"
        case tn_Error = ERR_NO_TARGET
            This.c_Errortext = "Drucker nicht gefunden"
        case tn_Error = ERR_NO_MEMORY
            This.c_ErrorText = "Ungenügend Speicher"
        case tn_Error = ERR_HANDLE
            This.c_ErrorText = "Ungültiger API-Handle"
        case tn_Error = ERR_TIMEOUT
            This.c_ErrorText = "TimeOut"
        case tn_Error = ERR_ACCESS
            This.c_ErrorText = "Kein Zugriff"
        case tn_Error = ERR_PARAM
            This.c_ErrorText = "Ungültiger Parameter"
        case tn_Error = ERR_NOT_SUPPORT
            This.c_ErrorText = "Nicht unterstützt"
        case tn_Error = ERR_OFFLINE
            This.c_ErrorText = "Drucker ist OFFLine"
        case tn_Error = ERR_NOT_EPSON
            This.c_ErrorText = "Kein Epson-Drucker"
        other
            This.c_ErrorText = transform(tn_Error)
        endcase

        return ll_RetVal

    ENDPROC


ENDDEFINE
*
*-- EndDefine: cstdrawer
**************************************************
HTH
Regards from Berlin

Frank

Dietrich Datentechnik (Berlin)
Softwarekombinat Teltow (Teltow)

Frank.Dietrich@dd-tech.de
DFPUG # 327
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform