Question Tomer Marinov · Aug 28, 2018

SYNTAX Error With ObjectScript Indirection Usage

Hi,

Does anyone know why the SYNTAX error appears?

Thanks,

Tomer.

Comments

Eduard Lebedyuk · Aug 28, 2018

OCR:

S S="*"
S A="123*456"
S B="$P(A,S,2)"
W @B
S C=@B
0
Tomer Marinov  Aug 28, 2018 to Eduard Lebedyuk

I Forgot to show you that line:
S S="*"

Still, it doesn't work.

0
Robert Cemper  Aug 28, 2018 to Tomer Marinov

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.

But

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!

0
John Murray · Aug 28, 2018

The rules about indirection in ObjectScript can be a bit tricky to comprehend. Your last line is syntactically invalid.

Use this instead:

S @("C="_B)
0
Bryan Lucas · Aug 28, 2018

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.

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