<?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: Eliminate empty rows from a script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/798814#M97484</link>
    <description>&lt;P&gt;Jarmo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even better, I don't need to have parallel script windows.&amp;nbsp; I can do the elimination in a single window with this.&amp;nbsp; I nominate the present script window as ed and I'm off to the the races.&amp;nbsp; Thanks for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	ed = ww[Script Box(1)];
	Wait(1);
	ed &amp;lt;&amp;lt; Set Text(Regex(ed &amp;lt;&amp;lt; get text, "[\r\t]+", "\!N", GLOBALREPLACE));
	ed &amp;lt;&amp;lt; reformat;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2024 22:22:35 GMT</pubDate>
    <dc:creator>SpannerHead</dc:creator>
    <dc:date>2024-09-13T22:22:35Z</dc:date>
    <item>
      <title>Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797508#M97335</link>
      <description>&lt;P&gt;I have a script that builds a second script inside a JMP table, copies that and pastes it to a JMP script window to make a functional script.&amp;nbsp; Because of the nature of how this is achieved, I get a lot of empty rows in the finished script and I'd like to eliminate those.&amp;nbsp; Reformat doesn't do the trick and my attempts at REGEX and GLOBALREPLACE also fail.&amp;nbsp; Anyone succeed with this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked in here for clues but I'm still not there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.0/index.shtml#page/jmp/scripting-the-script-editor.shtml#" target="_blank"&gt;Scripting the Script Editor (jmp.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 15:22:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797508#M97335</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-09-10T15:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797551#M97341</link>
      <description>&lt;P&gt;Here is one idea.&amp;nbsp; It takes a script and basically removes all line feeds and then reformats the script.&lt;/P&gt;
&lt;P&gt;The reformatted script realigns the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
nw = New Window( "This is a script box",
sb = Script Box( "print(\!" Hello\!");

print(\!" Hello\!");

print(\!" Hello\!");
print(\!" Hello\!");



print(\!" Hello\!");", 300, 100 );

);
sb &amp;lt;&amp;lt; Save Text( "$TEMP/Test.jsl" );
nw &amp;lt;&amp;lt; close window;
intText = Load Text File( "$TEMP/Test.jsl" );
substitute into(intText,hextochar("0D"), " ");

nw = New Window( "This is a new script box",
sb = Script Box()
);

sb &amp;lt;&amp;lt; Append Text( intText );
sb &amp;lt;&amp;lt; reformat;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Sep 2024 16:35:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797551#M97341</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-09-10T16:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797570#M97343</link>
      <description>&lt;P&gt;If you can live with the fact that all comments get removed as well [like in Formula Editor], you can use the magic of &lt;FONT face="courier new,courier"&gt;Char&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;Parse&lt;/FONT&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myScript = Char(
	Expr(
		For( i = 1, i &amp;lt;= 5, i++, 
        // Print the value of i.
			Print( i );
        
        
        
        
        
		);
    // End expression.
	)
);


nw = New Window( "test", &amp;lt;&amp;lt;Type( "Script" ), myScript );
wait(0);
Main Menu( "reformat script " );&lt;/CODE&gt;&lt;/PRE&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;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myScript = Parse( "/* Begin quote. */
    For (i = 1, i &amp;lt;= 5, i++,
        // Print the value of i.
        Print(i);
        
        
        
        
        
    );
    // End expression.");
   write(myscript)&lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;by the way: via&amp;nbsp;&lt;CODE class=" language-jsl"&gt;&amp;lt;&amp;lt;Type( "Script" )&lt;/CODE&gt;&lt;BR /&gt;the new window is a standard Script Editor window - with the same look and feel (e.g. a play button to run the script : )&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 19:03:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797570#M97343</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-10T19:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797618#M97345</link>
      <description>&lt;P&gt;I refined my code a bit, which is not a perfect solution, but it may work&lt;/P&gt;
&lt;P&gt;Given&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1725993895561.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68109iACFC8E1FB606E4AC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1725993895561.png" alt="txnelson_0-1725993895561.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It returns&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1725993951732.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68110iD3104255FD3AF791/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1725993951732.png" alt="txnelson_1-1725993951732.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
nw = New Window( "This is a script box",
sb = Script Box( "print(\!" Hello\!");

print(\!" Hello\!");

print(\!" Hello\!");











// comment
print(\!" Hello\!");



// comment
print(\!" Hello\!");", 300, 100 );

);
sb &amp;lt;&amp;lt; Save Text( "$TEMP/Test.jsl" );
nw &amp;lt;&amp;lt; close window;
intText = Load Text File( "$TEMP/Test.jsl" );
substitute into(intText,hextochar("0D0D"), "\!n");
substitute into(intText,hextochar("0A0A"), " ");
substitute into(intText,hextochar("2F2F"), "\!n//");

nw = New Window( "This is a new script box",
sb = Script Box()
);

sb &amp;lt;&amp;lt; Append Text( intText );
sb &amp;lt;&amp;lt; reformat;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Sep 2024 18:46:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797618#M97345</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-09-10T18:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797642#M97348</link>
      <description>&lt;P&gt;Thanks Jim and Hogi.&amp;nbsp; I'm surprised how complicated this actually is.&amp;nbsp; I had thought something that kills off incidences of double carriage returns would have worked in this case.&amp;nbsp; Maybe Regex statements work on JMP tables but not scripts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ww = New Window( (names), &amp;lt;&amp;lt; Script );
ed = ww[Script Box(1)];
Regex( ed, "\n\n", "", GLOBALREPLACE )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 20:46:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797642#M97348</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-09-10T20:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797644#M97349</link>
      <description>&lt;P&gt;yes, sure, in JMP there are always 12 ways to do what you want to do ...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ww = New Window( "title", &amp;lt;&amp;lt; Script );
ed = ww[Script Box(1)];

new window("helper", Button Box ("clean",
mytext = ed &amp;lt;&amp;lt; get text;
ed &amp;lt;&amp;lt; set text(Regex( mytext, "[\n\r]{2,}", "\n", GLOBALREPLACE ))))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Sep 2024 20:52:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797644#M97349</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-10T20:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797698#M97353</link>
      <description>&lt;P&gt;Line changing whitespace characters are not all the same which can cause some problems. Sometimes Words() can be clean option for something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

nw = New Window("This is a script box",
	H List Box(
		Panel Box("Long Script",
			sb1 = Script Box(
				"print(\!" Hello\!");

			print(\!" Hello\!");

			print(\!" Hello\!");











			// comment
			print(\!" Hello\!");



			// comment
			print(\!" Hello\!");",
				600,
				500
			);

		),
		sb2 = Script Box(, 600, 500)
	)
);

// You can also clear tabs if you wish to \t (regex) or \!t (jmp)
Wait(1);
sb2 &amp;lt;&amp;lt; Set Text(Regex(sb1 &amp;lt;&amp;lt; get text, "[\r\n]+", "\!N", GLOBALREPLACE));
sb2 &amp;lt;&amp;lt; reformat;

Wait(1);
sb2 &amp;lt;&amp;lt; Set Text("");

Wait(1);
sb2 &amp;lt;&amp;lt; Set Text(Concat Items(Words(sb1 &amp;lt;&amp;lt; get text, "\!N"), "\!N"));
sb2 &amp;lt;&amp;lt; reformat;


Wait(1);
sb2 &amp;lt;&amp;lt; Set Text("");

Wait(1);
lines = sb1 &amp;lt;&amp;lt; get lines;
empty = Loc(ls, "");
sb2 &amp;lt;&amp;lt; Set Text(Concat Items(Remove(lines, As List(empty)), "\!N"));
sb2 &amp;lt;&amp;lt; reformat;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In JMP&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1726034628624.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68113i24B8254DDAA8C27E/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_0-1726034628624.png" alt="jthi_0-1726034628624.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/18.0/index.shtml#page/jmp/jsl-syntax-rules.shtml" target="_blank"&gt;JSL Syntax Rules (jmp.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In regex (usually)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_1-1726034690030.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/68114iF3BA852A18D46775/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_1-1726034690030.png" alt="jthi_1-1726034690030.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 06:10:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/797698#M97353</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-09-11T06:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/798813#M97483</link>
      <description>&lt;P&gt;Jarmo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mighty!&amp;nbsp; Had to tinker with it a bit, seems like there was a Tab that I didn't immediately recognise.&amp;nbsp; This ended up working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Wait(1);
sb2 &amp;lt;&amp;lt; Set Text(Regex(sb1 &amp;lt;&amp;lt; get text, "[\r\t]+", "\!N", GLOBALREPLACE));
sb2 &amp;lt;&amp;lt; reformat;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2024 22:15:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/798813#M97483</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-09-13T22:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Eliminate empty rows from a script</title>
      <link>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/798814#M97484</link>
      <description>&lt;P&gt;Jarmo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Even better, I don't need to have parallel script windows.&amp;nbsp; I can do the elimination in a single window with this.&amp;nbsp; I nominate the present script window as ed and I'm off to the the races.&amp;nbsp; Thanks for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	ed = ww[Script Box(1)];
	Wait(1);
	ed &amp;lt;&amp;lt; Set Text(Regex(ed &amp;lt;&amp;lt; get text, "[\r\t]+", "\!N", GLOBALREPLACE));
	ed &amp;lt;&amp;lt; reformat;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 22:22:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Eliminate-empty-rows-from-a-script/m-p/798814#M97484</guid>
      <dc:creator>SpannerHead</dc:creator>
      <dc:date>2024-09-13T22:22:35Z</dc:date>
    </item>
  </channel>
</rss>

