Parsing a value with a Quote<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi,
I have a larege set of data a parse through and create plots and adds them to a jounal based on a unique set of column values. I want to add a script button so that for a paticular plot I have I can quickly get back to the data the created it. The problem I have is that when one of the values contains a quote I can't parse it to create the unique script. Here's a very simplified version of what I'm doing where a represents the value I've gotten from my data table:
a = "Example 4\!" Test";
scrbutt = Button Box("Get Data");
scr = "dt << Select Where(:MyColumn==\!"" || a || "\!")";
eval(parse("scrbutt << set script(" || scr || ")"));
The parse will always fail because it see's the quote after 4 as the end of a string and no matter what I try and can't get it to not to. Any ideas on what I could do?
FYI, this is with JMP9.
Thanks,
Bob
Re: Parsing a value with a QuoteYeah, I was doing this a loop to automate building some analysis so scr would be re-used. I just did this to get around it:
eval(parse("scrbutt << Set Script(" || scr || ");"));
Re: Parsing a value with a QuoteYes, if one digs into the tree structure it says scr. But unless the expression variable scr is changed, the button works as intended (also in JMP 9), or is it not?
If there is any risk that another script that redefines scr, clears globals etc. could be run, then just set the entire cunstruction as button script (or use a protected namespace).
scrbutt << set script(
a = "Example 4\!" Test";
scr = Expr( dt << Select Where( :MyColumn == _a_ ) );
Substitute Into( scr, Expr( _a_ ), a );
scr);
Re: Parsing a value with a QuoteThe last line is where I run into issue with this method. scrbutt << set script(scr); sets the script to "scr" not the expression scr is equal to.
Thanks,
Bob
Re: Parsing a value with a QuoteParsing fails also in JMP 10.
One workaround may be to build the command from expressions instead of strings as in the example below (works in JMP 10).
//Example table
dt = New Table( "Ex", Add Rows( 3 ), New Column( "MyColumn", Character, Nominal, Set Values( {"Example 4\!" Test", "X", "Y"} ) ) );
//Example code
a = "Example 4\!" Test";
scr = Expr( dt << Select Where( :MyColumn == _a_ ) );
Substitute Into( scr, Expr( _a_ ), a );
New Window( "test", scrbutt = Button Box( "Get Data" ), Text Box( Name Expr( scr ) ) );
scrbutt << set script( scr );