How to right justify text on a printer (Windows)?
Posted: Tue Feb 14, 2006 1:16 pm
This is driving me insane!
Does anyone have a routine that will right justify text on a printer.
I am using the 'Courier New' font which does not appear to be a proportional font but still do not seem to get it right.
In the 'old' DOS days we would say:
@ 0, 80 - Len( cVar1 ) Say cVar1
@ 1, 80 - Len( cVar2 ) Say cVar2
but this does not work in windows.
I have been pulling my hair out the whole morning with this (type) of code:
...
Define Font oFont;
Name 'Courier New';
Size 15, 50
Print oPrn Name 'Report' From User
If Empty( oPrn:hDC )
oPrn:End( )
Return ( NIL )EndIf
oPrn:SetFont( oFont )
nRowStep := oPrn:nVertRes( ) / 66 // 66 rows
nColStep := oPrn:nHorzRes( ) / 80 // 80 cols
oPrn:SetPortrait( )
Page
nRow += nRowStep
oPrn:Say( nRow, ( nColStep * 80 ) - (nColStep * ( Len( 'D' ) ) ), 'D' )
nRow += nRowStep
oPrn:Say( nRow, ( nColStep * 80 ) - (nColStep * ( Len( 'DD' ) ) ), 'DD' )
EndPage
EndPrint
oPrn:End( )
etc. etc.
If you keep repeating the lines above the text 'creeps' to the left.
Any ideas?
Regards,
Dale.
Does anyone have a routine that will right justify text on a printer.
I am using the 'Courier New' font which does not appear to be a proportional font but still do not seem to get it right.
In the 'old' DOS days we would say:
@ 0, 80 - Len( cVar1 ) Say cVar1
@ 1, 80 - Len( cVar2 ) Say cVar2
but this does not work in windows.
I have been pulling my hair out the whole morning with this (type) of code:
...
Define Font oFont;
Name 'Courier New';
Size 15, 50
Print oPrn Name 'Report' From User
If Empty( oPrn:hDC )
oPrn:End( )
Return ( NIL )EndIf
oPrn:SetFont( oFont )
nRowStep := oPrn:nVertRes( ) / 66 // 66 rows
nColStep := oPrn:nHorzRes( ) / 80 // 80 cols
oPrn:SetPortrait( )
Page
nRow += nRowStep
oPrn:Say( nRow, ( nColStep * 80 ) - (nColStep * ( Len( 'D' ) ) ), 'D' )
nRow += nRowStep
oPrn:Say( nRow, ( nColStep * 80 ) - (nColStep * ( Len( 'DD' ) ) ), 'DD' )
EndPage
EndPrint
oPrn:End( )
etc. etc.
If you keep repeating the lines above the text 'creeps' to the left.
Any ideas?
Regards,
Dale.