我進行了搜索,但沒有找到任何從 JSL 中獲取系統偏好設定的簡單方法。我正在 Mac 上進行開發 – (JMP 14 & 15) – 但也想知道如何在 Windows 上執行此操作。我得到的最接近的是關於如何獲取語言代碼的討論:
System Service( Get Language Code );
System Service sounds like and interesting function, but I couldn't find any documentation on it. I'm looking for a general solution but am immediately interested in finding the date format, (per setting in System Preferences ➔ Language & Region ➔ Advanced... ➔ Dates ➔ Short), as shown below:

The 短的 date delimiters are normally set to slashes by default, but were modified by me to dashes in the image above. The specific issue I find with changing this setting is that it affects what arguments are valid to the Input Format function. For example, the following statement will generate a runtime error:
col << Input Format( "y/m/d h:m:s" );
因此程式碼必須如下所示:
col << Input Format( "y-m-d h:m:s" );
And the reverse it true if the user has their System Preferences set to slashes. Furthermore, with the Format function, if the wrong date string is given, there won't be a runtime error, but the relevant datetime column will ignore the format setting, and the data will be left in its raw, unintelligible form.
因此,有效參數集取決於使用者的設置,並且程式碼必須先讀取此設定以確定要使用哪種格式。
作為解決方法,我能夠從系統 Unix 命令收集設定資訊並相應地解析它:
// implement Unix command:
// $ defaults read com.apple.mail DateCellWidthCache | grep M.d.yy
Clear Log();
// read System Preferences from 'defaults' that contains date format string.
sDefaults = Run Program(
Executable( "/usr/bin/defaults" ),
Options( { "read", "com.apple.mail", "DateCellWidthCache" } ),
Read Function( "text" )
);
//Write( sDefaults );
ss1 = Munger( sDefaults, 1, "M/d/yy" ); // check for slash style.
ss2 = Munger( sDefaults, 1, "M-d-yy" ); // check for dash style.
Show( ss1, ss2 ); Write("\!n");
If( ss1 > 0,
Write( "Using slashes.\!n");
,
/* else if */ ss2 > 0,
Write( "Using dashes.\!n");
,
/* else */
Write( "***ERROR: unrecognized date delimiter.\!n");
Write( "defaults read com.apple.mail DateCellWidthCache:\!n");
Write( sDefaults );
);然而,這似乎有點笨拙,我想有一個更簡單的方法。顯然,JMP 引擎可以讀取此設置,因為它基於此設置在“列屬性”對話框中顯示一組非常不同的時間格式,如下所示(此處僅顯示破折號選項):

So, my question is: Is there a simple way to get arbitrary System Preferences values (and the date format specifically) by using System Service or some other function?