如何使脚本独立于语言设置?你好!
如果JMP 15设置为英语,并且在另一种语言设置中出现错误,我有一个脚本可以提供正确的结果。
我在脚本中使用的是
:Name( "Mean(Something)" )
这就是问题的原因,因为在例如德语中,我实际要引用的列是“ Mittelwert(Something)”。 “ Std Dev”等也是如此,在其他语言设置中它们的名称也不同。 我想参考的那些列是表格摘要列的结果。
在引用这样的摘要列时,如何使skript独立于语言设置? 有没有好的做法?
其他脚本编写回复:如何使脚本独立于语言设置?关于“良好实践”,我当然会看看探索论文从@hecht_jmp 。
回复:如何使脚本独立于语言设置?伊恩,感谢您的大喊! 但我认为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。 之所以有效,是因为使用别名名称“ Mean(height)”创建了“ Mittelwert(height)”列。 如果复制表脚本并将其粘贴到新的脚本窗口中,则可以看到以下内容:
New Column( ["de" => "Mittelwert(height)", "en" => "Mean(height)"],
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 1 ),<BR />// etc.
通过名称查找列时,JMP会同时检查当前的语言环境名称和英语别名,以查找匹配项。
您能给我们更多有关您失败的细节吗?
回复:如何使脚本独立于语言设置?当然! 感谢您的回复。 那正是我所想。 我记得当我以为“哦,哇,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
运行脚本
“愚蠢的公式”列未填写。
回复:如何使脚本独立于语言设置?PS:您的示例对我不起作用。 列(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 )
)
)
回复:如何使脚本独立于语言设置?策略取决于几件事,我还不知道。
因此,如果该表格是由您的脚本创建的,则您可能已经知道正确的名称,并且可以采取相应的措施。
您还可以测试正确的语言并警告用户,或在以下脚本中使用此信息。
如果启动脚本时该表存在,并且该表始终具有相同的结构,则可以按列位置(即第三列的column(dt,3))进行引用。
等等。
回复:如何使脚本独立于语言设置?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)));
它虽然不漂亮,但会让您度过难关。
至于“摘要”示例,我将不得不研究为什么它对我有用而不对您有用。 也许是最近才修复的。
回复:如何使脚本独立于语言设置?谢谢! 是的,你是对的,它离美丽还很远。 但这对我来说就足够了。 我将在某些if语句中使用语言代码。
我仍然很好奇您将从摘要示例中找到什么。