Hi Francesco,
When we execute the scripts in Script Window or Command Window, variable with $ will be resolved to its actual value directly before it is passed into Before Script options.
https://www.originlab.com/doc/Quick-Help/Avoid-Substituted
To fix this issue, we could change the code like:
%A = $;
csetvalue col:=col(E)
formula:="Sum"
script:="
dataset Sum;
for (int j=1; j<=3; j++) //Rows
{
for (int i=1; i<=4; i++) // Columns
Sum[j]+=Col(%A (i))[ %A (j)];
}
"
recalculate:=1;
In fact, we could easily use “A+B+C+D” to sum the values for each row:
csetvalue col:=col(E) formula:="A+B+C+D" recalculate:=1;
Regards,
Yuki
OriginLab