您好,我正在编写一些 JSL 代码来处理一个源文件,并希望能够重用/调整该源文件。为此,我创建了几个非常简单的变量,打算偶尔更改。
以下是一段 JSL 代码,用于创建变量并在列公式中使用它们。这些并非原始名称。为了简洁起见,我做了一些修改:
JMP v18.2.0
dt = current data table();
VariableA = 42; // A value I intend to change occasionally depending on the details of the source data
VariableB = 1; // Another value I'll change depending on the source data.
dt << New Column( "A_New_Formula_Coumn",
numeric,
ordinal,
Formula( :An_Existing_Data_Column - VariableA * VariableB )
);
dt << New Column( "A_Simpler_New_Formula_Coumn",
numeric,
ordinal,
Formula( :An_Existing_Data_Column - 42 )
); I've run this in an external script and from a script in the table. Both seem to have no trouble when the script is first run. The problem is that "VariableA" and "VariableB" are used in the column formula, almost as if they are local variables. But they aren't defined anywhere. So when I close JMP down completely and reopen it - only then do I get a warning that there is something wrong with the formula:
我实际上只想让脚本将此公式应用于新列,即计算脚本变量部分的值。但我不知道该怎么做。
我不想使用表变量。
感谢阅读!
您必须对它们进行评估,使用 Eval Insert、Eval Expr、Parse 和 Substitute 将一个表达式插入另一个表达式
Names Default To Here(1);
dt = open("$SAMPLE_DATA/Big Class.jmp");
myvar = 100;
Eval(EvalExpr(
dt << new column("A", Numeric, Continuous, Formula(
:height * Expr(myvar)
));
));