Page 1 of 1
Hi guys, been a long time...
Posted: Sun Mar 25, 2018 2:08 am
by Zach
Some of you might remember me, some of you probably don't
I was the guy working on the Text RPG game engine a few years back. I've been gone a long time as I have been dealing with a lot of personal / health issues and I have not programmed anything for many years.
I actually thought about trying to get started again, a few weeks back, but to my dismay I discovered that I had lost a lot of my source code progress. What I have remains much older prototype and testing code and I probably lost a lot of things I don't even remember thinking about!
I know TomS was instrumental in helping me with several things, including working with me and helping me when we were both co-developing our own RTF parsing and text coloring functions for the richeditor gadget.. It looks like TomS has also not been here in a long time (2011 ??)
Not sure if I'll be able to get over the hump of starting over on a lot of stuff, but hopefully there are still some people smarter than me who can throw me a bone when I try to get some broken code with my RTF parser working under Windows 10 (not sure what went wrong lol)
Hope everyone is doing well

Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 3:47 am
by Dude
Zach wrote:hopefully there are still some people smarter than me who can throw me a bone when I try to get some broken code with my RTF parser working
Of course we will. There's plenty of friendly, helpful people here. Welcome back!
Tip: Post in "Coding Questions" rather than PM'ing someone for direct help, as you'll get more eyes that way and won't monopolise one single person's time.

Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 7:52 am
by Bitblazer
Welcome back Zach
I actually remember you and while i don't use RTF gadgets myself, so i cant instantly help out, i am sure you will get started and helped by others.
Ironically i found RTF example code at
rsbasic's awesome collection , but my browser and my KIS AV suite both went mad about the included executable in that example. It might be another false positive as we all have them sometimes with PB executables, but i can't verify that quickly. So i post the link here as untested (just download it, erase the exe and use the included rtf example source - no need for the exe anyway).
The name of the example is
adveditor_b.zip
KIS claims the binary is infected with
Find and Call: Leak and Spam and if you read the description about it, it's very unspecific and supposed to be the usual generic advertisement spam, just erase the exe untested.
Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 8:29 am
by Zach
it looks like its using some external library to handle stuff so I'm not really sure I can glean anything useful from the source code (sure is big to my small brain).
Anyhow I bumped an old thread in General Discussion so hopefully people will stop by there to offer advice

Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 8:54 am
by Bitblazer
The authors homepage ironically doesnt have the sources for this specific library either and his contact form isn't existing.
I could phone him as i speak german too and found his number, but its sunday and i try to not come across like an internet stalker

Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 2:01 pm
by mk-soft
I looked at your request for RTF parser.
The problem is that the EditorGadget (RichEdit) is still UTF8 and Purebasic is UNICODE internally.
Thus Purebasic must internally translate the text for the EditorGadget to UTF8. Your own RTF formatting will be lost.
So you have to add the text in UTF8 directly to the gadget to avoid losing the formatting.
Link to your code:
http://www.purebasic.fr/english/viewtop ... 30#p519950
Update v1.04
Code: Select all
;-TOP
; *****************************************************************************
; AddTextRTF by mk-soft, v1.04, 25.03.2018
CompilerIf #PB_Compiler_Version < 550
Procedure UTF8(Text.s)
Protected *mem = AllocateMemory(StringByteLength(Text, #PB_UTF8) + 1)
If *mem
PokeS(*mem, Text, -1, #PB_UTF8)
EndIf
ProcedureReturn *mem
EndProcedure
CompilerEndIf
Procedure AddTextRTF(Gadget, Text.s , NewLine=#True)
If Left(Text, 5) <> "{\rtf"
Text = "{\rtf " + Text + "}"
EndIf
CompilerIf #PB_Compiler_Unicode
Protected hEdit = GadgetID(Gadget)
Protected ndx = GetWindowTextLength_(hEdit)
Protected *szBuffer = UTF8(Text)
Protected hFocus = GetFocus_()
If ndx And NewLine
AddGadgetItem(Gadget, -1, "")
EndIf
SetFocus_(hEdit);
SendMessage_(hEdit, #EM_SETSEL, ndx, ndx)
SendMessage_(hEdit, #EM_REPLACESEL, 0, *szBuffer)
SetFocus_(hFocus);
FreeMemory(*szBuffer)
CompilerElse
AddGadgetItem(Gadget, -1 , Text)
CompilerEndIf
EndProcedure
; *****************************************************************************
I don't know is a bug or features
P.S.
The RichEdit control has a check on the text "{\rtf".
If this text is recognized at the beginning, the text is interpreted as UTF8 and translated by Control.
Otherwise, the text is interpreted as Unicode text.
Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 3:18 pm
by Zach
Thanks mk!
Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 7:27 pm
by RASHAD
Hi Zach
Why do not you load your RTF file into the EditorGadget then add or delete or correct any text then save it as RTF file again
Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 7:45 pm
by Zach
RASHAD wrote:Hi Zach
Why do not you load your RTF file into the EditorGadget then add or delete or correct any text then save it as RTF file again
This is not for viewing files, it is for dynamically generated and formatted game content. A lot of this data is not really going to be static, and I don't feel like saving/reloading a file would be efficient or potentially elegant as a real-time scrolling solution (redraw flicker?, also constant R/W on users drive).
I did think about this as a potential solution, but then I thought "if I can't even get RTF to show up in the editor properly, would saving it result in the same problem"
Re: Hi guys, been a long time...
Posted: Sun Mar 25, 2018 8:42 pm
by RASHAD
You do not have to show any EditorGadget()
Just send your data to the gadget using AddGadgetItem()
When you finished save the file
And it is there as RTF
Code: Select all
Global EStream.EDITSTREAM
Procedure SStreamCB(dwCookie, pbBuff, cb, pcb)
ProcedureReturn WriteFile_(dwCookie, pbBuff, cb, pcb, 0) ! 1
EndProcedure
If OpenWindow(0, 0, 0, 100, 100, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 0, 0, 0, 0)
ButtonGadget(3,10,10,60,20,"Save")
AddWindowTimer(0,100,100)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
Case #PB_Event_Timer
Run + 1
AddGadgetItem(0,-1,Str(Run))
Case #PB_Event_Gadget
Select EventGadget()
Case 2 ;Load
Case 3 ;Saving
If CreateFile(0, GetHomeDirectory()+"Document.rtf")
EStream\dwCookie = FileID(0)
EStream\pfnCallback = @SStreamCB()
SendMessage_(GadgetID(0), #EM_STREAMOUT, #SF_RTF, EStream)
CloseFile(0)
EndIf
EndSelect
EndSelect
ForEver
EndIf
Re: Hi guys, been a long time...
Posted: Wed Mar 28, 2018 4:16 am
by Kuron
ZACH!! Welcome back, big bro hugs for you! Been going through my own personal hell as of late and I see no sign of it letting up soon. Hang in there, bro!!!
The Devil whispered in my ear "You're not strong enough to withstand the storm." Today I whispered in the Devil's ear "Never underestimate the tenacious power of a VET -- I am the Storm!"