<?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: I can't even do this simple replace! in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71064#M35340</link>
    <description>&lt;P&gt;You could use&lt;A href="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013" target="_self"&gt; data table subscripting&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Wait(3);
maleRows = Loc(dt[0, "sex"], "M");
dt[maleRows, "sex"] = "boy";&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Sep 2018 12:36:21 GMT</pubDate>
    <dc:creator>ian_jmp</dc:creator>
    <dc:date>2018-09-03T12:36:21Z</dc:date>
    <item>
      <title>I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71037#M35337</link>
      <description>&lt;P&gt;&lt;SPAN class="transSent"&gt;Not found in the script index, please finish with JSL.&lt;/SPAN&gt;&lt;SPAN class="transSent"&gt;Thank you very much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="transSent"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2018-09-04_18-28-59.png" style="width: 671px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12283iF28D26ABA4A3091E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-09-04_18-28-59.png" alt="2018-09-04_18-28-59.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 10:36:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71037#M35337</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T10:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71064#M35340</link>
      <description>&lt;P&gt;You could use&lt;A href="https://community.jmp.com/t5/Uncharted/Data-table-subscripting/ba-p/21013" target="_self"&gt; data table subscripting&lt;/A&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Wait(3);
maleRows = Loc(dt[0, "sex"], "M");
dt[maleRows, "sex"] = "boy";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Sep 2018 12:36:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71064#M35340</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-09-03T12:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71084#M35342</link>
      <description>It seems to be quite different from the VBA approach.thank you!</description>
      <pubDate>Mon, 03 Sep 2018 13:33:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71084#M35342</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T13:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71096#M35343</link>
      <description>&lt;P&gt;&lt;SPAN class="transSent"&gt;I've tried to write JSL in a way that only works with perfectly matched substitutions, but if you don't want to replace only a few characters, how do you write JSL?&lt;/SPAN&gt;&lt;SPAN class="transSent"&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="transSent"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2018-09-04_21-38-19.png" style="width: 769px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12286i0A7A5FB0974DE76A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-09-04_21-38-19.png" alt="2018-09-04_21-38-19.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 13:46:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71096#M35343</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T13:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71105#M35344</link>
      <description>&lt;P&gt;This is one way to do it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
dt:class[dt &amp;lt;&amp;lt; get rows where( dt:class == "A1" )] = "A9";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Sep 2018 14:06:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71105#M35344</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-09-03T14:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71107#M35345</link>
      <description>&lt;P&gt;&lt;SPAN class="transSent"&gt;If this is the new case, this JSL is not very efficient.&lt;/SPAN&gt;&lt;SPAN class="transSent"&gt;Can the code be improved for the new instance?&lt;/SPAN&gt;&lt;SPAN class="transSent"&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="transSent"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2018-09-04_22-14-58.png" style="width: 769px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12287i47B910A948EC63D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-09-04_22-14-58.png" alt="2018-09-04_22-14-58.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 14:19:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71107#M35345</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T14:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71109#M35346</link>
      <description>&lt;P&gt;If I understand correctly, consider using the 'Match()' JSL expression. I generated the code below by using 'Cols &amp;gt; Recode':&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 2018-09-03 at 15.29.02.png" style="width: 513px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12288i7F31C4A8A273AE18/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-09-03 at 15.29.02.png" alt="Screen Shot 2018-09-03 at 15.29.02.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and inspecting the JSL for the resulting formula column. And, 'yes', JSL is very different from VBA. You should look at 'Help &amp;gt; Books &amp;gt; Scripting Guide' and/or consider some training.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Wait(3);
dt &amp;lt;&amp;lt; New Column( "Age 2",
					Character,
					"Ordinal",
					Formula(
						Match( :age,
							12, "Twelve",
							13, "Thirteen",
							14, "Fourteen",
							15, "Fifteen",
							16, "Sixteen",
							17, "Seventeen",
							Format( :age, "Fixed Dec", 5, 0 )
						)
					)
				);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Sep 2018 14:37:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71109#M35346</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-09-03T14:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71110#M35347</link>
      <description>I'm so sorry!Maybe the example I gave is not appropriate and misleading.&lt;BR /&gt;&lt;BR /&gt;I just want to replace some of the specified characters with others in the same column.That is the manual interface function, just want to use JSL implementation.&lt;BR /&gt;&lt;BR /&gt;The VBA implementation in excel is simple:Selection.Replace What:="1", Replacement:="9", LookAt:=xlPart&lt;BR /&gt;&lt;BR /&gt;I just want the effect of this simple trade effect.But I don't have the corresponding code in JSL.Thank you!</description>
      <pubDate>Mon, 03 Sep 2018 14:53:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71110#M35347</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T14:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71113#M35349</link>
      <description>&lt;P&gt;This is the result of the substitution in the case of "Match entire cell value" the multiple checkbox is not selected.Thank you!&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="2018-09-04_22-14-58.png" style="width: 769px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12289iBF8DCF4CC6767D25/image-size/large?v=v2&amp;amp;px=999" role="button" title="2018-09-04_22-14-58.png" alt="2018-09-04_22-14-58.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 14:59:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71113#M35349</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T14:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71114#M35350</link>
      <description>It's just a matter of replacing some characters in a cell with JSL.</description>
      <pubDate>Mon, 03 Sep 2018 15:02:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71114#M35350</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T15:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71116#M35352</link>
      <description>&lt;P&gt;OK. So maybe take a look at &lt;A href="https://community.jmp.com/t5/Uncharted/Regex/ba-p/21008" target="_self"&gt;regular expressions&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 15:24:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71116#M35352</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2018-09-03T15:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71139#M35359</link>
      <description>I see. That's all I can do.Thankyou!</description>
      <pubDate>Mon, 03 Sep 2018 23:31:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71139#M35359</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-03T23:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71140#M35360</link>
      <description>&lt;P&gt;That is not all the ways it&amp;nbsp; can be&amp;nbsp;coded in JSL to accomplish what you want, but Ian's suggestion is what I would have also suggested as the solution.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 00:14:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71140#M35360</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-09-04T00:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71141#M35361</link>
      <description>Thanks for your help.&lt;BR /&gt;I want to realize that VBA is done with one click In JMP: you can do many complicated operations with just one click of the home-made button.</description>
      <pubDate>Tue, 04 Sep 2018 00:37:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71141#M35361</guid>
      <dc:creator>lwx228</dc:creator>
      <dc:date>2018-09-04T00:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: I can't even do this simple replace!</title>
      <link>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71319#M35391</link>
      <description>&lt;P&gt;Iwx228 brings up an interesting wish list item, albeit the example provided is not the typical JSL use case, where there are user selected rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Excel VBA has a spreadsheet method (function) to do a global replace.&amp;nbsp; JMP's Substitute() and Substitute Into() functions would meet this users needs without the overhead of regular expressions, since there was no requirement for a pattern, just global replacement. All that is missing is to get and apply it to the current selections. The logical syntax would be&lt;/P&gt;&lt;P&gt;&amp;nbsp;dt &amp;lt;&amp;lt; Replace( searchStr, replaceStr, arguments for selections either select rows and selected cols or all, or.....)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a prototype script called ReplaceCell() with usage examples.&lt;/P&gt;&lt;P&gt;A few items to note:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Applies to the current data. Aborts if no current data table.&lt;/LI&gt;&lt;LI&gt;Aborts if no selected columns. If no selected rows, all rows in the selected columns are used.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;As written this function only applies to Character columns; it can be extended to Numeric columns, by using char() and num() functions.&lt;/LI&gt;&lt;LI&gt;Replaces by row, so looping happens once.&lt;/LI&gt;&lt;LI&gt;This could have been done by column fairly quicky with LFunc() which I posted previously, but wanted to keep ths simple.&lt;/LI&gt;&lt;LI&gt;Use Include() for JSL. No need to make it an Add-In since CTRL + F already does this&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ReplaceCell = Function({src,rpl},{cdt, scol, srow, i, j, val},&lt;BR /&gt; if(ntable()&amp;gt;0, cdt=current data table(), throw("no table available"));&lt;BR /&gt; scol = cdt &amp;lt;&amp;lt; get selected columns;&lt;BR /&gt; if(nitems(scol) ==0, throw("no columns are selected...aborting"));&lt;BR /&gt; srow = cdt &amp;lt;&amp;lt; get selected rows();&lt;BR /&gt; if (nrow(srow)==0, srow = Transpose(1::nrow(cdt)) ); //if no rows are selected, assume the entire column.&lt;BR /&gt; for(i=1, i&amp;lt;=nrow(srow), i++,&lt;BR /&gt; for(j=1, j&amp;lt;=nitems(scol), j++,&lt;BR /&gt; val = scol[j][srow[i]];&lt;BR /&gt; if( IsString(val), scol[j][srow[i]] = Substitute(val, src, rpl) ) &lt;BR /&gt; );&lt;BR /&gt; )//end for i&lt;BR /&gt; &lt;BR /&gt;); //end function&lt;BR /&gt;&lt;BR /&gt;//test cases create a new table with 2 selected columns &lt;BR /&gt;ndt = New Table( "Test 1",&lt;BR /&gt; Add Rows( 10 ),&lt;BR /&gt; New Column( "A",&lt;BR /&gt; Character,&lt;BR /&gt; "Nominal",&lt;BR /&gt; Set Values(&lt;BR /&gt; {"A7", "B7", "C7", "D7", "E7", "F7", "G7", "A9", "A79", "A707"}&lt;BR /&gt; )&lt;BR /&gt; ),&lt;BR /&gt; New Column( "B",&lt;BR /&gt; Character,&lt;BR /&gt; "Nominal",&lt;BR /&gt; Set Values(&lt;BR /&gt; {"M7", "M77", "M07", "MX7", "E7", "E2", "E3", "F9", "G27", "M99"}&lt;BR /&gt; )&lt;BR /&gt; )&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;//replace all 7's with 1's&lt;BR /&gt;ReplaceCell("7","1"); //aborts no selected columns&lt;BR /&gt;&lt;BR /&gt;ndt:A &amp;lt;&amp;lt; set selected(1);&lt;BR /&gt;ndt:B &amp;lt;&amp;lt; set selected(1);&lt;BR /&gt;&lt;BR /&gt;//replace all 7's with 1's&lt;BR /&gt;ReplaceCell("7","1");&lt;BR /&gt;ndt &amp;lt;&amp;lt; bring window to front;&lt;BR /&gt;&lt;BR /&gt;//now try it with selected rows&lt;BR /&gt;&lt;BR /&gt;ndt &amp;lt;&amp;lt; select rows([1,2,4,7,9,10]);&lt;BR /&gt;&lt;BR /&gt;ReplaceCell("1","6");&lt;BR /&gt;ndt &amp;lt;&amp;lt; bring window to front;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Sep 2018 02:40:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/I-can-t-even-do-this-simple-replace/m-p/71319#M35391</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-09-05T02:40:22Z</dc:date>
    </item>
  </channel>
</rss>

