[VFP] Issue in Text...EndText
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
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 ?
In my limited experience, I think macro compilers can and should be able to access private properties.
Ok, we'll allow this for at least the FoxPro dialect
The macro compiler now allows access to private and protected properties in the FoxPro dialect. See 35a5c13603056a5e86be12a9596016bb00b894d5
The private/protected variables can now be accessed fine, but the macro compiler does not recognize the dot opeartor for accessing them.