Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

first test in 2.8c. Public variables and debugger 04 Aug 2021 22:52 #19254

  • jpmoschi
  • jpmoschi's Avatar
  • Topic Author


  • Posts: 76
  • 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:

    Please Log in or Create an account to join the conversation.

    Last edit: by jpmoschi. Reason: to add error screen capture

    first test in 2.8c. Public variables and debugger 05 Aug 2021 00:09 #19255

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • 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.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    first test in 2.8c. Public variables and debugger 05 Aug 2021 20:21 #19258

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Hi Juan,

    I´m able to reproduce your mentioned PUBLIC var problem with this code.
    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
    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()
    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

    Please Log in or Create an account to join the conversation.

    first test in 2.8c. Public variables and debugger 05 Aug 2021 20:35 #19259

    • Chris
    • Chris's Avatar


  • Posts: 3856
  • 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!
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    first test in 2.8c. Public variables and debugger 06 Aug 2021 08:25 #19260

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • Hi Chris,

    btw. there´s no problem if a PUBLIC var is declared before the Start()
    PUBLIC pub3
    
    FUNCTION Start() AS VOID 
    
    ...
    
    RETURN

    results in:
    [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

    Please Log in or Create an account to join the conversation.

    first test in 2.8c. Public variables and debugger 09 Aug 2021 16:39 #19296

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • Thanks, everyone's comments guided me to go to the source code on github. Fix the problem by replacing public declaration with:
    // 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?

    Please Log in or Create an account to join the conversation.

    first test in 2.8c. Public variables and debugger 09 Aug 2021 17:50 #19299

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 774
  • 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::
    PUBLIC myvariablewitherror

    results in the generated code:
    XSharp.RT.Functions.__MemVarDecl(e"myvariablewitherror", _priv: false)
    XSharp.RT.Functions.__MemVarPut(e"myvariablewitherror", false)

    regards
    Karl-Heinz

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1