cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
martin_snogdahl
Level III

Parse() command to output quoted string

Dear community,

I am trying to generate som code by concatenating strings. The string will be evaluated using Eval( Parse( <string>) ). The outcome of this should contain a quoted string, let me exemplify:

List = {"Item1", "Item2"};

string = Concat( "Select(", List[1], ")" );

 

This string will read "Select(Item1)" and Parse( string ) will return Select(Item1). What I want is that Parse( string ) should return Select("Item1"), with quotes. 

 

Any help is much appreciated

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Parse() command to output quoted string

The solution is to add your quotes into the string you are attempting to produce.  

\! is the escape sequence for JMP that allows for the interpretation of the character following it to be properly handled.  Therefore \!" will allow the double quote character to be embedded in the string

Names Default To Here( 1 );
List = {"Item1", "Item2"};
string = "Select(\!"" || List[1] || "\!")";
Show( Parse( string ) );
Jim

View solution in original post

2 REPLIES 2
txnelson
Super User

Re: Parse() command to output quoted string

The solution is to add your quotes into the string you are attempting to produce.  

\! is the escape sequence for JMP that allows for the interpretation of the character following it to be properly handled.  Therefore \!" will allow the double quote character to be embedded in the string

Names Default To Here( 1 );
List = {"Item1", "Item2"};
string = "Select(\!"" || List[1] || "\!")";
Show( Parse( string ) );
Jim
pmroz
Super User

Re: Parse() command to output quoted string

Another way to embed double quotes is to use the \[...]\ delimiters around the string.  I'm also using evalinsert() to evaluate List[1], using ^ characters around it.

 

string2 = evalinsert("\[Select("^List[1]^")]\");