Discussion (7)1
Log in or sign up to continue

you mix up 2 variants of indirection

W @B
S @("C="_B)

These both are ARGUMENT indirections, where the arguments of WRITE or SET are replaced.


S C=@B

is a NAME indirection where the name of a variable or global is expected.
$P(A,S,2) is definitely no a variable or global name.

Docs on Indirection is quite verbose and shows the limits. 

Most important: this is a runtime feature and not a compile-time feature!

Name indirection can substitute only a name value. The second SET command in the following example returns an error message because of the context. When evaluating the expression to the right of the equal sign, Caché interprets @var1 as an indirect reference to a variable name, not a numeric value.

SET var1 = "5"  SET x = @var1*6
You can recast the example to execute correctly as follows:
SET var1 = "var2",var2 = 5  SET x = @var1*6