|
|
clipka <ano### [at] anonymousorg> wrote:
I always thought that the value of OneVariable would get copied to X, and
Another would get copied to Y, and the macro would operate on X and Y, not
OneVariable and Another. So I would have always tried to output any values from
the macro via
#declare A = macro ThisMacro (A)
But apparently X and Y are just pointers / links / containers for the REAL
variables, and when I perform operations on X and Y, the underlying actual
variables that get passed into the macro get changed.
.... and indeed after running the below, it works just like that.
Good to know! That will help with a lot of debugging.
[X] Learned something new today
#macro SwapXY (X, Y)
// Input/output: X, Y
// On output, the values of X and Y have been interchanged.
#local Z = X; // Z is a placeholder variable
#local X = Y;
#local Y = Z;
#end
#declare A = 1;
#declare B = 2;
#debug concat ( "A = ", str (A, 3, 1), "B = ", str (B, 3, 1), "\n")
SwapXY (A, B)
#debug concat ( "A = ", str (A, 3, 1), "B = ", str (B, 3, 1), "\n")
Post a reply to this message
|
|