Hi guys, been a long time...

For everything that's not in any way related to PureBasic. General chat etc...
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Hi guys, been a long time...

Post by Zach »

Some of you might remember me, some of you probably don't :oops:

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! :cry:

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 8)
Image
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Hi guys, been a long time...

Post 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. ;)
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Hi guys, been a long time...

Post 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.
webpage - discord chat links -> purebasic GPT4All
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Hi guys, been a long time...

Post 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). :oops:

Anyhow I bumped an old thread in General Discussion so hopefully people will stop by there to offer advice :mrgreen:
Image
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Hi guys, been a long time...

Post 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 :P
webpage - discord chat links -> purebasic GPT4All
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Hi guys, been a long time...

Post 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.
Last edited by mk-soft on Sun Mar 25, 2018 8:10 pm, edited 2 times in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Hi guys, been a long time...

Post by Zach »

Thanks mk!
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Hi guys, been a long time...

Post 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
Egypt my love
Zach
Addict
Addict
Posts: 1654
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: Hi guys, been a long time...

Post 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"
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Hi guys, been a long time...

Post 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
Egypt my love
User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: Hi guys, been a long time...

Post 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!"
Best wishes to the PB community. Thank you for the memories. ♥️
Post Reply