Choose Language Hide Translation Bar
Highlighted
kadiew
Level II

Trying to use escape characters for double quote

var=":Name\!"" || initCol || "\!"";

I am trying to create a string variable which would contain the following: :Name("0")

I want to eventually extract data from a column named "0" which is why I'm trying to store this string into a variable. However the output gives me : var = ":Name(\!"0)\!"";  

 

It seems like my escape characters aren't working properly... but without the escape characters I can't run my code at all. Can anyone please help? Could there possibly be a better way to index this column? The "initCol" will always contain a number, but it may not always be 0, which is why I need to store the number of interest in a variable before indexing the column.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
pmroz
Super User

Re: Trying to use escape characters for double quote

You can also use special escape characters \[ and ]\ to allow any characters, including double quotes, in the string.  I'm also using evalinsert for cleaner looking code:

initcol = "0";
var2 = evalinsert("\[:Name("^initcol^")]\");
write(var2);

From the log:

:Name("0")

 

View solution in original post

7 REPLIES 7
Highlighted
txnelson
Super User

Re: Trying to use escape characters for double quote

This works for me

initCol = "0";

var = ":Name(\!"" || initCol || "\!")";

 

Jim
Highlighted
pmroz
Super User

Re: Trying to use escape characters for double quote

You can also use special escape characters \[ and ]\ to allow any characters, including double quotes, in the string.  I'm also using evalinsert for cleaner looking code:

initcol = "0";
var2 = evalinsert("\[:Name("^initcol^")]\");
write(var2);

From the log:

:Name("0")

 

View solution in original post

Highlighted
kadiew
Level II

Re: Trying to use escape characters for double quote

Could there be a setting I need to change in my jmp to get the codes mentioned to work? I have tried both solutions, and both of them result in the following output:

 

colsName = {":Name(\!"0\!")"};
colsName2 = {":Name(\!"0\!")"};

 

Here is the initial code: 

 

colsName[count] = Eval Insert( "\[:Name("^test^")]\" );
colsName2[count] = ":Name(\!"" || test || "\!")";

Show( colsName );
Show( colsName2 );

 

 

colsName is a list of column names which is incremented. For now, count is equal to 1, and only one value (value 0) is trying to get written to the first element of the list, but I can't seem to get rid of the escape characters "\!".

Highlighted
pmroz
Super User

Re: Trying to use escape characters for double quote

JMP is working properly.  When you use show or print the escape characters for double quotes are shown.  If you use write() instead you'll see that the values are correct.

Highlighted
kadiew
Level II

Re: Trying to use escape characters for double quote

Here are the results when using write():
{":Name(\!"0\!")"}
{":Name(\!"0\!")"}

The issue are the " \" " contained in my list beside the "0". This shouldn't be there.
Highlighted

Re: Trying to use escape characters for double quote

Yes, it is correct. The string is :Name("0"). 

Learn it once, use it forever!
Highlighted
pmroz
Super User

Re: Trying to use escape characters for double quote

You cannot use write with the list because it's not a string.  Show includes the escape characters.  

If you use write for a list element you'll see that the string is correct.

show(colsname, colsname2);
write("\!n" || colsName[1] || "\!n");
write(colsName2[1]);

From the log:

colsname = {":Name(\!"0\!")"};
colsname2 = {":Name(\!"0\!")"};
:Name("0")
:Name("0")
Article Labels

    There are no labels assigned to this post.