Choose Language Hide Translation Bar
Highlighted
vs90
Community Trekker

Getting Null in function argument variable

Hi,

I'm trying to create multiple formula column by passing "column name" and "formula" as an argument to function from a nested for loop which iterate over a list of list which contains these two values.

Function:

add_col=Function({col_name,col_calc},Show(col_name,col_calc);

cal_2<<New Column(col_name,Numeric,Continuous,Format("Best",12),Formula(col_calc));

);

List:

cols={{"g IgG in Fr II+III Suspension",If(

:Name( "ISB Paste Source/Plasma Type" ) ==

:Name( "Fill Batch Paste Source/Plasma Type" ) ==

:Name( "SFB Paste Source/Plasma Type" ),

:Name( "Individual Fr 2+3 Paste Suspended (Kg) [Bk]" ) *

:Solution Weight After IM HOAc Addition,

Empty()

);},.....};

Loop:

For(i=1,i<=N Items(cols),i++,

For(k=1,k<N Items(cols[i]),k++,

cn=cols[i][k];cl=cols[i][k+1];

);show(cn,cl);

add_col(cn,cl);

);

Log Report:

cn = "g IgG in Fr II+III Suspension";

cl = If(:Name("ISB Paste Source/Plasma Type") == :Name("Fill Batch Paste Source/Plasma Type") == :Name("SFB Paste Source/Plasma Type"), :Name("Individual Fr 2+3 Paste Suspended (Kg) [Bk]") * :Solution Weight After IM HOAc Addition, Empty());

col_name = "g IgG in Fr II+III Suspension";

col_calc = .;

**Not exactly NULL but a DOT(.).

Message was edited by: Vivek Sharma

0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Staff (Retired)

Re: Getting Null in function argument variable

you need nameexpr( ) in three places.




add_col = Function( {col_name, col_calc},


  Show( col_name, Name Expr( col_calc ) );


  cal_2 << New Column( col_name, Numeric, Continuous, Format( "Best", 12 ),


  Formula( Name Expr( col_calc ) )


  );


);




cols = {{"g IgG in Fr II+III Suspension", If(


  :Name( "ISB Paste Source/Plasma Type" ) ==


  :Name( "Fill Batch Paste Source/Plasma Type" ) ==


  :Name( "SFB Paste Source/Plasma Type" ),


  :Name( "Individual Fr 2+3 Paste Suspended (Kg) [Bk]" ) *


  :Solution Weight After IM HOAc Addition,Empty()) ;


}};




For( i = 1, i <= N Items( cols ), i++,


  For( k = 1, k < N Items( cols ), k++,


  cn = cols;


  cl = cols[k + 1];


  );


  Show( cn, cl );


  add_col( cn, Name Expr( cl ) );


);



nameexpr is needed when cl or col_calc is used in a context where it would normally be evaluated but what you want is the expression, unevaluated.

More info Column Formula

Craige

View solution in original post

2 REPLIES 2
Craige_Hales
Staff (Retired)

Re: Getting Null in function argument variable

you need nameexpr( ) in three places.




add_col = Function( {col_name, col_calc},


  Show( col_name, Name Expr( col_calc ) );


  cal_2 << New Column( col_name, Numeric, Continuous, Format( "Best", 12 ),


  Formula( Name Expr( col_calc ) )


  );


);




cols = {{"g IgG in Fr II+III Suspension", If(


  :Name( "ISB Paste Source/Plasma Type" ) ==


  :Name( "Fill Batch Paste Source/Plasma Type" ) ==


  :Name( "SFB Paste Source/Plasma Type" ),


  :Name( "Individual Fr 2+3 Paste Suspended (Kg) [Bk]" ) *


  :Solution Weight After IM HOAc Addition,Empty()) ;


}};




For( i = 1, i <= N Items( cols ), i++,


  For( k = 1, k < N Items( cols ), k++,


  cn = cols;


  cl = cols[k + 1];


  );


  Show( cn, cl );


  add_col( cn, Name Expr( cl ) );


);



nameexpr is needed when cl or col_calc is used in a context where it would normally be evaluated but what you want is the expression, unevaluated.

More info Column Formula

Craige

View solution in original post

vs90
Community Trekker

Re: Getting Null in function argument variable

You are Awesome. I was struck in it and couldn't able to figure it out. Thanks a lot!!