將列名作為參數傳遞給函數 - 是否需要與 : 連接?下面是一個函數,我試圖傳遞一個列名來繪製分佈,但它不起作用。 我想知道正確的語法是什麼?
Names Default To Here (1);
getDistChart = Function({ColName}, {dC},
dC = Distribution( Continuous Distribution( Column( :ColName) ) );
return(dC);
);
//gt = getDistChart ("MyCol"); to test the function
我已經打開了以 MyCol 作為列名的數據表。 我想知道是否需要連接
:
與列名
ColName
如果是這樣(與 || || 的正常連接似乎不起作用)?
數據表腳本回复:將列名作為參數傳遞給函數 - 需要與 : 連接嗎?謝謝@Mark_Bailey這行得通。
回复:將列名作為參數傳遞給函數 - 需要與 : 連接嗎?是的,它非常適合我使用 JMP Pro 16.1.0。 我沒有安裝任何早期版本的 JMP 進行測試。 您的版本大約有 5 年的歷史。 JSL 不斷發展,因此我的語法可能不適用於早期版本。
您可以聯繫 JMP 技術支持( support@jmp.com ) 求助。
你也可以嘗試使用表達式來完成你想要的。 它們適用於任何版本的 JMP,自版本 4 起。 看看這個版本是否有效:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function( {ColName, _LSL, _USL}, {distChart},
Eval(
Substitute(
Expr(
distChart = New Window( "" || ColName || " distribution",
Distribution(
Stack( 1 ),
Continuous Distribution(
Column( As Column( ColName ) ),
Horizontal Layout( 1 ),
Vertical( 0 ),
Capability Analysis( LSL( _LSL ), USL( _USL ) )
),
SendToReport(
Dispatch(
{ ccc },
"Distrib Histogram",
FrameBox,
{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
)
)
)
);
),
Expr( ccc ), colName
)
);
Return( distChart );
);
getDistChart( "weight", 55, 185 );回复:將列名作為參數傳遞給函數 - 需要與 : 連接嗎?@Mark_Bailey謝謝。 運行您的腳本會在日誌中為我提供以下信息
Cannot find item "ColName" in outline context {ColName}
對你起作用嗎?
(我在 JMP 13 上)
回复:將列名作為參數傳遞給函數 - 需要與 : 連接嗎?Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function( {ColName, _LSL, _USL},
{distChart},
New Window( "" || ColName || " distribution",
Distribution(
Stack( 1 ),
Continuous Distribution(
Column( As Column( ColName ) ),
Horizontal Layout( 1 ),
Vertical( 0 ),
Capability Analysis( LSL( _LSL ), USL( _USL ) )
),
SendToReport(
Dispatch(
{colName},
"Distrib Histogram",
FrameBox,
{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
)
)
)
);
Return( distChart );
);
getDistChart( "weight", 55, 185 );回复:將列名作為參數傳遞給函數 - 需要與 : 連接嗎?@Mark_Bailey謝謝它的工作原理。 但是,我在前進到下一步時遇到了困難。 我想將列名傳遞到腳本中的多個位置。 下面以大類為例。 我可以將 ColName 傳遞給新窗口,但不能傳遞給 Dispatch
Names Default To Here (1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function({ColName, _LSL, _USL}, {distChart},
New Window(""||ColName||" distribution",
Distribution(
Stack( 1 ),
Continuous Distribution(
Column(As Column (ColName) ),
Horizontal Layout( 1 ),
Vertical( 0 ),
Capability Analysis( LSL(_LSL ), USL(_USL) )
),
SendToReport(
Dispatch(
{"weight"},
"Distrib Histogram",
FrameBox,
{DispatchSeg( LabelSeg( 1 ), {Font( "Segoe UI", 7, "Plain" )} ),
DispatchSeg( LabelSeg( 2 ), {Font( "Segoe UI", 7, "Plain" )} )}
)
)
);
);
return(distChart);
);
getDistChart ("weight", 55, 185);
例如這個
Dispatch( {ColName},...
或這個從這裡
Dispatch( {Expr(ColName)},...
不起作用。 將字符串作為 Dispatch 的參數傳遞的正確語法是什麼?
回复:將列名作為參數傳遞給函數 - 需要與 : 連接嗎?Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
getDistChart = Function( {ColName}, {dC},
dC = Distribution( Continuous Distribution( Column( As Column( colName ) ) ) );
Return( dC );
);
gt = getDistChart ("weight");