<?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: Script to add leading characters (leading zeros in this case) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226485#M44933</link>
    <description>&lt;P&gt;You're almost there. Use the scoping character (single colon) to make sure JSL understands it's a variable (i.e. a column), and not a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
dt:Architecture &amp;lt;&amp;lt; Set Each Value(Repeat("0", 3 - Length(dt:Architecture)) || dt:Architecture);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Sep 2019 21:33:12 GMT</pubDate>
    <dc:creator>ms</dc:creator>
    <dc:date>2019-09-19T21:33:12Z</dc:date>
    <item>
      <title>Script to add leading characters (leading zeros in this case)</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226473#M44931</link>
      <description>&lt;P&gt;What's the syntax to have a column operate on itself?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This is the best I could come up with and it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = current data table();
column(dt, "Architecture") &amp;lt;&amp;lt; Set Each Value( Repeat("0",3-Length(Char("Architecture")))||Char("Architecture"));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column Architecture has values like 1, 2, 123, XXX, etc.&amp;nbsp; Length is not standard.&lt;/P&gt;&lt;P&gt;Want a script that will run on the table and covert the column to standardize the length at 3 and add any leading zeros.&lt;/P&gt;&lt;P&gt;Resulting values would be, 001, 002, 123, XXX, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Saw this post and it was almost there.&lt;BR /&gt;&lt;A href="https://community.jmp.com/t5/Discussions/How-to-represent-numeric-value-quot-1-quot-as-quot-001-quot/td-p/10972" target="_blank"&gt;https://community.jmp.com/t5/Discussions/How-to-represent-numeric-value-quot-1-quot-as-quot-001-quot/td-p/10972&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 21:13:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226473#M44931</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-09-19T21:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Script to add leading characters (leading zeros in this case)</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226484#M44932</link>
      <description>&lt;P&gt;You need to loop through each row an apply the change:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
For Each Row(
	dt:Architecture = Repeat( "0", 3 - Length( Char( dt:Architecture ) ) ) ||
	Char( dt:Architecture )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 21:23:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226484#M44932</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2019-09-19T21:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Script to add leading characters (leading zeros in this case)</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226485#M44933</link>
      <description>&lt;P&gt;You're almost there. Use the scoping character (single colon) to make sure JSL understands it's a variable (i.e. a column), and not a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
dt:Architecture &amp;lt;&amp;lt; Set Each Value(Repeat("0", 3 - Length(dt:Architecture)) || dt:Architecture);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 21:33:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226485#M44933</guid>
      <dc:creator>ms</dc:creator>
      <dc:date>2019-09-19T21:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Script to add leading characters (leading zeros in this case)</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226557#M44945</link>
      <description>What if the column name has a space in it?&lt;BR /&gt;Thank you so much!</description>
      <pubDate>Fri, 20 Sep 2019 12:54:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226557#M44945</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-09-20T12:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Script to add leading characters (leading zeros in this case)</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226569#M44948</link>
      <description>&lt;P&gt;JSL can forgive spaces in column names.&amp;nbsp; But it can't forgive special characters.&amp;nbsp; The following statements are equivalent references to a column.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt:Architecture Digest
column(dt, "Architecture Digest")&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;For special characters you can use &lt;STRONG&gt;column()&lt;/STRONG&gt; or &lt;STRONG&gt;:Name()&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Column with special characters, ABC=DEF?
column(dt, "ABC=DEF?")
:Name("ABC=DEF?")&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:25:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226569#M44948</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2019-09-20T13:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script to add leading characters (leading zeros in this case)</title>
      <link>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226571#M44950</link>
      <description>&lt;P&gt;Thank you both.&amp;nbsp; The software is great and the user community is even better!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:33:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Script-to-add-leading-characters-leading-zeros-in-this-case/m-p/226571#M44950</guid>
      <dc:creator>BSwid</dc:creator>
      <dc:date>2019-09-20T13:33:36Z</dc:date>
    </item>
  </channel>
</rss>

