TEXT TO varName NOSHOW TEXTMERGE

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

Post Reply
User avatar
Irwin
Posts: 29
Joined: Wed Mar 23, 2022 10:24 am
Location: España

TEXT TO varName NOSHOW TEXTMERGE

Post by Irwin »

Hi,

Why TEXT/ENDTEXT with TEXTMERGE doesn't evaluate PARAMETERS variables?

Eg:

Code: Select all

METHOD SomeMethod(tcFileName1 AS STRING, tcFileName2 AS STRING) AS VOID
   LOCAL lcOutput := "" AS STRING
   TEXT TO lcOutput NOSHOW TEXTMERGE
       COPY FILE "<<tcFileName1>>" TO "<<tcFileName2>>"
   ENDTEXT
END METHOD
lcOutput then get this value:

Code: Select all

COPY FILE "** Error in expression (tcFileName1) **" TO "** Error in expression (tcFileName2) **"
I have to create local variables to hold the parameters values in order to TEXTMERGE being able to evaluate them.

thanks.
User avatar
robert
Posts: 4478
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: TEXT TO varName NOSHOW TEXTMERGE

Post by robert »

This must be a bug. Can you post an issue for this?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Irwin
Posts: 29
Joined: Wed Mar 23, 2022 10:24 am
Location: España

Re: TEXT TO varName NOSHOW TEXTMERGE

Post by Irwin »

Thanks @robert,

I've created the issue.
User avatar
robert
Posts: 4478
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: TEXT TO varName NOSHOW TEXTMERGE

Post by robert »

Explanation:

The problem here is that FoxPro does not really have local variables. In every other development language a local variable is only visible in the location where it is declared (including parameters).
FoxPro however gives the runtime code for TextMerge access to locals and therefore violates this visibility rule.
We have added code to our compiler and runtime to emulate this (to make locals visible to other code): when a function or method is marked with a special attribute then we publish the locals as a kind of "pseudo private" variable and after the function call we remove them again.

You can find the code for this attribute here:
https://www.xsharp.eu/runtimehelp/html/ ... ribute.htm

The compiler detects all locals that were defined for the function call and makes these available.
It looks like we have forgotten to include parameters in this list.


Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply