Problem with printed coordinates for dot-matrix printer

Problem with printed coordinates for dot-matrix printer

Postby cdmmaui » Wed Jul 13, 2011 5: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 "Arial" 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("000"+ LTRIM(TRANSF(nX,"999")),4)
nBeg = 4

IF LTRIM(STR( MOD(nX,2),2)) ="0"
Mtmp = ""
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) $ "05"
M_dat = "|"
ELSE
IF nY=99
M_dat = "X"
ELSE
M_dat = "-"
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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Problem with printed coordinates for dot-matrix printer

Postby James Bott » Fri Jul 15, 2011 4: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests