Double quote string element in list<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi there
I have a list of strings:
StringList = {"String1", "String2", "String3"};
Using a for-loop I want to create a new list with the entries shown below:
NewStringList = {"\!"String1\!"", "\!"String2\!"", "\!"String3\!""};
The reason is that I want to use the entries of NewStringList in an Eval(Parse())-expression and get a quoted string as the result:
Eval( Parse( NewStringList[1] ) ) = "String1"
There might be a simple command that I am just not aware of... Thank you
Re: Double quote string element in listHere's another way that uses evalinsert and \[... ]\. The sequence \[ means don't interpret anything in the rest of the string until you see the closing ]\.
newstringlist = {};
for (i = 1, i <= nitems(stringlist), i++,
newstringlist[i] = evalinsert("\["^stringlist^"]\");
);
newstringlist;
Re: Double quote string element in listWorks perfectly. Thank you.
Re: Double quote string element in listHere is one way using Repeat. A For loop works well too but Repeat has the advantage of returning a list directly.
StringList = {"String1", "String2", "String3"};
NewStringList = Repeat(
i = 0;
{i++ ; "\!"" || StringList[i] || "\!""};,
N Items(StringList)
);
Eval( Parse( NewStringList[1] ) );