first test in 2.8c. Public variables and debugger

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

Post Reply
jpmoschi
Posts: 77
Joined: Thu May 21, 2020 3:45 pm

first test in 2.8c. Public variables and debugger

Post by jpmoschi »

Good affternoon, for me

I began to test the xsharp 2.8c version. I noted a problem respect the previous version, because some public declared variables produce a runtime
  • runtime error: Variable does not exist (see the attached image)
  • When i try to separate the error in a new WinForm project to expose you, it produce the compilation error: Error XS0103 The name 'publicMemoryVariable' does not exist in the current context
That shoots me 2 questions:
1st. In FoxPro, the public variables are visible from all the threads and in the new version may be not?
2nd. I found in the documentation a namespace XSharp.Debug but i doesn't know how to use this to help me to do better diagnostics. Could you help me?
Best regards
Juan
Attachments
screenshot.PNG
screenshot.PNG (19.72 KiB) Viewed 513 times
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

first test in 2.8c. Public variables and debugger

Post by Chris »

Hi Juan,

1. In order to allow using public/private variables, you need to use the FoxPro (or Visual Objects etc) dialect in your project, and also enable the project options "Enable Memvar support" and "Enable Undeclared Variables support" (both in the Language tab page).

2. I think you are referring to XSharp.Debugging? This contains some forms found in Xsharp.RT.Debugger.dll for displaying settings, dbfs, memvars etc at runtime, but are not properly working yet, support for them should be completed in one of the next builds.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

first test in 2.8c. Public variables and debugger

Post by Karl-Heinz »

Hi Juan,

I´m able to reproduce your mentioned PUBLIC var problem with this code.

Code: Select all

FUNCTION Start( ) AS VOID 
PUBLIC pub1 

	pub1 = "1"
	
	DO Test
	
	? "pub1" , pub1  && "11" 
	

	&& 1. compiler warning not declared ? 
	&& 2. throws an VAR does not exist runtime error	
	? "pub2" , pub2                   
	
RETURN    

PROCEDURE Test
PUBLIC pub2 

	pub1 = "11"    && compiler warning not declared ?
	pub2 = "22" 	
	
RETURN
Looking at the generated code shows that the PUBLIC Pub2 is created as a PRIVATE

Code: Select all

XSharp.RT.Functions.__MemVarDecl(e"pub2", _priv: true)


When i use this Test proc where i "manually" create the pub2 as a PUBLIC, pub2 becomes as expected visible in the Start()

Code: Select all

PROCEDURE Test
// PUBLIC pub2 
 
	//  IF a PRIVATE or PUBLIC is created depends on the second  param ( true or false )

	XSharp.RT.Functions.__MemVarDecl(e"pub2", FALSE )  

	pub1 = "11"    && compiler warning not declared ?
	pub2 = "22" 	
	
RETURN


@Chris

The same happens with the PUBLIC pub1 in the Start(), which is also created as a PRIVATE.

XSharp.RT.Functions.__MemVarDecl(e"pub1", _priv: TRUE)

Is this problem already known ?

regards
Karl-Heinz
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

first test in 2.8c. Public variables and debugger

Post by Chris »

Hi Karl-Heinz,

No, it's not known and apparently this problem happens in the FoxPro dialect only, in VO dialect it works as expected. Thanks, will get this logged for Robert to look into it!
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

first test in 2.8c. Public variables and debugger

Post by Karl-Heinz »

Hi Chris,

btw. there´s no problem if a PUBLIC var is declared before the Start()

Code: Select all

PUBLIC pub3

FUNCTION Start() AS VOID 

...

RETURN
results in:

Code: Select all

[CompilerGenerated];
internal static method $Init3() as void
	XSharp.RT.Functions.__MemVarDecl(e"pub3", _priv: false)
	XSharp.RT.Functions.__MemVarPut(e"pub3", false)
regards
Karl-Heinz
jpmoschi
Posts: 77
Joined: Thu May 21, 2020 3:45 pm

first test in 2.8c. Public variables and debugger

Post by jpmoschi »

Thanks, everyone's comments guided me to go to the source code on github. Fix the problem by replacing public declaration with:

Code: Select all

// public myvariablewitherror 
XSharp.MemVar.Add("myvariablewitherror" , false)
Is it correct to say that replacing all foxpro declarations "public" and "private" in the same way is correct and cleaner?
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

first test in 2.8c. Public variables and debugger

Post by Karl-Heinz »

Juan,

what you´re trying to do is no good idea because it´s a compiler problem. When the issue is fixed a declaration like::

Code: Select all

PUBLIC myvariablewitherror
results in the generated code:

Code: Select all

XSharp.RT.Functions.__MemVarDecl(e"myvariablewitherror", _priv: false)
XSharp.RT.Functions.__MemVarPut(e"myvariablewitherror", false)
regards
Karl-Heinz
Post Reply