Page 1 of 1

A problem < oPRINT:cmSay( ..> with MULTILINE get ?

PostPosted: Sun Apr 03, 2016 10:05 am
by ukoenig
Hello,

I want to print a MULTILE get and use

oPRINT:cmSay(nRow1,12.2, MEMOLINE(aDatP[20]), oFont1,,CLR_BLACK,,PAD_LEFT )

also tested :

Code: Select all  Expand view

n := 1
WHILE n < 8
     oPRINT:cmSay( nZeile1, 12.2, MEMOLINE(aDatP[20]), oFont1,,CLR_BLACK,,PAD_LEFT )
     nZeile1+= 0.5 // linefeed
     n++
END  
 

but shows 7 lines "AAAAAAAAAAAAAAAAA"

but doesn't work

Ok I can search for CRLF inside the get and cut the get in pieces
but maybe another solution ?

Image

best regards
Uwe :?:

Re: A problem < oPRINT:cmSay( ..> with MULTILINE get ?

PostPosted: Sun Apr 03, 2016 10:35 am
by cnavarro
Maybe, fwh\samples\report\rep20.prg, can help

Re: A problem < oPRINT:cmSay( ..> with MULTILINE get ?

PostPosted: Sun Apr 03, 2016 11:16 am
by ukoenig
Cristobal,

using the logic of this report sample it is working fine

The width and hight of the get must be adjusted to the used fontsize
to get the same result inside the report

Image

Code: Select all  Expand view

nZeile1 := 2.6 // startrow
....
....
IF !EMPTY( aDatP[20] )  // multine get
     FOR nFor := 1 TO 7 // 7 Lines
          cLine := MEMOLINE( aDatP[20], 40, nFor ) // 40 chars each line
          oPRINT:cmSay( nZeile1, 12.2, cLine, oFont1,,CLR_BLACK,,PAD_LEFT )
          nZeile1+= 0.5 // linefeed
     NEXT
ENDIF
....
....
nZeile1 += 3.7
 


best regards
Uwe :D

Re: A problem < oPRINT:cmSay( ..> with MULTILINE get ?

PostPosted: Sun Apr 03, 2016 3:46 pm
by nageswaragunupudi
Mr Uwe

oPrn:SayText() is an improved version over earlier methods oPrn:Say(),etc., which handle only single line texts.
This method prints both single line and / or multiline text with word-wrapping depending on the size of text and size of the rectangle provided. This method is particulary intended to ease the programmers' work, by avoiding the need to break the text into individual lines and printing line by line.

Syntax:
SayText( nRow, nCol, cText, [nWidth], [nHeight], [oFont], [cAlign], [nClrText], [nClrBack] ) --> nLastRowInPixels

All coordinates are in pixels.
nWidth: It is desirable to provide nWidth parameter.

nHeight: If we do not now how much height the entire text requires to be printed, set nHeight to NIL.

cAlign: Values can be 'T','L','B','R','TL','TR','LB','BR'. Text is aligned within rectangle as specfied in the parameter. Default is TL (TopLeft)

Return Value: This method returns the Last Row in pixels used for printing the text. We can use this result to know the row from which we can continue printing the next text or images.

Here is a small sample:
Code: Select all  Expand view

#include "fivewin.ch"

func dbtest()

   local oDlg, oGet, cText := ""
   local oFont

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 300,300 PIXEL TRUEPIXEL FONT oFont

   @ 20,20 GET oGet VAR cText MEMO SIZE 260,220 PIXEL OF oDlg

   @ 255,20 BUTTON "Print" SIZE 80,30 PIXEL OF oDlg ACTION PrintGet( cText, oFont )

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

return nil

static function PrintGet( cText, oTextFont )

   local oPrn, oFont, aPoint, nRow, nCol, nWidth

   PRINT oPrn PREVIEW

   DEFINE FONT oFont NAME oTextFont:cFaceName SIZE 0,-oTextFont:nHeight OF oPrn

   PAGE

   aPoint   := oPrn:Cmtr2Pix( 2.6, 10.0 )
   nRow     := aPoint[ 1 ]
   nCol     := aPoint[ 2 ]

   nRow  := oPrn:SayText( nRow, nCol, cText, @nWidth, nil, oFont )
   oPrn:Line( nRow, nCol, nRow, nCol + nWidth )

   ENDPAGE

   ENDPRINT

   RELEASE FONT oFont

return nil
 

Note: The word wrapping of the printed text depends on the font size and width provided and may not exactly match the text in the Get. However if each line in the Get is terminated by CRLF then the printed text also honors the same CRLFs while word wrapping.
Image

Re: A problem < oPRINT:cmSay( ..> with MULTILINE get ?

PostPosted: Sun Apr 03, 2016 6:50 pm
by ukoenig
Mr. Rao,

works fine !!!

my changes :

Code: Select all  Expand view

IF !EMPTY( aDatP[20] )
     aPoint   := oPRINT:Cmtr2Pix( nZeile1, 12.2 )
     nWidth := 720
     nRow     := aPoint[ 1 ]
     nCol     := aPoint[ 2 ]
     nRow  := oPRINT:SayText( nRow, nCol, aDatP[20], @nWidth, NIL, oFont1 )
     oPRINT:Line( nRow, nCol, nRow, nCol + nWidth )
ENDIF

// old
// IF !EMPTY( aDatP[20] )
//     FOR nFor := 1 TO 7 // 7 Lines
//          cLine := MEMOLINE( aDatP[20], 40, nFor ) // 40 chars
//          oPRINT:cmSay( nZeile1,12.2,  cLine, oFont1,,CLR_BLACK,,PAD_LEFT  )
//          nZeile1+= 0.5
//     NEXT
//ENDIF
 


best regards
Uwe :D

Re: A problem < oPRINT:cmSay( ..> with MULTILINE get ?

PostPosted: Sun Apr 03, 2016 9:52 pm
by nageswaragunupudi
In your case. because you know the width of the column, you may specify nWidth