xsharp.eu • first test in 2.8c. Public variables and debugger
Page 1 of 1

first test in 2.8c. Public variables and debugger

Posted: Wed Aug 04, 2021 8:52 pm
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

first test in 2.8c. Public variables and debugger

Posted: Wed Aug 04, 2021 10:09 pm
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.

first test in 2.8c. Public variables and debugger

Posted: Thu Aug 05, 2021 6:21 pm
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

first test in 2.8c. Public variables and debugger

Posted: Thu Aug 05, 2021 6:35 pm
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!

first test in 2.8c. Public variables and debugger

Posted: Fri Aug 06, 2021 6:25 am
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

first test in 2.8c. Public variables and debugger

Posted: Mon Aug 09, 2021 2:39 pm
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?

first test in 2.8c. Public variables and debugger

Posted: Mon Aug 09, 2021 3:50 pm
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