如何使組合框顯示唯一值?各位,
此腳本類似於“JUMP into JMP”一書中的腳本。
該腳本提示用戶選擇“DCM”,基於此選擇“DieNo”列表被填充。
這裡有幾個問題。 “DCM 編號”列表未按升序排列。
其他問題,當我選擇一個 DCM 號碼時,“DieNo”列表被填充。 但這列出了所有值,我只想列出唯一值。
對於這兩列,數據類型都是 char,但是數字數據類型在這裡不起作用。 關於這個問題的任何建議。
/* Open the sample data table */
dt = Open( "$Desktop/JMP scripts/SampleData.jmp" );
/* Create lists of the values found in the DCMNo and Die columns*/
Unique DCM=Associative array(dt:DCMNo);
nitems(unique DCM);
DCM1= unique DCM<<GET keys=""></GET>
我還試圖包括日期選擇組合框。 最好的帖子和簡單的選擇是“日期數據過濾器”。
JMP 是否允許我顯示日期的日曆{我們預訂從出發日期到到達日期的航班時顯示的小日曆}。
乾杯
散
回复:如何使組合框顯示唯一值?關於這個新功能,腳本索引和指南有些薄弱。 腳本指南中的示例可以加強一點。 這是顯示日曆的更好的一個。 當您選擇一個日期並單擊“確定”時,日誌窗口中將打印出來。
Names Default To Here( 1 );
nw = New Window( "Calendar Box Example",
cal = Calendar Box(),
ok_button = button box("OK",
selected_date = format(cal << get date, "ddMonyyyy");
print(selected_date);
nw << close window;
)
);
回复:如何使組合框顯示唯一值?您不需要模態窗口即可使用日曆框。
日曆框就像一個專門的數字編輯框。 它為您處理日期,因此您不必弄亂格式或將秒數轉換為日期或時間。
有關消息協議,請參閱腳本索引或腳本指南。
回复:如何使組合框顯示唯一值?我不知道 JMP 13 中的新日曆框()顯示框。太好了! 你如何使用它? 我必須使對話框成為模態才能讓它返回一些東西。
Names Default To Here( 1 );
New Window( "Calendar Box Example", << modal(),
cal = Calendar Box()
);
selected_date = format(cal << get date, "ddMonyyyy");
print(selected_date);
回复:如何使組合框顯示唯一值?此外,您還可以使用帶有日期格式的數字編輯框 () 或新的日曆框 ()。 它們都運行良好,但向用戶呈現不同的界面。
這是腳本索引中的 Number Edit Box() 方法:
Names Default To Here( 1 );
New Window( "Example",
fontobj = numbox = Number Edit Box( 0 )
);
numbox << Set Format( Format( "m/d/y", 12 ) );
numbox << Set( Date MDY( 10, 2, 1989 ) );
這是 Calendar Box() 解決方案,也取自腳本索引:
Names Default To Here( 1 );
New Window( "Calendar Box Example",
cal = Calendar Box()
);
回复:如何使組合框顯示唯一值?DCM 列表按字母順序排列。 您將 DCM 解釋為一個數字。 JMP 將 DCM 解釋為字符串。
為什麼數值對 DCM 或 Die 不起作用? 該數據類型將解決您的訂購問題。
我清理了一些東西以獲得更短的解決方案。 這裡是:
Names Default to Here( 1 );
/* Open the sample data table */
dt = Open( "$Desktop/SampleData.jmp" );
/* Create lists of the values found in the DCMNo and Die columns*/
DCM = Sort Ascending( Associative Array( dt:DCMNo ) << Get Keys );
Die = Associative Array( dt:DieNo ) << Get Keys;
selRows = dt << Get Rows Where( :DCMNo == DCM[1] );
initial Die Set = Associative Array( Column( dt, "DieNo" )[selRows] ) << Get Keys;
dt << Clear Column Selection();
dt << Clear Row Selection();
/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window( "Choose DCM Die combination",
hb = H List Box(
Panel Box( "Select a DCM Number",
select1 = Combo Box( DCM,
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
selRows = dt << Get Rows Where( :DCMNo == DCM[select1 << Get] );
myDies = Associative Array( Column( dt, "DieNo" )[selRows] ) << Get Keys;
select2 << Set Items( myDies );
)
),
Panel Box( "Select a Die",
select2 = Combo Box( initial Die Set )
)
),
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
Button Box( "OK",
nw << Close Window;
dt << Select where( :DCMNo == DCM[select1 << Get] & :DieNo == myDies[select2 << Get] );
/* Selected rows are subsetted into new table. */
dt << Subset( Output Table Name( "Ryobi Details" ) );
)
);回复:如何使組合框顯示唯一值?為什麼如果我不選擇下拉框中的其他數字並使用默認值,就會出現錯誤;如果我選擇其他數字,它不會給我錯誤。
我的版本是17,mac。
回复:如何使組合框顯示唯一值?@李雙林您可以使用示例腳本創建一個新的討論嗎?
回复:如何使組合框顯示唯一值?這是馬克的腳本和這篇文章中提供的數據,我在運行它時發現按下默認下拉框數字而不更改它們會給我一個錯誤;選擇其他數字就可以了。
/* Open the sample data table */
dt = Open( "$Desktop/SampleData.jmp" );
/* Create lists of the values found in the DCMNo and Die columns*/
DCM = Sort Ascending( Associative Array( dt:DCMNo ) << Get Keys );
Die = Associative Array( dt:DieNo ) << Get Keys;
selRows = dt << Get Rows Where( :DCMNo == DCM[1] );
initial Die Set = Associative Array( Column( dt, "DieNo" )[selRows] ) << Get Keys;
dt << Clear Column Selection();
dt << Clear Row Selection();
/* Use New Window to create a non-modal dialog to display DCMNo and Die for user to choose. */
nw = New Window( "Choose DCM Die combination",
hb = H List Box(
Panel Box( "Select a DCM Number",
select1 = Combo Box( DCM,
/* Each of the following tasks are executed when the user makes a DCMNo choice.*/
selRows = dt << Get Rows Where( :DCMNo == DCM[select1 << Get] );
myDies = Associative Array( Column( dt, "DieNo" )[selRows] ) << Get Keys;
select2 << Set Items( myDies );
)
),
Panel Box( "Select a Die",
select2 = Combo Box( initial Die Set )
)
),
/* If user clicks OK, values displayed for DCMNo and Die will be selected in table. */
Button Box( "OK",
nw << Close Window;
dt << Select where( :DCMNo == DCM[select1 << Get] & :DieNo == myDies[select2 << Get] );
/* Selected rows are subsetted into new table. */
dt << Subset( Output Table Name( "Ryobi Details" ) );
)
);回复:如何使組合框顯示唯一值?非常快速地檢查腳本,問題是組合框中的腳本在初始創建時不會被觸發。 最簡單的修復是添加類似的內容
select1 << Set(2, Run Script(0));
select1 << Set(1, Run Script(1));
到腳本結束。 這將更改組合框中的值,然後觸發腳本一次。
其他相當簡單的選項是將組合框中的腳本更改為表達式,然後在創建窗口後運行它。
查看更多...
或者在腳本末尾使用 << Get Function 和 Eval
Eval(select1 << get function);
回复:如何使組合框顯示唯一值?謝謝 !