Pass a Script Variable into a New ScriptHi,
Basically I am trying to use a for loop to imbed multiple scripts into a data table:
For( SV = 1, SV <= N Items( CL ), SV++,
DT2 << New Script(
Char(SV),
For( x = 7, x <= N Items( ColLst ), x++,
:Column(Char(ColLst[x])) << Hide (1);
);
For( w = 1, w <= N Items( Lst ), w++,
:Column(Char(CL[SV][w])) << Hide (0);
);
);
);The problem is when one of these scripts run it doesn't know what SV is. I need a way of capturing SV from the main script and setting it into the New Script. For example if I replace SV with 1 all the imbedded scripts will work as if SV == 1, so I need the For Loop to "set" SV to the correct value for that script.
Hopefully this makes some kind of sense.
Re: Pass a Script Variable into a New ScriptIn general you can use this method to pass variable into a script:
Eval (eval expr(
dt << New script (
"name",
Bivariate(
Y(expr(col_var)),
X(expr(col_list_var))
)
)
));
Re: Pass a Script Variable into a New ScriptTry this:
For( SV = 1, SV <= N Items( CL ), SV++,
Eval(Parse(Eval Insert("DT2 << New Script(
Char(SV),
For( x = 7, x <= N Items( ColLst ), x++,
:Column(Char(ColLst[x])) << Hide (1);
);
For( w = 1, w <= N Items( Lst ), w++,
:Column(Char(CL[^SV^][w])) << Hide (0);
);
);"
)));
);
Re: Pass a Script Variable into a New ScriptI tried:
For( SV = 1, SV <= N Items( CL ), SV++,
DT2 << New Script(
Char(SV),
For( x = 6, x <= N Items( ColLst ), x++,
:Column(Char(ColLst[x])) << Hide (1);
);
For( w = 1, w <= N Items(
Eval(
Eval Expr(
Expr(
CL[
Eval(
Eval Expr(
Expr(SV)
)
)
]
)
)
)
), w++,
:Column(
Char(
Eval(
Eval Expr(
CL[
Eval(
Eval Expr(
Expr(SV)
)
)
][w]
)
)
)
) << Hide (0);
);
);
);The error is:
Subscript Range in access or evaluation of 'Subscript' , CL[/*###*/Eval( Eval Expr( Expr( SV ) ) )]
Re: Pass a Script Variable into a New ScriptTry using Eval( Eval Expr(...Expr(SV)...)) to force pre-evaluation of SV (and CL if necessary).