Referencing columns extracted from parsing Datafilter select whereI want to use a data filter interface for a different use.
Then i need to parse the "select where" clause and use the info in there.
I am able to parse the Where clause and identify the different column in the expression
but not reference them
DFClause=Currentdatafilter << get where clause();<BR />SelectInnerExpr=Arg(parse(DFClause),1);<BR />// let assume for a second this will always return an expression of this type to simplify the example <BR />SelectInnerExpr= expr(:study_owner == "name" & :Is Electr. == 1);<BR /><BR />//so i can parse it with a simple for loop
for(iA=1,iA<=NArg(SelectInnerExpr),iA++,
TestColExp=Arg(Arg(SelectInnerExpr,iA),1); // here i can get the column as i need but as :ColumName
TestCol=eval(TestColExp); // so this does not really retun the column reference<BR /> colname= TestCol<< Get Name;
);
however i get the column as :ColumName
how do i now get the column reference to then continue with the script?
colname= TestCol<< Get Name
WindowsRe: Referencing columns extracted from parsing Datafilter select whereIs this what you're looking for? I modified your For() loop to put the first bit into a char, then pulled out and parsed the first word. Full script attached. There are also likely more elegant ways to do this that others may add.
For( iA = 1, iA <= N Arg( SelectInnerExpr ), iA++,
TestColExp = Char( Arg( Arg( SelectInnerExpr, iA ), 1 ) ); // put all into a char()
TestCol = Parse( Word( 1, TestColExp ) ); //now returns test col
);
Re: Referencing columns extracted from parsing Datafilter select whereThis also seems to work, but in the not-that-unusual case of having an open paren in the column name, will fail. You'd have to trap for that if it is a concern.
Names Default To Here( 1 );
dt = open("$Sample_Data\Car Physical Data.jmp");
gb = dt << Graph Builder(
Size( 526, 668 ),
Show Control Panel( 0 ),
Variables( X( :Turning Circle ), Y( :Horsepower ) ),
Elements( Points( X, Y, Legend( 5 ) ), Smoother( X, Y, Legend( 6 ) ) ),
Local Data Filter(
Show Histograms and Bars( 0 ),
Add Filter( columns( :Country, :Type ), Display( :Type, N Items( 5 ) ) ),
Add Filter( columns( :Weight ), Display( :Weight, Height( 20 ) ) )
)
);
<BR /><BR /><BR /><BR />//////////// processing here
ob = (report(gb) << parent)[outlinebox(1)];
lis = (ob << xpath( "//TabPageBox" )) << get title;
colnames = Transform Each( {v, i}, lis[2 :: (N Items( lis ) - 1)],
Trim Whitespace( Items( [1 1], v, "(" )[1] )
);