Variable Viewer, view passed pointed structure

Everything else that doesn't fall into one of the other PB categories.
User avatar
Thumper
User
User
Posts: 97
Joined: Sat Feb 01, 2014 2:16 am
Location: Alabama USA

Variable Viewer, view passed pointed structure

Post by Thumper »

Well, that's the best way I can describe it. I've been trying out the debugger and hit a bump trying to view passed pointed structure.

I call my button draw routines with

Code: Select all

drawNormalButton ( @wPlayer01 \ audioPause )
which is

Code: Select all

procedure drawNormalButton ( *thebutton._gadgetExt )
     if startDrawing ( canvasOutput ( *theButton \ id ) )
. . .
What I'm seeing in the Variable Viewer for *theButton is a number, the pointer value itself.

Since I have a usable structure _gadgetExt defined in the procedure, is there a way to make the variable viewer expand that to view the contents of that structure ? I've tried the usual double-clicking, right-click menu (Add to Watchlist), + key, etc.

And yes, the passed parameter is a structure within a structure. wPlayer01 contains all of the controls (and more), audioPause here which has the _gadgetExt structure. (And I'm still loving the structure capabilities of PureBasic!)

Anyhow, figuring this out would be helpful. My current workaround is to assign a temp variable to see the structure item in question.

Dan
I enter the PureBasic world, targeting both Mac and Windows, by way of PowerBasic, Win32API, EZGUI back to CP/M via various BASIC dialects, xBase and other languages as needed.
Side project: http://www.thecomputerarchive.com
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Variable Viewer, view passed pointed structure

Post by HeX0R »

Not sure why you didn't provide a usable short code instead of a difficult to follow description.
Assuming I got it correct, with the internal debugger you can show the content, when hovering over *button:
Image

I don't think it is possible with the variable viewer
User avatar
Thumper
User
User
Posts: 97
Joined: Sat Feb 01, 2014 2:16 am
Location: Alabama USA

Re: Variable Viewer, view passed pointed structure

Post by Thumper »

Well, I've been told that my messages were too long so I posted only what is needed. Also, I don't see the source code. I've got something else. Give me a few hours to write something and make a screen shot.
I enter the PureBasic world, targeting both Mac and Windows, by way of PowerBasic, Win32API, EZGUI back to CP/M via various BASIC dialects, xBase and other languages as needed.
Side project: http://www.thecomputerarchive.com
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Variable Viewer, view passed pointed structure

Post by HeX0R »

You shouldn't invest several hours, I said a "usable short code".
Which is a tiny code, anyone can paste into the IDE, press F5, it runs and people can look into it.
Like mine, you didn't say a word now, did I miss the point? Hovering in the IDE is not accepted?
Here again my quick'n dirty code according to your description:

Code: Select all

Structure _gadgetExt
	id.i
	s.s
EndStructure

Structure Player
	audioPause ._gadgetExt
EndStructure

Define Player.Player


Procedure BBBLA(*button._gadgetExt)
	Debug *button\id ;<- hover here over *button
	
	
	
	CallDebugger
EndProcedure

Player\audioPause\id = 12
BBBLA(@Player\audioPause)
User avatar
Thumper
User
User
Posts: 97
Joined: Sat Feb 01, 2014 2:16 am
Location: Alabama USA

Re: Variable Viewer, view passed pointed structure

Post by Thumper »

I am on an extended phone call that will probably last at least another hour and will write something after the call.
I enter the PureBasic world, targeting both Mac and Windows, by way of PowerBasic, Win32API, EZGUI back to CP/M via various BASIC dialects, xBase and other languages as needed.
Side project: http://www.thecomputerarchive.com
User avatar
Thumper
User
User
Posts: 97
Joined: Sat Feb 01, 2014 2:16 am
Location: Alabama USA

Re: Variable Viewer, view passed pointed structure

Post by Thumper »

I've distilled a real program to the essence below. Setting standardFont to 0 deliberately causes an error. What I'm showing is that cannot how to see how to get the variable viewer to show structure contents. Nothing serious. It will show other variables just fine. My solution has been to assign a temp variable before the error line and re-run.

Code: Select all

     structure _windowExt
          id                       .i
     endStructure

     structure _gadgetExt
          id                       .i
          type                     .i
          text1                    .s{1024}
          font1                    .i
     endStructure

     structure _pbpp_w_home
          window                   ._windowExt
          close                    ._gadgetExt
     endStructure

     declare w_home_create ( )
     declare drawButton ( *theButton._gadgetExt )

     global exitEventProcessor     .i = 0
     global w_home                 ._pbpp_w_home
     global standardFont           .i = 0 ; fontID ( loadFont ( #pb_any, "Courier New", 12 ) )
                                      ; setting to 0 to  _deliberately_ causing an error to show debugger

     procedure w_home_create ( )
          w_home \ window \ id = openWindow ( #pb_any, 0, 0, 200, 50, "Test proggy", #pb_window_screenCentered | #pb_window_systemMenu, 0 )

          if w_home \ window \ id
               with w_home \ close
                    \id = canvasGadget ( #pb_any, 5, 5, 190, 40 )
                    \text1 = "Close Program"
                    \font1 = standardFont
               endWith
               drawButton ( @w_home \ close )
          endIf
     endProcedure

     procedure drawButton ( *theButton._gadgetExt )
          if startDrawing ( canvasOutput ( *theButton \ id ) )
               drawingMode ( #pb_2dDrawing_default )
               box ( 0, 0, outputWidth ( ), outputHeight ( ), $004040 )

               drawingMode ( #pb_2dDrawing_transparent | #pb_2dDrawing_nativeText )
               drawingFont ( *theButton \ font1 )  ; error triggered here
               drawText ( 0, 0, *theButton \ text1 )
               stopDrawing ( )
          endIf
     endProcedure

     w_home_create ( )

     repeat
          select waitWindowEvent ( )
               case #pb_event_closeWindow
                    if eventWindow ( ) = w_home \ window \ id
                         closeWindow ( w_home \ window \ id )
                         exitEventProcessor = 1
                    endIf

               case #pb_event_gadget
                    if eventGadget ( ) = w_home \ close \ id
                         select eventType ( )
                              case #pb_eventType_leftClick
                              closeWindow ( w_home \ window \ id )
                              exitEventProcessor = 1
                         endSelect
                    endIf
          endSelect
     until exitEventProcessor = 1
Image

And here is a snippet of the batch file in case that is the problem.

Code: Select all

set currentProgram=t9889
set currentExecutable=%currentProgram%.exe

call "\progutil\PureBasic\purebasic 6.20\compilers\pbcompiler.exe" "%currentProgram%.%cpextension%" --output "%currentExecutable%" --thread --optimizer --debugger /dynamiccpu /UCRT
pb6debugger %currentExecutable%
I enter the PureBasic world, targeting both Mac and Windows, by way of PowerBasic, Win32API, EZGUI back to CP/M via various BASIC dialects, xBase and other languages as needed.
Side project: http://www.thecomputerarchive.com
User avatar
Thumper
User
User
Posts: 97
Joined: Sat Feb 01, 2014 2:16 am
Location: Alabama USA

Re: Variable Viewer, view passed pointed structure

Post by Thumper »

Oh, and I do not use the PureBasic text editor. Let's just say that I have a well established workflow and am compiling from batch files.
I enter the PureBasic world, targeting both Mac and Windows, by way of PowerBasic, Win32API, EZGUI back to CP/M via various BASIC dialects, xBase and other languages as needed.
Side project: http://www.thecomputerarchive.com
PBJim
Enthusiast
Enthusiast
Posts: 294
Joined: Fri Jan 19, 2024 11:56 pm

Re: Variable Viewer, view passed pointed structure

Post by PBJim »

I would think that the variable viewer is not intended to provide for the opening of structure elements when the structure is assigned to a pointer, at least that's the way it looks to me. As the icon appears as a block, rather than the usual arrow, I'd say it was deliberate.

It can be seen with a simple example. If we take existing code that's shown within the Pointers and memory access help, it allows us to open Point1 and its structure, but not *CurrentPoint. I couldn't see anything in the variable viewer help that might confirm this, but I would say that's the case. It provides only the pointed address — confirmed below.

Code: Select all

Define Point1.Point, Point2.Point

*CurrentPoint.Point = @Point1
*CurrentPoint \x = 10
*CurrentPoint.Point = @Point2
*CurrentPoint \x = 20

Debug *CurrentPoint

ShowVariableViewer()
CallDebugger
User avatar
spikey
Enthusiast
Enthusiast
Posts: 749
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Variable Viewer, view passed pointed structure

Post by spikey »

I think this could be a feature request. The context debugger popup in the IDE supports dereferencing this sort of pointer:

Image

I'm guessing that it's possibly a case that the variable viewer window has never been updated to display it too. If I recall correctly, the context debugger info is a "new" feature introduced since I first started using PB so it's feasible the two features have become out of sync.
User avatar
Thumper
User
User
Posts: 97
Joined: Sat Feb 01, 2014 2:16 am
Location: Alabama USA

Re: Variable Viewer, view passed pointed structure

Post by Thumper »

Well, the Variable Viewer does show structures for local variables. It just seems that it cannot when the passed parameter points to a structure. It would be helpful but the workaround to create a local variable just before the error is still a means.

Still, I've used the --debugger a few times and have found it quite useful. It had almost exactly what is needed. Now that I think about, did PowerBasic even have a debugger?

Anyhow, thanks for looking at it. I'm moving on... doing a lot of graphics work tonight. Going to see if I can figure out what a "screen" really is...

Cheers!
I enter the PureBasic world, targeting both Mac and Windows, by way of PowerBasic, Win32API, EZGUI back to CP/M via various BASIC dialects, xBase and other languages as needed.
Side project: http://www.thecomputerarchive.com
PBJim
Enthusiast
Enthusiast
Posts: 294
Joined: Fri Jan 19, 2024 11:56 pm

Re: Variable Viewer, view passed pointed structure

Post by PBJim »

spikey wrote: Wed Jul 23, 2025 8:10 pm I think this could be a feature request. The context debugger popup in the IDE supports dereferencing this sort of pointer
I tend to take the view that the variable viewer is fine as it is — pointers with structures are an advanced feature and to some extent not an unreasonable limitation and which we can see while hovering over the pointer variable. Perhaps there was a technical obstacle.

I'm glad that the OP raised this though — I hadn't previously considered that the variable viewer could serve as a useful means of identifying possible obsolete vars in procedures :D
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Variable Viewer, view passed pointed structure

Post by User_Russian »

PBJim wrote: Thu Jul 24, 2025 8:32 amand which we can see while hovering over the pointer variable.
You cannot see all the fields of the structure. Only a few fields are displayed (note the three dots at the bottom of the window).
Image
Also, you will not be able to view an array or list in this structure.
Post Reply