Page 1 of 1

Help - RTF Filter (all but text)

Posted: Thu Mar 16, 2006 10:08 pm
by Hydrate
I need to be able to filter everything in an RTF file but the text, but im not too sure where to start, has anyone got any documentation on this file and/or a way i could use to filter it?

Posted: Thu Mar 16, 2006 10:21 pm
by srod
A real dirty way is to load the .rtf content into an editor gadget and then use GetGadgetText() to pull out just the text etc.

PB 3.94.

Code: Select all

If OpenWindow(0,0,0,322,150,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"EditorGadget") And CreateGadgetList(WindowID(0)) 
EditorGadget(0,8,8,306,133) 

a$="{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}}"
a$+"{\colortbl ;\red255\green0\blue0;}{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 Hello \cf1\fs32 TESTING\cf0\f1\fs20\par}"

SetGadgetText(0, a$)
;Now get just the text.
b$=GetGadgetText(0)
Debug b$

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf 

Posted: Thu Mar 16, 2006 10:34 pm
by Hydrate
srod wrote:A real dirty way is to load the .rtf content into an editor gadget and then use GetGadgetText() to pull out just the text etc.

PB 3.94.

Code: Select all

If OpenWindow(0,0,0,322,150,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"EditorGadget") And CreateGadgetList(WindowID(0)) 
EditorGadget(0,8,8,306,133) 

a$="{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}}"
a$+"{\colortbl ;\red255\green0\blue0;}{\*\generator Msftedit 5.41.15.1503;}\viewkind4\uc1\pard\f0\fs20 Hello \cf1\fs32 TESTING\cf0\f1\fs20\par}"

SetGadgetText(0, a$)
;Now get just the text.
b$=GetGadgetText(0)
Debug b$

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf 

Haha thats excellent, i was looking more for a way of decoding, but hey, if the design plans are there, why not use them? thanks.

Posted: Thu Mar 16, 2006 10:36 pm
by srod
You're welcome.

Of course, hiding the editor gadget will make it completely transparent to the user etc.

Posted: Thu Mar 16, 2006 10:38 pm
by Hydrate
srod wrote:You're welcome.

Of course, hiding the editor gadget will make it completely transparent to the user etc.
Yea, i need to anyway since im planning on putting this into the scintilla gadget.