FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with printed coordinates for dot-matrix printer
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Problem with printed coordinates for dot-matrix printer
Posted: Wed Jul 13, 2011 05:25 AM

Hello Everyone,

I am having problems printing to a dot matrix printer, Okidata ML 320. I am trying to change the paper length to 12 inches which is supported by the printer. I am using the following code print a grid with rows and columns to determine placement of data on a pre-printed form.

Another problem is that the page is not form feeding to the next form once the print job is completed.

How can I get this resolved?

/---------------------------------------------------------------------------/
static function __grid( nLay, nWid1, nLen1 )

local oPrinter, oFont

/ Set Paper Size /
nWid := ROUND( nWid1 * 254, 0) <--- 254 is conversion to millimeters
nLen := ROUND( nLen1 * 254, 0)
PrnSetSize( nWid, nLen )

/ Select Printer /
PRINT oPrinter FROM USER PRINTER NAME "Grid Utility" PREVIEW MODAL

/* Check if Object is Empty */
if empty( oPrinter:hDC )
   return nil
endif

// Font...
DEFINE FONT oFont NAME &quot;Arial&quot; SIZE 0,-10 OF oPrinter

/* Set to Layout */
if (nLay==1)
   oPrinter:SetPortrait()                   // Portrait...
 else
   oPrinter:SetLandScape()                  // Landscape...
endif

/* Init vars */
Mrow   = 0
Mv_max = oPrinter:nVertRes()
Mh_max = oPrinter:nHorzRes()

/* Start Printing Page */
PAGE

/* Let's Go */
FOR nX=0 TO 100
    Mrow := ROUND( Mv_max * (nX/100), 0)
    Mtmp = RIGHT(&quot;000&quot;+ LTRIM(TRANSF(nX,&quot;999&quot;)),4)
    nBeg = 4

    IF LTRIM(STR( MOD(nX,2),2)) =&quot;0&quot;
       Mtmp = &quot;&quot;
       nBeg = 1
    ENDIF

    FOR nY=nBeg TO 100
        IF nY=nBeg
           oPrinter:Say( Mrow, 1, Mtmp, oFont       )
        ENDIF

        Mcol := ROUND( Mh_max * (nY/100), 0)
        IF RIGHT(LTRIM(STR(nY,3)),1) $ &quot;05&quot;
           M_dat = &quot;|&quot;
         ELSE
           IF nY=99
              M_dat = &quot;X&quot;
            ELSE
              M_dat = &quot;-&quot;
           ENDIF
        ENDIF

        oPrinter:Say( Mrow, Mcol, M_dat, oFont       )

        /* Counter */
        Mcol += oPrinter:GetTextWidth(M_dat, oFont)

    NEXT nY
NEXT nX

// Done printing...
ENDPAGE
oPrinter:SetPortrait()
ENDPRINT

nWid := ROUND( 8.5 * 254, 0)
nLen := ROUND( 11  * 254, 0)
PrnSetSize(nWid, nLen )

RETURN nil
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Problem with printed coordinates for dot-matrix printer
Posted: Fri Jul 15, 2011 04:37 PM
Darrell,

I am having problems printing to a dot matrix printer


You didn't say what the problem is.

To get a form feed try using the FW function Escape() to send escape codes directly to the printer. I think this would be Escape( oPrn:hDC, 12) for a form feed.

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion