如何使组合框显示唯一值?各位,
此脚本类似于“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。
回复:如何使组合框显示唯一值?@lishualin您可以使用示例脚本创建一个新的讨论吗?
回复:如何使组合框显示唯一值?这是马克的脚本和这篇文章中提供的数据,我在运行它时发现按下默认下拉框数字而不更改它们会给我一个错误;选择其他数字就可以了。
/* 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);
回复:如何使组合框显示唯一值?谢谢 !