用于选择并保存所选列的列名称的列对话框大家好,
我想创建一个对话框,显示数据可用的所有列名称。 它将允许选择所需的列并将列名称保存到变量中。 因此,我使用变量中存储的名称访问 jsl 中的该列。
例如:我有下表。
如果我运行脚本,它将打开对话框(如图所示),选择列后我想使用存储该 ccolumn 的变量名称来访问它们。 (例如列(dt,分数))
回复:用于选择并保存所选列的列名称的列对话框看看这个稍微改变的代码:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Modal dialog: Note that 'ColumnDialog()' is a variant of the deprecated 'Dialog()', so you
// should probably look at 'NewWindow()' with the '<< Modal' option
dlg = Column Dialog(
name = ColList( "Name", Min Col(1), Max Col(1) ),
subject = ColList( "Subject", Min Col(1), MaxCol(1) )
);
// Stop if the user did not press 'OK'
If( dlg["Button"] != 1, Beep(); Throw());
// Note that 'name' and 'subject' will both be lists - Look at the tooltip when you point to the variable
name = dlg[ "name" ];
subject = dlg["subject"];
// If you require column names . . .
name = Column(dt, name[1]) << getName;
subject = Column(dt, subject[1]) << getName;
Print(name, subject);回复:用于选择并保存所选列的列名称的列对话框你好@ian_jmp
我写了下面的代码。
dlg = Column Dialog(
name = ColList( "Name", Min Col(1), Max Col( 1 ) ),
subject = ColList( "Subject", Min Col(1) ),
);
If( dlg["Button"] == 1,
name = dlg[ "name" ];
subject = dlg["subject"]
);所以,运行后,当我打印姓名,它打印“ :A ”。 它指的是整个列,但我只想获取列名称。 我该如何解决这个问题。 有时,如果我正在处理多个数据表,它会显示错误无法访问列“A”,因为行号 (0) 无效。
请帮助我如何解决这个问题。
谢谢
回复:用于选择并保存所选列的列名称的列对话框首先,请使用“帮助 > 脚本索引”并搜索“Col List Box”。 有三个例子。