Richedit raw text
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hoi,
I tried in my 4GL form and found the somewhat peculier way of working. I have to initiate a SMOD before the data is transported from the control into the 4GL. Looking into this property it seems to be invented for internal testing and not for 4GL development purposes so that's why this has never been documented. I'm sorry that my quick answer did not completely solved the problem. I put the problem as follows on the internal list of things to investigate and /or solve:
Following is added to the list ( without warranty ;-))
In many cases the content of a richeditbox cannot be used in the 4GL to do simple comparisons. The reason is that the field content is in RTF i.s.o plain text.The 4GL developer will be very much helped when the lab introduces a simple call to get the field content as text.
4GL sample
activate "richtext".rich2text(fieldname,outString)
Where:
"richtext": pseudo component
rich2text: function name
fieldname: is the fieldname having the richedit control as widget
outString: out parameter of the function and delivers the content in plain text.
Do you think this is sufficient?
I hope we can come up with a solution in our next release
Kind regards,
Jasper de Keijzer
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hi Jasper,
to make it easy for us coders (and use the dITo approach),
I recommend a global proc returning the ASCII text
"mytext = ret_rtf2text(myrtftext)"
For the moment in time, we can use any type of 4GL converter/"hidden" form
just like Luigis code above.
later on the proc is an adapter to $rtf2text() function.
Success, Uli
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hi Jasper,
thank you for your clarification.
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hi Larry,
found a PERL freeware solution at: http://www.schlagmueller.de/programmieren/rtf2txt.htm
Perhaps the sources will help you to solve the situation.
Or you can check http://text-mining-tool.com/
Most interesting may be a C++ RTF to TEXT code at: http://www.codeguru.com/cpp/controls/richedit/article.php/c2423#more
SUccess, Uli
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
and (not for the uniface widget, but perhaps for an OCX of richedit) I found:
Answer:
The SaveFile method of the RichTextBox control can be called with an additional argument: filetype. If you call SaveFile as follows, it will save your text without any RTF tags:
RichTextBox.SaveFile "testfile.txt", 1
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
I've developed a C#-COM extension, not so easy to deploy ad a native function.
a $rawtext or similar function should be provided
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hi Larry,
there is a small c program which has a nice algorithm to derive a pure-uniface-implementation from.
Slightly modified "{\\rtf0" is now "{\\rtf1"
Success, Uli
Code is: ************************ cut here *************************************
*
rtf2ascii.c - convert rtf to ascii
coded in 1994 by Felix Rauch
felix@nice.ch
*/
#include <stdio.h>
FILE *in;
void scanblock(void) /* scan a block in `{}' */
{
int c;
while(!feof(in) && ((c = fgetc(in)) != '}')) {
if(c == '{')
scanblock();
}
}
int scanpart(void) /* return 1 if text follows, otherwise 0 */
{
int c;
while(!feof(in)) {
c = fgetc(in);
if(c == ' ') /* the rest until '\\n' is test */
return 1;
else if(c == '\\n') /* end of command-part */
return 0;
else if(c == '\\{') /* skip whole block */
scanblock();
}
return 0; /* not reached if there are no errors */
}
void scantext(void) /* scan text until '\\n' */
{
int c;
while(!feof(in) && ((c = fgetc(in)) != '\\n')) {
if(c == '\\\\') /* escape char */
c = fgetc(in);
fputc(c, stdout);
}
}
void main(int argc, char *argv[])
{
int i, c, ret;
char rtfc[7] = "{\\\\rtf1";
if(argc == 1)
in = stdin;
else if(argc == 2)
in = fopen(argv[1], "r");
for(i = 0; i < 6; i++) { /* rtf-magic-cookie test */
if(fgetc(in) != rtfc[i]) {
puts("not in rtf-format");
exit(1);
}
}
while(!feof(in)) {
ret = 2; /* no command part or block found yet */
c = fgetc(in);
if(c == '\\\\') {
ret = scanpart(); /* command part */
}
else if(c == '\\{') { /* block found */
scanblock();
ret = 0;
if((c = fgetc(in)) != '\\n') /* a '\\n' after a block must be ignored */
ungetc(c, in);
}
else if(c == '}') { /* end of rtf-stream */
break;
}
if(ret > 0) { /* if there's text after a command part or just text */
if(ret == 2) /* if just text, the print first char */
fputc(c, stdout); /* (otherwise it's a '//' */
scantext(); /* text block */
}
}
exit(0); /* that's all, dude */
}
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hi Ulrich,
I would thank you for your suggestion to translate in Uniface the clever algorithm implemented by Felix Rauch.
I have downloaded this morning a program that attempts to resolve the problem in Uniface environment.
Many thanks
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
$fieldproperties(Field.entity)="Format=Text"
Assigning the data to a field gives the plain text.
Any other value changes the output to RTF.
For instance:
$fieldproperties(Field.entity)="Format=RTF"
Hope this helps.
- Jasper
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Very good. I will try.
Many thanks
Author: adkinsl@proware.com (hoss)
Please make available the raw text through the $fieldproperties (or something) so it will be possible to access the non-marked up version of the data displayed within this widget.
Hi Jasper,
I have done today some tests to understand how to use, according to your suggestion, $fieldproperties with 'Format=text' property to convert in some way an RTF text to a raw text.
Of course $fieldproperties cannot change physical content of a field; thus applying 'Format=text' to a not empty richeditbox has no effect on its whole value (RTF formatting sequences and unformatted data); therefore field to field procedural assignments continue to transfer always whole value (included formatting sequences).
However a visible effect can be obtained drawing a richeditbox field (database or non-database) and then changing its characteristic applying 'Format=text' property to the widget; thereafter, if you fill that field inserting RTF text by means, for example, 'cut and past' actions or by hand writing (never procedurally) , RTF text is being cleaned and becomes an unformatted raw text as you can observe viewing content field in debug mode.
Likely there are other 'tricks' for better to use this interesting property but I have not be able to find it.
Many thanks
P.S. : Where is documented this particular property for $fieldproperties ? Is it mentioned in some official or unofficial manual ?
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.