<?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: Parsing multiple commands into expr using substitute into in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41744#M24343</link>
    <description>&lt;P&gt;When "Substitute" fails me, I fall back on generating the code I need&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure this is exactly what you want, but it should give you a potential of a way to solve the issue&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
myExpr = Expr(
	TheExpr =
	"FixyAxis = Expr(
	gbt &amp;lt;&amp;lt; SendToReport(
		Dispatch( {}, \!"Graph Builder\!", OutlineBox, {myTitle} ),
		Dispatch(
			{},
			name,
			ScaleBox,
			{Min( minY ), Max( maxY ), Inc( ticksY ),"
	 || myRefLines || ", Show Major Grid( 1 ), ,
			Show Minor Grid( 1 )}
		)
	)
);"
);

myRefLines =
"Add Ref Line(60, Solid, \!"Medium Dark Red\!",\!"USL_lt_2.5\!", 2 ),
              Add Ref Line(30, Solid, \!"Medium Dark Red\!",\!"USL_gt_2.5_lt_4.5\!", 2 )";
myexpr;
Parse( theexpr );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Jul 2017 03:07:47 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-07-11T03:07:47Z</dc:date>
    <item>
      <title>Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41735#M24335</link>
      <description>&lt;P&gt;I am trying to add an arbitrary number of reference lines into a graph based on the arguments given in a function.&amp;nbsp; And I can construct the string I need without too much trouble.&amp;nbsp; The issue I'm having is that I can't seem to get it into past parse() due to the commas in the string.&amp;nbsp; All I really want to do is peel off the outer quotes from the string and substitute it into and remove the \!'s if necessary.&amp;nbsp; Perhaps there's a much better way to do this but here's the guts of my attempt:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expression that needs adjustment:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;FixyAxis = expr( gbt &amp;lt;&amp;lt;
        SendToReport(
            Dispatch(
                {},
                "Graph Builder",
                OutlineBox,
                {myTitle}
            ),
            Dispatch(
                {},
                name,
                ScaleBox,
                {
                  Min( minY ), Max( maxY ), Inc( ticksY ),
                  IntRefLines,
                  Show Major Grid( 1 ), , Show Minor Grid( 1 )
                }
            )
        )
    ) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;String variable I'm trying to substitute with (cr added for readability):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myRefLines = "Add Ref Line(60, Solid, \!"Medium Dark Red\!",\!"USL_lt_2.5\!", 2 ),
              Add Ref Line(30, Solid, \!"Medium Dark Red\!",\!"USL_gt_2.5_lt_4.5\!", 2 ),"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But parse() hits the first comma and quits:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;substitute into(fixYaxis, Expr(IntRefLines), parse(myRefLines)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unexpected ",". Perhaps there is a missing ";" or ",".&lt;BR /&gt;Line 1 Column 60: ...rk Red","USL_lt_2.5", 2 )►,Add Ref Line(30, Solid, ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the end what I want fixYaxis to look like is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;FixyAxis = expr( gbt &amp;lt;&amp;lt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;SendToReport(
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Dispatch(
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{},
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;"Graph Builder",
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;OutlineBox,
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{myTitle}
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;),
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Dispatch(
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{},
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;//"Mean",
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;name,
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ScaleBox,
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Min( minY ), Max( maxY ), Inc( ticksY ),
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Add Ref Line(60, Solid, "Medium Dark Red","USL_lt_2.5", 2 ),
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Add Ref Line(30, Solid, "Medium Dark Red","USL_gt_2.5_lt_4.5", 2 ),
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Show Major Grid( 1 ), , Show Minor Grid( 1 )
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;)
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;)
&amp;nbsp;&amp;nbsp; &amp;nbsp;) ;
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks for any help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Phil&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 13:07:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41735#M24335</guid>
      <dc:creator>ptonge</dc:creator>
      <dc:date>2017-07-13T13:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41744#M24343</link>
      <description>&lt;P&gt;When "Substitute" fails me, I fall back on generating the code I need&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure this is exactly what you want, but it should give you a potential of a way to solve the issue&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
myExpr = Expr(
	TheExpr =
	"FixyAxis = Expr(
	gbt &amp;lt;&amp;lt; SendToReport(
		Dispatch( {}, \!"Graph Builder\!", OutlineBox, {myTitle} ),
		Dispatch(
			{},
			name,
			ScaleBox,
			{Min( minY ), Max( maxY ), Inc( ticksY ),"
	 || myRefLines || ", Show Major Grid( 1 ), ,
			Show Minor Grid( 1 )}
		)
	)
);"
);

myRefLines =
"Add Ref Line(60, Solid, \!"Medium Dark Red\!",\!"USL_lt_2.5\!", 2 ),
              Add Ref Line(30, Solid, \!"Medium Dark Red\!",\!"USL_gt_2.5_lt_4.5\!", 2 )";
myexpr;
Parse( theexpr );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 03:07:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41744#M24343</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-07-11T03:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41754#M24350</link>
      <description>&lt;P&gt;FWIW, here's an alternative you could probably build on:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt &amp;lt;&amp;lt; Graph Builder(
					Size( 528, 452 ),
					Show Control Panel( 0 ),
					Variables( X( :weight ), Y( :height ) ),
					Elements( Points( X, Y, Legend( 8 ) ), Smoother( X, Y, Legend( 9 ) ) ),
				);

// Make some reference lines
n = 3;
refLineList = {};
for(i=1, i&amp;lt;=n, i++,
	InsertInto(refLineList, EvalExpr(Add Ref Line( Expr(RandomInteger(55,65)), "Solid", "Medium Dark Green")));
);

// Add the reference lines
for(i=1, i&amp;lt;=n, i++,
	addLine = Expr(Report(gb)[axisBox(2)] &amp;lt;&amp;lt; lineTBD);
	SubstituteInto(addLine, Expr(lineTBD), refLineList[i]);
	addLine;
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 10:46:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41754#M24350</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2017-07-11T10:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41766#M24358</link>
      <description>&lt;P&gt;Here's another way that builds strings dynamically and then executes the final result using eval(parse()). &amp;nbsp;Uses evalinsert to replace variables surrounded by carets (i.e. ^varname^). &amp;nbsp;Also uses the string escape characters \[ and ]\ to avoid having to escape double quotes inside a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;myRefLines = "\[Add Ref Line(60, Solid, "Medium Dark Red","USL_lt_2.5", 2 ),
              Add Ref Line(30, Solid, "Medium Dark Red","USL_gt_2.5_lt_4.5", 2 ),]\";

FixyAxis = evalinsert("\[
	gbt &amp;lt;&amp;lt; SendToReport(
            Dispatch( {}, "Graph Builder", OutlineBox, {myTitle}
            ),
            Dispatch( {}, name, ScaleBox,
                {
                  Min( minY ), Max( maxY ), Inc( ticksY ),
                  ^myRefLines^,
                  Show Major Grid( 1 ), , Show Minor Grid( 1 )
                }
            )
        )
    )]\");

eval(parse(fixyaxis));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2017 13:28:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41766#M24358</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2017-07-11T13:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41876#M24423</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thanks for responding. I'm trying this now and it appears to work as I wanted it to, although I had to modify other code to get it to work - JMP's syntactically requirements seemed to have changed with more "add ref lines" - that I hadn't noticed until I manually built another graph and dumped the script.&lt;BR /&gt;&lt;BR /&gt;When I get done I'll update the discussion.&lt;BR /&gt;&lt;BR /&gt;Thanks for your help!&lt;BR /&gt;&lt;BR /&gt;Phil&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2017 17:51:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41876#M24423</guid>
      <dc:creator>ptonge</dc:creator>
      <dc:date>2017-07-12T17:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41883#M24428</link>
      <description>&lt;P&gt;Would it be simpler to launch the platform and follow with sending a series of messags to add the lines instead of trying to build the complicated launch message?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 19:20:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41883#M24428</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-07-12T19:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41893#M24436</link>
      <description>txnelson,&lt;BR /&gt;I implemented your method but needed to make a couple of modifications. As I understand it it's basically a string construction that then gets unwrapped/unpacked. But in order for me to get it to work, I removed "FixyAxis =" from "myExpr = Expr(TheExpr ="FixyAxis = Expr(" and then assigned it to the output of the parse command. Then in order to get that to work, I had to eval(FixyAxis). So this "myexpr;Parse( theexpr );" became "myexpr; FixyAxis = Parse(theexpr) ;Eval(fixYaxis) ;". But eval(parse(theexpr)) did not.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2017 21:02:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41893#M24436</guid>
      <dc:creator>ptonge</dc:creator>
      <dc:date>2017-07-12T21:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41899#M24439</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;I had tried an idea like this but really didn't understand how to put together the message string to the graph.&amp;nbsp; I modified your script to use parse(refLinesList[i]) because my list item was more complicated than your example.&amp;nbsp; And since I intend to change the script to accept a limit list rather to build the from this solution meets my current need best.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was also a segment of a larger function to build a generic graphing function (still a work in progress).&amp;nbsp; Completed graph looks like this:&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="graph.GIF" style="width: 780px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/6761i35C9085ADC8B7201/image-size/large?v=v2&amp;amp;px=999" role="button" title="graph.GIF" alt="graph.GIF" /&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 22:36:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41899#M24439</guid>
      <dc:creator>ptonge</dc:creator>
      <dc:date>2017-07-12T22:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41900#M24440</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I implemented this idea first because it made the most sense to me initially.&amp;nbsp; I picked the second posters code over yours because it suited my future needs better.&amp;nbsp; However, I learned something from your method that I'm going to put to use on another problem I've got.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 22:42:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41900#M24440</guid>
      <dc:creator>ptonge</dc:creator>
      <dc:date>2017-07-12T22:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Parsing multiple commands into expr using substitute into</title>
      <link>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41902#M24441</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the carat substitution idea too.&amp;nbsp; I had seen this method referred to but didn't understand it before.&amp;nbsp; Your code was very helpful with a straight forward implementation into my original code (copy, cut, paste and work!).&amp;nbsp; The "\[" is something I didn't know about, and I have another problem I can use this evalinsert solution on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My&amp;nbsp;apologies to all in the manner that my replies are getting added to the thread.&amp;nbsp; My intent was to address each code poster's reply after theirs but I keep seeing them somewhat randomly added. The reply with the graph picture in it was intended as comment to the 2nd code example.&amp;nbsp; This post is intended for the 3rd code example, and the others all pertain to the 1st code example.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 23:00:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Parsing-multiple-commands-into-expr-using-substitute-into/m-p/41902#M24441</guid>
      <dc:creator>ptonge</dc:creator>
      <dc:date>2017-07-12T23:00:17Z</dc:date>
    </item>
  </channel>
</rss>

