cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMPĀ® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Martin
Level V

Parse Outermost Quoted String

I am writing a script that makes an additional script on the data table as "New Script". But I am having a problem with parsing the string I have set up as the code to be placed in the new script.

The problem is when I run "dt << New Script("Script", parse(a));" when it parses the string, it assumes the quote prior to the Graph Builder is the first quote and then ends that quote at the beginning of the "Graph Title" section and ends.  I need to be able to write in the script that my script is writing to the data table, many quotes without them parsing when I go to place them in the script.

 

The code looks something like this:

 

a = "Parse(Eval(Eval Insert(
    "Graph Builder(
        ...
       Dispatch(
         ... ,"Graph Title",
       ),
       ....

    )"
)));

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Parse Outermost Quoted String

I agree that you should learn how to use expressions, but you also need to learn how to work with character strings. Use the \!" escape sequence to enter a double quotation mark inside a string. Otherwise, the quotation mark is interpreted as a string delimiter as you discovered.

View solution in original post

4 REPLIES 4
pauldeen
Level VI

Re: Parse Outermost Quoted String

You probably need to look at expr() and insert into() or substitute into() for constructing you new table script. If you expand your scipt to show what you have we might be able to help you in more detail.

Martin
Level V

Re: Parse Outermost Quoted String

This is the exact script I need to put into a new table script:

 

Eval(
	Parse(
		eval Insert(
			"\[Graph Builder(
				Size( 1500, 400 ),
				Show Control Panel( 0 ),
				Show Title( 0 ),
				Variables(
					X( :TIME ),
					Y( :Y )
				),
				Elements( Points( X, ^TempY^, Legend( 6 ) ) ),
				SendToReport(
					Dispatch(
						{},
						"Graph Builder",
						OutlineBox,
						{Set Title( "My New Title" ),
						Image Export Display( Normal )}
					),
					Dispatch(
						{},
						"TIME",
						ScaleBox,
						{Format( "Format Pattern", "<M><-><D><-><YY> <zhh><ampm>" ),
						Min( 3717386000 ), Max( 3717507800 ), Interval( "Hour" ), Inc( 4 ),
						Minor Ticks( 0 ), Label Row( Label Orientation( "Vertical" ) )}
					),
					Dispatch(
						{},
						"graph title",
						TextEditBox,
						{Set Text( "Graph Title" )}
					),
					Dispatch(
						{},
						"Y title",
						TextEditBox,
						{Set Text( "Thing of Interest" )}
					)
				)
			)]\"
		)
	)
);

The reason for the "Eval(Parse(Eval Insert(" is because there is a variable in the script "TempY" that is the name of another table variable that gets changed via a radio box in an input window.

hogi
Level XII

Re: Parse Outermost Quoted String

Hi @Martin.
This is an example with Big Class and Substitute
a) to get TempY replaced with the variable

b) to get the code into the NewScript function.

The TempY in "Elements" has to be replaced by "Y", so you could put "Y" there directly.
Did you want to change "Y" in Variables?

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
TempY=Expr(Y);
myCode= Substitute(Expr(
		
			Graph Builder(
				Size( 1500, 400 ),
				Show Control Panel( 0 ),
				Show Title( 0 ),
				Variables(
					X( :age ),
					Y( :height /*change this one*/ )
				),
				Elements( Points( X, TempY, Legend( 6 ) ) )

		)),
	Expr(TempY),Name Expr(TempY));
Eval(Substitute(Expr(dt << New Script("Script", __script__)),Expr(__script__),Name Expr(myCode)))
	

Re: Parse Outermost Quoted String

I agree that you should learn how to use expressions, but you also need to learn how to work with character strings. Use the \!" escape sequence to enter a double quotation mark inside a string. Otherwise, the quotation mark is interpreted as a string delimiter as you discovered.