Page 1 of 1
How to view the value of a PRIVATE variable in debugger?
Posted: Wed Aug 24, 2022 3:59 pm
by kevclark64
A variable which is created with PRIVATE or DIMENSION isn't available in Locals and it does not appear capable of being added to the Watch window since it says it does not exist in the current context. Some time ago there was an article posted on this site saying that PRIVATE variable values could be viewed using XSharp.MemVar.Privates in the watch window. That does not seem to work anymore, so I'm wondering if there is an alternative way to view PRIVATE variables.
How to view the value of a PRIVATE variable in debugger?
Posted: Wed Aug 24, 2022 5:12 pm
by Chris
Hi Kevin,
There's a new functionality for that, you need to add a reference to the assembly XSharp.RT.Debugger, and then while debugging you can enter in the Immediate Window:
XSharp.RT.Debugger.Functions.DbgShowMemvars()
This will open a window showing all memory variables. In a future build, this functionality will be added also as a simple menu command.
Btw, there are a few more similar debug windows that can be opened in a similar way:
XSharp.RT.Debugger.Functions.DbgShowWorkAreas() // show info about all open dbfs
XSharp.RT.Debugger.Functions.DbgShowGlobals() // GLOBALs
XSharp.RT.Debugger.Functions.DbgShowSettings() // Show all SET* settings
Edit: Oh I see that the reference does not automatically get linked in just by referencing it, we need to make sure this happens in the future. For now, please add this somewhere in your Start() function, in order to be able to use those Immediate window commands:
Code: Select all
VAR dummy := XSharp.Debugger.GlobalsWindow{}
dummy := NULL
.
How to view the value of a PRIVATE variable in debugger?
Posted: Wed Aug 24, 2022 9:05 pm
by robert
Kevin,
You can also add the expression
Code: Select all
XSharp.RT.Functions.MemVarGet("MYVARNAME")
to the watch window.
If you are not sure if the variable exists you can try
Code: Select all
XSharp.RT.Functions.__MemVarGetSafe("MYVARNAME")
This will return NIL if the variable does not exist.
Robert
How to view the value of a PRIVATE variable in debugger?
Posted: Thu Aug 25, 2022 12:57 pm
by kevclark64
I tried both the popup window and MemVarGet and both ways work well. Thanks Robert and Chris.
How to view the value of a PRIVATE variable in debugger?
Posted: Fri Aug 26, 2022 4:32 pm
by ic2
Hello Chris,
Chris post=23482 userid=313 wrote:
There's a new functionality for that, you need to add a reference to the assembly XSharp.RT.Debugger, and then while debugging you can enter in the Immediate Window:
Btw, there are a few more similar debug windows that can be opened in a similar way:
XSharp.RT.Debugger.Functions.DbgShowWorkAreas() // show info about all open dbfs .
This is very handy!
We used it today to view open workareas. This is one of the rare things were (in this case XSharp.RT.Debugger.Functions.DbgShowWorkAreas()) is even better than in VO because you can actually browse through DBF records!
Would it be difficult to add a GoTo(recordnumber) option within that function? As it is -yet- impossible to do that in the IM window (where you get all kind of C# errors and have to guess what the C# equivalent would be) it could probably be a quick to implement that functionality there?
Dick
How to view the value of a PRIVATE variable in debugger?
Posted: Fri Aug 26, 2022 4:42 pm
by Chris
Hi Dick,
Yeah, I think that should be easy enough. Will look into it, probably we can sneak this in the 2.13.1.0 release next week.
.