如何使脚本独立于语言设置?你好!
我有一个脚本,如果 JMP 15 设置为英语,它会给出正确的结果,但它会在另一种语言设置中给出错误。
我在脚本中使用的是
:Name( "Mean(Something)" )
这就是问题的原因,因为在德语语言设置中,我实际想要引用的列是“Mittelwert(Something)”。 “Std Dev”等在其他语言设置中也有不同的命名。 我想引用的那些列是表格汇总列的结果。
在引用这样的摘要列时,如何使脚本独立于语言设置? 有好的做法吗?
其他脚本回复:如何使脚本独立于语言设置?谢谢! 是的,你是对的,它离漂亮还很远。 但对我来说已经足够了。 我将在一些 if 语句中使用语言代码。
我仍然很好奇您会发现有关摘要示例的内容。回复:如何使脚本独立于语言设置?Robbb,我在 Mac 上运行它,所以我必须重新启动 JMP 才能更改语言。
我能够使用 Tabulate 重现您的问题。 它没有正确生成列名别名。 我会将此报告为错误。 同时,您可以像这样解决它:
mean height = Match(System Service(Get Language Code),
"de", "Mittelwert(height)",<BR /> // Add more language cases here as needed
"Mean(height)"
);
DT = Open( "$SAMPLE_DATA/Big Class.jmp" );
Table1 = DT << Tabulate(
Add Table(
Column Table( Analysis Columns( :height ), Statistics( Mean ) ), // Here another language than English is not a problem.
Row Table( Grouping Columns( :age ) )
)
);
DT2 = Table1 << Make Into Data Table;
Eval(Parse(Substitute("\[
DT2 << New Column( "Stupid Formula",
Formula(
:Name("^MEAN HEIGHT") + 1 // Here it is a problem!
)
)]\",
"^MEAN HEIGHT", mean height)));
它并不漂亮,但它会让你度过这个难关。
至于摘要示例,我将不得不研究为什么它对我有用而不对你有用。 也许它只是最近才修复。
回复:如何使脚本独立于语言设置?战略取决于几件事,我还不知道。
因此,如果表格是由您的脚本创建的,您可能已经知道正确的名称,并且可以采取相应的行动。
您还可以测试正确的语言并警告用户,或在以下脚本中使用此信息。
如果启动脚本时该表存在,并且它始终具有相同的结构,则可以通过列位置引用它,即第三列的 column(dt, 3)。
等等。
回复:如何使脚本独立于语言设置?PS:你的例子对我不起作用。 Column( dt_summ, "平均值(身高)" )[1];产生“找不到列”。 更改语言后是否重新启动了 JMP?
我的脚本表脚本如下所示。 如您所见,均值列没有别名。 但是对于 N 行,有。 这是为什么?
New Table( "Big Class Nach (age)",
Add Rows( 6 ),
New Script(
["de" => "Quelle", "en" => "Source"],
Data Table( "Big Class" ) << Summary(
Group( :age ),
Mean( :height ),
Freq( "Keine" ),
Weight( "Keine" )
)
),
New Column(
["en" => "age", "ja" => "年齢", "x-id" => "S_age_Col", "zh-CN" => "年龄"],
Numeric,
"Ordinal",
Format( "Fixed Dec", 5, 0 ),
Set Property( "Notes", "Explore data adventurously" ),
Lock( 1 )
),
New Column( ["de" => "Anzahl Zeilen", "en" => "N Rows"],
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 0 ),
Lock( 1 )
),
New Column( "Mittelwert(height)",
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 1 ),
Set Selected,
Lock( 1 )
)
)
回复:如何使脚本独立于语言设置?当然! 感谢您的回复。 我也这么想。 我记得当时我想“哇哦,JMP 甚至可以自动分析和翻译汇总列名称。”
但就我而言,它在某种程度上不起作用。 我打破了它。 请试试这个:
DT = Open( "$SAMPLE_DATA/Big Class.jmp" );
Table1 = DT << Tabulate(
Add Table(
Column Table( Analysis Columns( :height ), Statistics( <STRONG>Mean</STRONG> ) ), // Here another language than English is not a problem.
Row Table( Grouping Columns( :age ) )
)
);
DT2 = Table1 << Make Into Data Table;
DT2 << New Column( "Stupid Formula",
Formula(
<STRONG>:Name( "Mean(height)" )</STRONG> + 1 // Here it is a problem!
)
);
英语
运行脚本
“愚蠢的公式”列被填满。
改为德语
重新启动 JMP 15.2.1
运行脚本
愚蠢的公式”列未填写。
回复:如何使脚本独立于语言设置?伊恩,谢谢你的呐喊! 但是我觉得Robbb的问题更多的是关于如何引用名称本地化的数据表中的生成列。
Robbb,这个脚本:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt_summ = dt << Summary(
Group( :age ),
Mean( :height ),
Freq( "None" ),
Weight( "None" )
);
Column( dt_summ, "Mean(height)" )[1];
无论我使用英语还是德语的 JMP,它都适用。 在这两种情况下,它都会将 58.125 打印到日志中。 它之所以有效,是因为“Mittelwert(height)”列是使用别名“Mean(height)”创建的。 如果您复制表脚本并将其粘贴到新的脚本窗口中,您可以看到这一点:
New Column( ["de" => "Mittelwert(height)", "en" => "Mean(height)"],
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 1 ),<BR />// etc.
按名称查找列时,JMP 会检查当前区域设置名称和英文别名,以寻找匹配项。
你能告诉我们更多关于你失败的细节吗?
回复:如何使脚本独立于语言设置?关于“良好做法”,我当然会看看发现论文从@hecht_jmp .