Page 1 of 1
remove formatting within a memo field
Posted:
Thu Jan 26, 2017 4:19 pm
by don lowenstein
I am reading a SQL database via ADO.
one of the data Items I'm using is a memo field, with embedded formatting.
here is an example:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17 JH - Sue let me know that their rep had noticed that they were not performing the yearly escrow analysis.\par
}
What I wish to preserve is the message without the formatting:
JH - Sue let me know that their rep had noticed that they were not performing the yearly escrow analysis.
Is there a function that will remove these formatting characters automatically?
I noticed that using DBU the memoedit function appears to ignore MOST of these.
Re: remove formatting within a memo field
Posted:
Thu Jan 26, 2017 5:35 pm
by Rick Lipkin
Don
I have used this to remove CRLF and carriage returns .. try this :
- Code: Select all Expand view
cText := HardCr( oRs:Fields("Memo"):Value )
HardCR()
Replaces soft carriage returns with hard CRs in a character string.
Syntax
HardCR( <cString> ) --> cConvertedString
Arguments
<cString>
A character string to be converted. Return
The function returns <cString> with all soft carriage returns converted to hard carriage returns.
Description
Soft carriage returns (Chr(141)+Chr(10)) are inserted into a string by MemoEdit() when a line wraps during editing. The string returned from MemoEdit() retains soft carriage returns and is usually stored in a memo field. When such a string must be printed or displayed with another function than MemoEdit(), it is necessary to replace soft carriage returns with hard carriage returns (Chr(13)+Chr(10)) since soft carriage returns are not interpreted as end of line characters.
Note: when a memo field is output using a proportional font, use MemoTran() to replace soft carriage returns with a space character.
Rick Lipkin
Re: remove formatting within a memo field
Posted:
Thu Jan 26, 2017 7:37 pm
by cnavarro
This function is not perfect, but it is an idea
- Code: Select all Expand view
#include "Fivewin.ch"
Function Main()
local cString
local cTmp1 := ""
local nPos1 := 0
local nPos2 := 0
cString := "{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}" + ;
"\viewkind4\uc1\pard\f0\fs17 JH - Sue let me know that their rep had noticed that they were not performing the yearly escrow analysis.\par" + ;
"}"
cString := StrTran( cString, CRLF, "" )
nPos1 := At( "{\", cString )
if !Empty( nPos1 )
nPos2 := At( "}", cString )
if !Empty( nPos2 )
cTmp1 := Substr( cString, nPos1, nPos2 - nPos1 + 1 )
cString := StrTran( cString, cTmp1, "" )
cString := StrTran( cString, "}", "" )
cString := StrTran( cString, "{", "" )
nPos1 := At( "\", cString )
if !Empty( nPos1 )
nPos2 := At( Chr( 32 ), cString )
cTmp1 := Substr( cString, nPos1, nPos2 - nPos1 + 1 )
cString := StrTran( cString, cTmp1, "" )
endif
cString := StrTran( cString, "\par", "" )
endif
endif
? cString
Return nil
Re: remove formatting within a memo field
Posted:
Thu Jan 26, 2017 9:07 pm
by don lowenstein
Cristobal,
That is essentially what I did.
thanks for providing your input.
Don.
Re: remove formatting within a memo field
Posted:
Thu Jan 26, 2017 9:59 pm
by cnavarro
You are not going to have a TRichEdit control?
It's just going to have a formatted string, right?
Re: remove formatting within a memo field
Posted:
Fri Jan 27, 2017 12:46 am
by don lowenstein
correct.
I'm wishing to print the memo data on a report without all of the embedded formatting.
Re: remove formatting within a memo field
Posted:
Fri Jan 27, 2017 12:49 am
by cnavarro
What I mean is that the string does not read from a RichEdit control, does it?