The debugger shows me values of the local procedure, but not globals. How can I see them?
Once a breakpoint has been reached, see the “Variables” window and click on the “Globals” link.
In a simple Desktop application having “Window1”, all its variables inclduing any “Properties” that have “Public” scope, should now be visible.
I have defined several Properties with Global scope and they do not appear. The drop down list only shows “Variables” and they are all local.
They are there, you just have to ‘open’ up the listed item. Sometime it takes a while.
Don’t forget to pack a lunch, you can really get lost in the debugger.
At a breakpoint, it seems Xojo does not show any variables from a newly added “Module1” unless such property has been accessed in the code that has been executed before/at the breakpoint. If few “Properties” with “Global” or “Private” scope are added to this new “Module1” then in the “Variables” window in “Globals” list, even the “Module1” name does not appear under “Modules”, unless one of its property has been accessed. Even in that case the other properties that have not yet been accesses, are not displayed.
Wow. You’re right. That’s a pretty severe limitation. Hopefully, there’s some hidden switch that just needs to be flipped.
That lunch is not to be eaten, by the way. It has to be used as done by “Hansel and Gretel”, to find the way back home.
Its seems the Xojo Memory Manager at work here and applying the JIT principle, one can only guess though.
HINT!
What I will do sometimes is put
Dim sxx as string = Globalwhaterever
break
at a place where I want to see the global.
It’s something like that. If you access them anywhere else in the app, even if that code path hasn’t been executed yet, then they appear. It’s like they’ve been optimized out of the compiled program, which isn’t so bad, I guess.
Okay, I can see them now. But this is what I have to do to see the variable I want:
Click Globals, click Modules, click Globals again.
I check the variable and run again. The next time into the breakpoint I have to make all those selections again??? It’s unbearably tedious.
So you’re not using those variables anywhere else in the program?
Not yet. I’m building the app. That’s why I’m looking at the values, to see if the code is working.
So there’s really nothing to see then. It’s showing the properties that are actively being used in your project (anywhere) and hiding the unused values.
Tim, I don’t think so. For me it works like Bryan described. It’s a PIA. Otherwise he need to step thru the code where the properties are being used.
Does Xojo compiler not show warning for unreferenced global and local objects/variables?
Guess it seems pointless to allocate memory for unreferenced objects/variables.
Odd. I added a couple properties to a module and put a break in window1.open. Nothing more in the project. Hit run and couldn’t even see the module in the list of modules. Then I put code to access them in window1.cancelclose. Run again, and the module plus the ones I accessed in cancelclose show up.
The compiler does strip dead code. Perhaps you’re seeing the effects of that?
Not sure about Xojo compiler, however some compilers do show the warnings listed in the sample code below.
Dim x As String
Dim y As String
Dim z As Integer // Compiler Warning: Unreferenced Local Variable 'z'
Dim u As Int32
Dim v As Int32
u = 1
v = 2
If u = v Then // Compiler Warning: Condition is always False
u = v * 2 // Compiler Warning: Unreachable Code
Else
x = y // Compiler Warning: Variable 'y' used without initilization
End If
It doesn’t warn unless you run an analyze of the project
Building should not be stopped with a bunch of warnings