<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to access System Preferences in JSL, specifically the date format setting in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-access-System-Preferences-in-JSL-specifically-the-date/m-p/280829#M54398</link>
    <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/494"&gt;@XanGregg&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jul 2020 18:21:51 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2020-07-21T18:21:51Z</dc:date>
    <item>
      <title>How to access System Preferences in JSL, specifically the date format setting</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-access-System-Preferences-in-JSL-specifically-the-date/m-p/280619#M54365</link>
      <description>&lt;P&gt;I've searched around and haven't found any simple way to get System Preferences settings from within JSL. &amp;nbsp;I'm developing on a Mac – (JMP 14 &amp;amp; 15) – but would also like to know how to do this on Windows. &amp;nbsp;The closest I got was a &lt;A href="https://community.jmp.com/t5/Discussions/Manage-the-display-language-with-JSL-or-freezing-english/td-p/236566" target="_self"&gt;discussion&lt;/A&gt; on how to get the language code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;System Service( Get Language Code );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;CODE class=" language-jsl"&gt;System Service&lt;/CODE&gt; sounds like and interesting function, but I couldn't find any documentation on it. &amp;nbsp;I'm looking for a general solution but am immediately interested in finding the date format, (per setting in System Preferences ➔ Language &amp;amp; Region ➔ Advanced... ➔ Dates ➔ Short), as shown below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-07-20 at 5.55.13 PM.png" style="width: 419px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25579iA7A4C74EE827C951/image-dimensions/419x304?v=v2" width="419" height="304" role="button" title="Screen Shot 2020-07-20 at 5.55.13 PM.png" alt="Screen Shot 2020-07-20 at 5.55.13 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The &lt;EM&gt;Short&lt;/EM&gt; date delimiters are normally set to slashes by default, but were modified by me to dashes in the image above. &amp;nbsp;The specific issue I find with changing this setting is that it affects what arguments are valid to the &lt;CODE class=" language-jsl"&gt;Input&amp;nbsp;Format&lt;/CODE&gt;&amp;nbsp;function. &amp;nbsp;For example, the following statement will generate a runtime error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col &amp;lt;&amp;lt; Input Format( "y/m/d h:m:s" );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So the code must instead look like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;col &amp;lt;&amp;lt; Input Format( "y-m-d h:m:s" );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And the reverse it true if the user has their System Preferences set to slashes. &amp;nbsp;Furthermore, with the &lt;CODE class=" language-jsl"&gt;Format&lt;/CODE&gt;&amp;nbsp;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thus, the set of valid arguments are dependent on the user's setting, and the code must first read this setting to determine which format to use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a workaround, I was able to collect the settings information from a system Unix command and parse it accordingly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// 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 &amp;gt; 0,
	Write( "Using slashes.\!n");
,
/* else if */ ss2 &amp;gt; 0,
	Write( "Using dashes.\!n");
,
/* else */	
	Write( "***ERROR: unrecognized date delimiter.\!n");
	Write( "defaults read com.apple.mail DateCellWidthCache:\!n");
	Write( sDefaults );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this seems a bit clumsy, and I imagine there's a simpler way. &amp;nbsp;It's apparent that the JMP engine can read this setting as it presents a very different set of time formats in the Column Properties dialog based on this setting, as shown below (presenting only the dash options here):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-07-20 at 6.30.49 PM.png" style="width: 362px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25580i8912953604D384AD/image-dimensions/362x597?v=v2" width="362" height="597" role="button" title="Screen Shot 2020-07-20 at 6.30.49 PM.png" alt="Screen Shot 2020-07-20 at 6.30.49 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, my question is: &amp;nbsp;Is there a simple way to get arbitrary System Preferences values (and the date format specifically) by using&amp;nbsp;&lt;CODE class=" language-jsl"&gt;System Service&lt;/CODE&gt;&amp;nbsp;or some other function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:32:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-access-System-Preferences-in-JSL-specifically-the-date/m-p/280619#M54365</guid>
      <dc:creator>SteveTerry</dc:creator>
      <dc:date>2023-06-09T23:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to access System Preferences in JSL, specifically the date format setting</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-access-System-Preferences-in-JSL-specifically-the-date/m-p/280829#M54398</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/494"&gt;@XanGregg&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/6878"&gt;@Jeff_Perkinson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jul 2020 18:21:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-access-System-Preferences-in-JSL-specifically-the-date/m-p/280829#M54398</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-07-21T18:21:51Z</dc:date>
    </item>
  </channel>
</rss>

