Clovertech
› Clovertech Forums › Cloverleaf › Using a variable to reference a field component
Hi folks,
I have an Xlate proc trying to output to a field component.
Tried using this but it seems to treat “[$ctr]” as blank and writes to the field instead.
xpmstore $xlateId {~0(0).PV1(0).#52(0).[$ctr]} d -c “$line”
What am I missing?
TIA!
That is because your variable is inside braces and is not evaluated. Use quotation marks instead. If you really need braces use the subst command
Hi Charlie,
Trying to wrap my mind around this…..
How would we output to a component without the square brackets?
A couple of different ways
enclose in double quotes and escape the brackets with backslashes
xpmstore $xlateId “~0(0).PV1(0).#52(0).\[$ctr\]” d -c “$line”
or you could use the substitute (subst) command.
set xlateid [subst -nocommands {~0(0).PV1(0).#52(0).[$ctr]}] d -c “$line”
The first option would be better for documentation. The second may confuse others nor familiar with the substitute command