How to view the value of a PRIVATE variable in debugger?

This forum is meant for questions about the Visual FoxPro Language support in X#.

Post Reply
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

How to view the value of a PRIVATE variable in debugger?

Post 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.
User avatar
Chris
Posts: 4855
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to view the value of a PRIVATE variable in debugger?

Post 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
.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
robert
Posts: 4483
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

How to view the value of a PRIVATE variable in debugger?

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

How to view the value of a PRIVATE variable in debugger?

Post by kevclark64 »

I tried both the popup window and MemVarGet and both ways work well. Thanks Robert and Chris.
ic2
Posts: 1856
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

How to view the value of a PRIVATE variable in debugger?

Post 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
User avatar
Chris
Posts: 4855
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

How to view the value of a PRIVATE variable in debugger?

Post 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.

.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply