XSharpPublic icon indicating copy to clipboard operation
XSharpPublic copied to clipboard

[VFP] Issue in Text...EndText

Open vfp9 opened this issue 1 year ago • 5 comments

Describe the bug The execution does not give the correct result if the value of the control is directly referenced in it.

To Reproduce Steps to reproduce the behavior:

First create a form and add a Textbox to the form, assuming its Name property is Textbox1. If we add a method to the form, the code for the method has code similar to the following:

        text to myTest NoShow TextMerge
            temp = <<This.Textbox1.Text>>
        endtext

The value of the variable myTest is not what we expected.

In version 2.21.0.5, if you need to get the correct result, you can only use the following code:

        a1 = This.Textbox1.Text

        text to myTest NoShow TextMerge
            temp = <<a1>>
        endtext

vfp9 avatar Dec 26 '24 05:12 vfp9

There are 2 reasons why this fails at this moment:

  • By default the TextBox1 field on the form is private. Therefore it is not visible by the X# macro compiler which is responsible for evaluating the expression. For local fields such as THIS and A1 we have applied a trick, so they become visible to the macro compiler as pseudo privates. But private fields in the objects stored in these locals are still invisible. We can change the macro compiler (for the FoxPro dialect) to "cheat", like the FoxPro runtime does, and give it access to local fields as well.
  • The macro compiler does not recognize the "." operator in the expression. We should fix that in the macro compiler when running in the FoxPro and Core dialect.

If you change the visibility of the TextBox1 field to PUBLIC and change the expression to This:Textbox1:Text then it works at this moment.

What do you think: should we adjust the macro compiler and allow it to access private properties ?

RobertvanderHulst avatar Feb 28 '25 09:02 RobertvanderHulst

In my limited experience, I think macro compilers can and should be able to access private properties.

vfp9 avatar Mar 01 '25 14:03 vfp9

Ok, we'll allow this for at least the FoxPro dialect

RobertvanderHulst avatar Mar 01 '25 16:03 RobertvanderHulst

The macro compiler now allows access to private and protected properties in the FoxPro dialect. See 35a5c13603056a5e86be12a9596016bb00b894d5

RobertvanderHulst avatar Mar 06 '25 16:03 RobertvanderHulst

The private/protected variables can now be accessed fine, but the macro compiler does not recognize the dot opeartor for accessing them.

cpyrgas avatar Mar 28 '25 10:03 cpyrgas