PureBasic 6.04 and 6/02 RTF "Issue"

Just starting out? Need help? Post your questions and find answers here.
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

PureBasic 6.04 and 6/02 RTF "Issue"

Post by offsides »

With my track record, I am hesitant to call anything a bug, any more. But after a recent PB upgrade to 6.04 from 6.01, my RTF project suddenly stopped working. The problem is that 6.04 appears to not recognize the rtf prolog as being rtf, just text. Ordinarily, when the EditorGadget is handed text with "\rtf1" in the first 6 chrs, it renders it accordingly.

I have done clean, identical, installs of PB 6.04, 6.02, and 6.01. The only one of the three that properly renders rtf on my machine is PB 6.01.
"My Machine" is a 2 year old HP running Win10, 32gb/1tb memory.

Here's something to try on your computer:

Code: Select all

Msg$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}" +
       "{\*\generator Riched20 10.0.19041}\viewkind4\uc1 " +
       "\pard\sa200\sl276\slmult1{\f0\fs22 " +
       "{\b This is a test rtf} to demonstrate\line " +
       "\i PureBasic 6.04 doesn't do rtf.\i0\line " +
       "\b PureBasic 6.02, also doesn't.\b0\line " +
       "\b\i But PureBasic 6.01 DOES.\i0\b0 }}"

If OpenWindow(#PB_Any, 0, 0, 250, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  Ed = EditorGadget(#PB_Any, 5, 5, 240, 250, #PB_Editor_ReadOnly)
  SetGadgetText(Ed, Msg$)
   
  Repeat 
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow   
EndIf

I'd be interested to hear what the forum sees on their systems.
Thanks,
Bill
PB 5.72 (32-bit) on Win 10.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by jacdelad »

Code: Select all

Msg$ = "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}" +
       "{\*\generator Riched20 10.0.19041}\viewkind4\uc1 " +
       "\pard\sa200\sl276\slmult1{\f0\fs22 " +
       "{\b This is a test rtf} to demonstrate\line " +
       "\i PureBasic 6.04 doesn't do rtf.\i0\line " +
       "\b PureBasic 6.02, also doesn't.\b0\line " +
       "\b\i But PureBasic 6.01 DOES.\i0\b0 }}"

If OpenWindow(#PB_Any, 0, 0, 250, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  Ed = EditorGadget(#PB_Any, 5, 5, 240, 250, #PB_Editor_ReadOnly)
  SendMessage_(GadgetID(Ed), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
  SetGadgetText(Ed, Msg$)
   
  Repeat 
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow   
EndIf

https://www.purebasic.fr/english/viewtopic.php?t=81402
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by offsides »

Many thanks, jacdelad. I totally missed that.
Thanks also for the quick reply!

Bill
PB 5.72 (32-bit) on Win 10.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by jacdelad »

To be fair, I knew about the problem and knew there was a simple solution with a single API call to fix that, but I still needed some minutes to find the solution. It's not easy to spot (or I'm dumb).
Last edited by jacdelad on Thu Dec 14, 2023 11:05 pm, edited 1 time in total.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Axolotl
Enthusiast
Enthusiast
Posts: 798
Joined: Wed Dec 31, 2008 3:36 pm

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by Axolotl »

Unfortunately, this feature of the EditorGadget() has been changed without notice. (... so all old RTF examples in the forum are not working anymore)
The corresponding entry in the help is definitely missing.
There should at least be something in the history. I would also like to see a note under EditorGadget().
P.S. How do you actually get to the history page in the online help?

hmmm, I always have to code something....

Code: Select all

Procedure main() 
  If OpenWindow(0, 0, 0, 280, 64, "Show Help Page History", #PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
    StickyWindow(0, 1)  ; small windows should be on top :)  
    TextGadget(0, 0, 0, 280, 64, "Show the PureBasic Help Page History" + #LF$ + "Close this window to get rid of the help as well.", #PB_Text_Center) 
    OpenHelp(#PB_Compiler_Home  + "PureBasic.chm", "MainGuide/history.html") 
    Repeat    ; main loop 
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break   ; say bye. 
      EndSelect
    ForEver ; main loop
    CloseHelp() 
  EndIf 
  ProcedureReturn 0 
EndProcedure 

End main() 
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by offsides »

Not wanting to beat a dead horse, at least not too much, I do ask:

Presumably the Linux and IOS PB editions are unchanged and automatically render rtf when they see it. If it takes an API call to fix the Windows version, can the call be built into the EditorGadget?

...and the Windows version is restored to the way it was and all those rtf applications out there don't have to be amended.

Just a thought
PB 5.72 (32-bit) on Win 10.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by jacdelad »

There already was a discussion, but I neither remember the thread, nor the outcome. I guess Fred has his reasons.
In the meantime you can include the following code near the top (or an include, however, it must be placed before any EditorGadget is created) to restore the old behaviour automatically:

Code: Select all

CompilerIf #PB_Compiler_OS=#PB_OS_Windows
  Procedure __EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags)
    If iGadget=#PB_Any
      iGadget=EditorGadget(#PB_Any,iX,iY,iWidth,iHeight,iFlags)
    Else
      EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags)
    EndIf
    If IsGadget(iGadget)
      SendMessage_(GadgetID(iGadget), #EM_SETTEXTMODE, #TM_RICHTEXT, 0)
    EndIf
    ProcedureReturn iGadget
  EndProcedure
  Macro EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags=0)
    __EditorGadget(iGadget,iX,iY,iWidth,iHeight,iFlags)
  EndMacro
CompilerEndIf
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by offsides »

jacdelad

I just insert the SendMessage_ .... after creating the EditorGadget. PB 6.04 now works fine.

Thanks for your input on this.
Bill
PB 5.72 (32-bit) on Win 10.
User avatar
jacdelad
Addict
Addict
Posts: 1991
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by jacdelad »

I assumed you wanted a more automated version for more projects (see your last post). However, both are fine and do basically the same. :)
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
offsides
Enthusiast
Enthusiast
Posts: 103
Joined: Sun May 01, 2011 3:09 am
Location: Northern California

Re: PureBasic 6.04 and 6/02 RTF "Issue"

Post by offsides »

Thanks, Jacdelad.

I'll likely use them both.
PB 5.72 (32-bit) on Win 10.
Post Reply