I have a global variable ‘v’ which is just a simple JSON formatted string holding some numbered keys and their values.
I would like to take this local variable and make modifications to it using the tc(reg) function inside a formula bit by bit - all easily done.
If I refer to the modified local variable inside an if() function using # notation it works fine, but not inside a for loop.
Perhaps there is something I’m trying to do which is illegal but I haven’t made sense of it yet. Is it a known issue?
The output from my current formula is below together with the formula that generates it.
{1:2,2:4,3:6,4:8,5:10,6:12} (Original)
{1:2,2:5,3:2,4:9,5:10,6:12} (Altered)
2,4,6,8,10,12
,,,,,
yes
$gv(v)$ (Original)
$lv(v, tc(reg, gv(v), "3:(\d{1,2})", "3:2"))
+ lv(v, tc(reg, #v, "4:(\d{1,2})", "4:9") )
+ lv(v, tc(reg, #v, "2:(\d{1,2})", "2:5") )
+ #v$ (Altered)
$fl(1, 6, "i+1", "tc(json, gv(v), i)", ",")$
$fl(1, 6, "i+1", "tc(json, #v, i )", ",")$
$if(tc(json, #v, 2)=5, "yes", "no")$
As you can see, using the normal gv(v) inside the for loop just calls the original as it is likely evaluated first, but using the #v shortcut renders blanks with five comma separators.
Using the #v notation inside an if() function to test for the modified value renders success.