您好,我正在編寫一些 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)
));
));