Help - RTF Filter (all but text)

Just starting out? Need help? Post your questions and find answers here.
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Help - RTF Filter (all but text)

Post 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?
.::Image::.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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 
I may look like a mule, but I'm not a complete ass.
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Post 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.
.::Image::.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

You're welcome.

Of course, hiding the editor gadget will make it completely transparent to the user etc.
I may look like a mule, but I'm not a complete ass.
Hydrate
Enthusiast
Enthusiast
Posts: 436
Joined: Mon May 16, 2005 9:37 pm
Contact:

Post 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.
.::Image::.
Post Reply