Subscribe Bookmark RSS Feed

How to use variable in List Check()

<-
P={"M","F"},
Col<->

it doesn't work when I use a variable.
5 REPLIES
mpb

Super User

Joined:

Jun 23, 2011

This seems to work:

chungwei

Staff

Joined:

Jun 23, 2011

I think there is a defect on this.
Whenever I need to use a variable's value as opposed to the variable itself for anything, like setting a column's property, I usually end up just building the expression I want as text and then parsing it. I've just tried doing that here as well, and the following seems to work:

MF = {"M", "F"};

MyTable = New Table( "MyTable",
New Column( "Year", Numeric, Values( Index( 2001, 2010 ) ) ),
New Column( "Gender", Character, Values( {"M", "F", "M", "M", "f", "M", "Male", "F", "M", "F"} ) )
);

TextToParse = "column(\!"Gender\!") << list check(" || Char( MF ) || ")";
Show( TextToParse );
Eval( Parse( TextToParse ) );
thanks for all replies. Eval(Parse()) is the best solution for this case.
pmroz

Super User

Joined:

Jun 23, 2011

I use eval() to set the value ordering. Might work the same for list check. Cheers!




style="font-size: 10pt; font-family: "Courier New"; color: green;">/*
Set the value ordering for the
new age category column */

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">=

style="font-size: 10pt; font-family: "Courier New"; color: black;">
{}

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl1
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl1))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl2
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl2))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl3
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl3))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl4
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl4))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl5
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl5))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl6
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl6))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl7
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl7))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl8
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl8))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl9
style=""> 

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl9))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">if

style="font-size: 10pt; font-family: "Courier New"; color: black;">
(lbl10

style="font-size: 10pt; font-family: "Courier New"; color: navy;">!=

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">""

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
lbl10))

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">



style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">insertinto

style="font-size: 10pt; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; font-family: "Courier New"; color: black;">age_value_list

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">
{

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Neonate"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Infant"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Child"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Adolescent"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Adult"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Elderly"

style="font-size: 10pt; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; font-family: "Courier New"; color: black;">

style="font-size: 10pt; font-family: "Courier New"; color: purple;">"Not
reported"

style="font-size: 10pt; font-family: "Courier New"; color: black;">})

style="font-size: 10pt; font-family: "Courier New"; color: navy;">;

style="font-size: 10pt; font-family: "Courier New"; color: black;">





style="font-size: 10pt; font-family: "Courier New"; color: black;">


style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: rgb(0, 0, 221);">column

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">current_dataset

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">
age_cat_col)

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;"><<

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">
set property(value
ordering

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">,

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: rgb(0, 0, 221);">eval

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">(

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: black;">age_value_list))

style="font-size: 10pt; line-height: 115%; font-family: "Courier New"; color: navy;">;