Page 3 of 3

Re: RTF from Variable

Posted: Fri Dec 03, 2021 11:49 pm
by cnavarro

Re: RTF from Variable

Posted: Mon Dec 06, 2021 11:57 pm
by TimStone
No my questions were not answered in that post. I had already reviewed it many times but look again. Let me be specific:

DOES ANYONE USE RTF with a FW Memo field ? Does anyone print RTF along with regular code in a custom PRINTER class printout ? I have heard it is possible, but have seen no completed code or documentation to demonstrate this.


ISSUE 1:

Using the updated RichEdit5.prg, with a resource file, I can read text from a memo field ( DBFCDX ) into a variable, and then modify it with RichEdit including highlighting, spell checking, etc. Now, I want to save that modified text ( with RichEdit formatting ) back to the MEMO field in the .dbf. For years I heard this was possible, but see no examples or documentation. I've looked at the code, tried many different things, and have not found the solution.

ISSUE 2:

I have an invoice that uses the PRINTER class ( NOT THE REPORT OPTION ). There are a lot of formatting options in the structure, with calculations. and decision trees, throughout. This cannot be done with the report class. I previously shared how I print MEMO fields. My question was specific: Is there a PRINTER command to output the RTF data which I can replace the example I used? Remember, this is just one small part of the full invoice which is written 100% with PRINTER syntax.

Once I can see how these methods are applied, then I can implement them specifically in my application.

Thank you.

Re: RTF from Variable

Posted: Thu Dec 09, 2021 8:57 am
by Antonio Linares
Tim,

Alias->YourMemoField := oRichEdit:SaveAsRTF()

Re: RTF from Variable

Posted: Thu Dec 09, 2021 9:00 am
by Antonio Linares
Tim,

c:\fwh\samples\report\rep22.prg is an example of using RTF from a report

both questions answered :-)

Re: RTF from Variable

Posted: Thu Dec 09, 2021 9:10 pm
by TimStone
Antonio,

1) Using the save puts the text into the memofield with the formatting commands. However, when I retrieve that text the next time, it is NOT in RTF format. It shows all the formatting commands. I have reviewed this thread about a dozen times and tried every option provided for retrieving the text and making it ready for the RTF edit, but none of them work. All of the efforts were made several years ago, so I assume updates to the code may have changed.

Here is the code I have:

Code: Select all | Expand


FUNCTION setup3
    // Text Editor for disclosures
    //  Updated:    7/30/2015 5:55:48 PM
   
    LOCAL oEndText, oDlg, nRcrd, oRich
    PRIVATE cText := " ", cTitle := " ", cRtf := " "
   
    // Open the text database
    oEndText := tEndText():New( )
    oEndText:gotop( )
   
   
   
    // Load the text

  cText := oEndText:tagtext

    // Create the dialog
    DEFINE DIALOG oDlg RESOURCE "SETUP3" BRUSH oBrush transparent OF oWnd
    oDlg:nHelpID := 6

    REDEFINE BUTTONBAR oBarS3 ID 100 SIZE 60,60 OF oDlg 2015
            oBarS3:bClrGrad := aPubGrad

           
    DEFINE BUTTON oWBtn3 OF oBarS3 RESOURCE "HRSAVE" ;
        ACTION (  oEndText:tagtext :=  oRich:SaveasRTF( cText ),  oEndText:save() )
    DEFINE BUTTON oWBtn5 OF oBarS3 RESOURCE "HREXIT" ;
        ACTION oDlg:end()

    // Create edit control
    REDEFINE RICHEDIT5 oRich VAR cText ID 2155 OF oDlg ;
        MESSAGE "Edit the text, and press OK to save your changes"  BARBUTTON  

    ACTIVATE DIALOG oDlg  CENTERED

    // Close the file
    oEndText:close()
   
RETURN NIL


 


Suggestions ? I've tried the various Set and Load options described in this thread. There does not seem to be a final one.

2) rep22.prg does not demo anything with .RTF. Also, my question is doing a printout of RTF text with the PRINTER class, and NOT with a report. As stated above, for the complexity of my need, I cannot use a REPORT. I need the equivalent for RTF of this output:

oPrn:SayText( nRow, 10 * nCsp, MemoLine( oEndText:tagtext, 60, lx,, .T. ),,, oFnorm )

I would expect a SayRTF() Method but in the tPrinter class there is absolutely nothing that addresses RTF in any way. Perhaps there is another way ?

Re: RTF from Variable

Posted: Thu Dec 09, 2021 9:14 pm
by Antonio Linares
Tim,

ACTIVATE DIALOG oDlg ON INIT ( oRich:LoadRTF( cRTF ), .T. )

same logic

Re: RTF from Variable

Posted: Thu Dec 09, 2021 9:19 pm
by Antonio Linares
Tim,

RTF means "Rich Text format" which means different font sizes and colors and thats exactly what you can see in rep22.prg

If you need to use different font sizes and colors just using a Printer object, there are lots of examples we can provide you.

Simplicity is the key

Re: RTF from Variable

Posted: Fri Dec 10, 2021 2:08 am
by TimStone
Antonio,

Thanks for the first response. I can now save and retrieve from the memo field. That is perfect.

The data in that field is many lines long. It is disclaimer text printed at the end of every invoice. Here is the code to print the contents:

Code: Select all | Expand


  IF cPRNTYP = "I"
      oEndText:goto( 3 )
      nRow += nRsp
      FOR lx := 1 TO MLCount( oEndText:tagtext, 60,, .T. )
         WOPAGEHEAD( oPrn, aHead )
         oPrn:SayText( nRow, 10 * nCsp, MemoLine( oEndText:tagtext, 60, lx,, .T. ),,, oFnorm )
         nRow += nRsp
      NEXT
   ENDIF


 


You said you have many examples of using the printer class to handle this. I would love to see the examples. Right now it prints the text with all the formatting symbols ( and displays it that way in Preview ). So my question is: What is the format to use with tPrinter class code to accomplish what I am showing you.

Re: RTF from Variable

Posted: Fri Dec 10, 2021 6:50 am
by Antonio Linares
Dear Tim,

This is the syntax for Class TPrinter Method SayText()

METHOD SayText( nRow, nCol, cText, nWidth, nHeight, oFont, cAlign, nClrText, nClrBack, cUnits, ;
nOutLineClr, nPenSize )

Please notice that you can use ANY font in oFont parameter, different colors, pensize...

That is RTF power :-)

Re: RTF from Variable

Posted: Fri Dec 10, 2021 6:19 pm
by TimStone
TO ALL =

I have started this in a NEW thread called "Print RTF using tPRINTER class ?????"

Maybe someone will read the post and understand what I need to do. Maybe I'm just getting too old to do this, but the comments keep missing the point of my need. I wish I could express it better.

Maybe a fresh start on the RTF printing question will be helpful.

Tim

Re: RTF from Variable

Posted: Sat Dec 11, 2021 7:41 am
by Antonio Linares