Subscribe Bookmark RSS Feed

using eval expr() with a column name

fr2007

Community Trekker

Joined:

Jul 3, 2012

can some one help me in using eval expr() function with column name;

example:

column1="names";

eval expr(":"||column1);

is the above evel expr() refers to names column? if so please help me with the syntax..(for referring column names)

3 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

You might have better luck with :name("names"), or better yet :name(column1)

jmp_jr

Community Trekker

Joined:

Jun 23, 2011

This will get you what you want. . .

column1="names";

var = parse(":"||temp);

However, a better general implementation that will work no matter how the column is named is to use:

var = Parse(":Name(\!"" || (col << Get Name()) || "\!")");

where col is a column reference (if you already have it).  If you don't you can replace the middle part of the concatenation with column1 from above (or the string "names" itself).

jmp_jr

Community Trekker

Joined:

Jun 23, 2011

If this question is not answered, I guess I do not understand the question.  Here is another answer . . .

In this case, eval expr() is not working as I would expect.  However, I almost never use eval expr() instead I would write

column1 = "names";

val = Eval(Expr(":" || column1));

If you run this, val = ":names"

Alternatively, you could simply write

val = Eval(":" || column1);

or

val = ":" || column1;

However, if you want to actually refer to the column whose name is "names" then you will have to parse val. . .

val2 = parse(val);

Now you can, for example, get the value in row one of this column by running val2[1].

If your question is not answered at this point, please restate your question.