FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour extract text from richtext formated memo field
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
extract text from richtext formated memo field
Posted: Tue Apr 14, 2009 09:39 PM
Hi everyone!

I have richtext saved on memo fields. Sometimes I'd like to print just the text saved on the memo field. No richtext fonts and/or attributes. Just plain text. But don't want to go through the trouble and cpu time of defining the rtf control on screen before printing. Is it possible?

Example: Suppose I have this saved on the memo field:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 ARIAL;}}
\viewkind4\uc1\pard\f0\fs19      The specimen is labeled "GALLBLADDER", is submitted in formalin and consists of a gallbladder measuring 9 cm in length x 2.5 cm in maximum diameter. The serosa is purple-tan and smooth. The gallbladder wall averages 0.2 cm in thickness. The mucosa is green and flattened. Within the lumen admixed with green viscid bile are multiple yellow granular calculi measuirng 3 x 2 x 0.3 cm in aggregate. (RSS 1 CASS)  WVS:vsb  \par
}


Would print this:
The specimen is lablel "GALLBLADDER", is submitted in formalin and consists of a gallbladder measuring 9 cm in lenght....


No fonts no attributes. Just the text.

Can some help?


Reinaldo.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: extract text from richtext formated memo field
Posted: Sat May 16, 2009 10:01 AM

Could you find a solution ?

Regards



G. N. Rao.

Hyderabad, India
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: extract text from richtext formated memo field
Posted: Sat May 16, 2009 11:30 AM

No. The only way I found to extract text from a richttext control is with: oRtf:GetText(). But that requires for the richtext control to be created which means that a window has to be defined also.

Reinaldo.

Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: extract text from richtext formated memo field
Posted: Sun Oct 24, 2010 07:05 PM
nageswaragunupudi;

I did find a solution to the problem:
Code (fw): Select all Collapse
#DEFINE _cREGEX "\{?\\([a-z]{1,32}[0-9]* ?)([A-z, ]*;)?|}"  //includes fonts

function GetTextFromRTF( cRtfText, lKeepCRLFs )
local aRet 
local cStrip, i

    DEFAULT cRtfText := ""
    DEFAULT lKeepCRLFs := .t.
    
    aRet := hb_RegExAll( _cREGEX, cRtfText, .f. )

    if aRet == Nil  ;return cRtfText    ;endif
    
    aSort( aRet,,, { |x,y| len( x[1] ) > len( y[1] ) } )
    for i := 1 to len( aRet )

        cRtfText := StrTran( cRtfText, aRet[ i, 1 ], "" )
        
    Next 
    
    if !lKeepCRLFs
        cRtfText := StrTran( cRtfText, CRLF, " " )
    endif
    
Return cRtfText


Regards,


Reinaldo.

Continue the discussion