こんにちは。ソースファイルを処理するための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)
));
));