xsharp.eu • TEXT TO varName NOSHOW TEXTMERGE
Page 1 of 1

TEXT TO varName NOSHOW TEXTMERGE

Posted: Wed Jul 10, 2024 7:45 pm
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.

Re: TEXT TO varName NOSHOW TEXTMERGE

Posted: Wed Jul 10, 2024 9:08 pm
by robert
This must be a bug. Can you post an issue for this?

Robert

Re: TEXT TO varName NOSHOW TEXTMERGE

Posted: Thu Jul 11, 2024 7:15 am
by Irwin
Thanks @robert,

I've created the issue.

Re: TEXT TO varName NOSHOW TEXTMERGE

Posted: Thu Jul 11, 2024 3:34 pm
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