Subscribe Bookmark RSS Feed

Parse() command to output quoted string

martin_snogdahl

Community Trekker

Joined:

Aug 17, 2016

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

Joined:

Jun 22, 2012

Solution

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
2 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

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

Joined:

Jun 23, 2011

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]^")]\");