How to make a script independent from language settings?Hello!
I have a script that gives the correct result if JMP 15 is set to English and it gives errors in another language setting.
What I am using in the script is
:Name( "Mean(Something)" )
and that is the cause of the problem, because in e.g. German language setting the column which I actually want to reference is "Mittelwert(Something)". Same goes for "Std Dev" etc. which are also named differently in other language settings. Those columns I would like to reference are results of summary columns of a tabular.
How to make a skript independent from language settings when it comes to referencing summary columns like this? Is there a good practice?
OtherScriptingRe: How to make a script independent from language settings?Thanks! Yes, you are right, it's far away from pretty. But it's sufficient in my case. I will use the language code in some if statements.
I'm still curious what you will find out about the summary example.Re: How to make a script independent from language settings?Robbb, I am running this on a Mac so I must restart JMP to change languages.
I was able to reproduce your issue with Tabulate. It is not generating column name aliases correctly. I will report this as a bug. In the meantime, you can work around it like so:
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)));
It's not pretty, but it will get you over this hump.
As for the Summary example, I will have to look into why it works for me and not you. Perhaps it was only recently fixed.
Re: How to make a script independent from language settings?Strategy depends on several things, I do not know yet.
So if the tabular is created by your script, you already may know the right name, and you can act accordingly.
You also can test for the right language and warn the user, or use this information in the following script.
If the table is existent when starting your script, and if it has always the same structure, you may reference it by the column position, i.e. column(dt, 3) for the third column.
And so on.
Re: How to make a script independent from language settings?PS: Your example does not work for me. Column( dt_summ, "Mean(height)" )[1]; yields "column cannot be found". Did you restart JMP after changing the language?
My table script of your script looks like below. As you see, there is not an alias for the mean column. But for N Rows there is. Why is that?
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 )
)
)
Re: How to make a script independent from language settings?Sure! Thanks for your reply. That's what I thought. I remember when I thought "Oh wow, JMP even analyses and translates summary column names automatically."
But in my case it somehow does not work. I broke it down. Please try this:
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!
)
);
English
Run Script
"Stupid Formula" column is filled.
Changed to German
Restarted JMP 15.2.1
Run Script
Stupid Formula" column is not filled.
Re: How to make a script independent from language settings?Ian, thanks for the shout out! But I think Robbb's question is more about how to refer to a generated column in a data table whose name is localized.
Robbb, this script:
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];
works for me whether I'm using JMP in English or German. In both cases it prints 58.125 to the log. It works because the column "Mittelwert(height)" is created with an alias name of "Mean(height)". You can see this if you copy the table script and paste it into a new script window:
New Column( ["de" => "Mittelwert(height)", "en" => "Mean(height)"],
Numeric,
"Continuous",
Format( "Fixed Dec", 12, 1 ),<BR />// etc.
When looking up the column by name, JMP examines both the current locale name and the English alias, looking for a match.
Can you give us more details on what is failing for you?
Re: How to make a script independent from language settings?Regarding 'good practice', I would certainly take a look at the Discovery paper from @hecht_jmp.