I have a main window ( WNDW_main ) and i have a logging window with just and editorgadget ( WNDW_log ).
I have a lot of processing steps in WNDW_main so would like to update the editor gadget on WNDW_log accordingly.
The editor gadget on the log window is defined as a GLOBAL variable using #PB_any.
But try as i might when i want to update the editorgadget from WNDW_main i get 'gadget not initialised' and when i check the gadget id is returned as zero even though its defined as a global.
Also should WNDW_log have /not have an eventloop because I dont want it to have the focus at any time as its just a visual aid.
Any help is appreciated.
Captain S.
Update a seperate Logging window
- captain_skank
- Enthusiast

- Posts: 644
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: Update a seperate Logging window
The main event loop should be able to handle both windows.
If you don't require any window-specific control, this would suffice:
However, if you would prefer to separate each window's events, do it like this:
The #PB_Editor_ReadOnly flag would prevent the editor gadget from pulling focus.
Hope it helps.
If you don't require any window-specific control, this would suffice:
Code: Select all
Win1 = OpenWindow(#PB_Any, 300, 300, 300, 150, "Main Window", #PB_Window_SystemMenu)
Win1Text = TextGadget(#PB_Any, 20, 50, 260, 30, "Elapsed: 0 sec")
AddWindowTimer(Win1, 0, 1000)
Win2 = OpenWindow(#PB_Any, 620, 300, 300, 150, "Log Window", #PB_Window_SystemMenu)
Win2Editor = EditorGadget(#PB_Any, 20, 20, 260, 100, #PB_Editor_ReadOnly)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Timer
elapsed + 1
If Not Mod(elapsed, 5)
SetGadgetText(Win2Editor, "Another five second elapsed at: " + FormatDate("%hh:%ii:%ss", Date()))
EndIf
SetGadgetText(Win1Text, "Elapsed: " + Str(elapsed) + " secs")
EndSelect
Until appQuit
However, if you would prefer to separate each window's events, do it like this:
Code: Select all
Win1 = OpenWindow(#PB_Any, 300, 300, 300, 150, "Main Window", #PB_Window_SystemMenu)
Win1Text = TextGadget(#PB_Any, 20, 50, 260, 30, "Elapsed: 0 sec")
AddWindowTimer(Win1, 0, 1000)
Win2 = OpenWindow(#PB_Any, 620, 300, 300, 150, "Log Window", #PB_Window_SystemMenu)
Win2Editor = EditorGadget(#PB_Any, 20, 20, 260, 100, #PB_Editor_ReadOnly)
Repeat
event = WaitWindowEvent()
Select EventWindow()
Case Win1
Select event
Case #PB_Event_CloseWindow
appQuit = #True
Case #PB_Event_Timer
elapsed + 1
If Not Mod(elapsed, 5)
SetGadgetText(Win2Editor, "Another five second elapsed at: " + FormatDate("%hh:%ii:%ss", Date()))
EndIf
SetGadgetText(Win1Text, "Elapsed: " + Str(elapsed) + " secs")
EndSelect
Case Win2
Select event
Case #PB_Event_CloseWindow
MessageRequester("Win2", "Close app from Main Window.")
EndSelect
EndSelect
Until appQuit
Hope it helps.
Last edited by TI-994A on Fri Dec 12, 2025 12:01 pm, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Update a seperate Logging window
In addition to the above post.
The error message indicates a “race condition.”
You may be calling the output before creating the window gadgets.
So: Before using the gadgets, simply check for their existence with IsGadget().
BTW: If the main loop is to be kept free of special events, there is also BindEvent() and its companions.
The error message indicates a “race condition.”
You may be calling the output before creating the window gadgets.
So: Before using the gadgets, simply check for their existence with IsGadget().
BTW: If the main loop is to be kept free of special events, there is also BindEvent() and its companions.
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).
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).
- captain_skank
- Enthusiast

- Posts: 644
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: Update a seperate Logging window
Thanks for the replies, found an alternate way of acheiving the required result.
The interesting pasrt for me was that i was creating and displaying the WNDW_log and showing the gadgetid in the editor gadget, but when i tried show it ( using debug ) in WNDW_main it was always returning an id of 0.
Anyhooo thanks for the pointers.
Cheers
The interesting pasrt for me was that i was creating and displaying the WNDW_log and showing the gadgetid in the editor gadget, but when i tried show it ( using debug ) in WNDW_main it was always returning an id of 0.
Anyhooo thanks for the pointers.
Cheers
Re: Update a seperate Logging window
Are you using modules, and are WNDW_main and WNDW_log in different modules?captain_skank wrote: Fri Dec 12, 2025 12:51 pm The interesting pasrt for me was that i was creating and displaying the WNDW_log and showing the gadgetid in the editor gadget, but when i tried show it ( using debug ) in WNDW_main it was always returning an id of 0.
Re: Update a seperate Logging window
You need named enumerations and with modules a common module.
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
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive

