如何使腳本獨立於語言設置?你好!
我有一個腳本,如果 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 .