引用从解析 Datafilter 中提取的列选择位置我想将数据过滤器接口用于其他用途。
然后我需要解析“select where”子句并使用其中的信息。
我能够解析 Where 子句并识别表达式中的不同列
但不引用它们
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;
);
但是我得到的列是:ColumName
我现在如何获取列引用然后继续脚本?
列名=测试列<< 获取名称
视窗回复:引用从解析 Datafilter 中提取的列选择位置这是你要找的吗? 我修改了您的 For() 循环以将第一位放入一个字符中,然后取出并解析第一个单词。 附上完整脚本。 也可能有其他人可能添加的更优雅的方法来做到这一点。
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
);
回复:引用从解析 Datafilter 选择中提取的列这似乎也有效,但在列名中有一个左括号的常见情况下,会失败。如果担心这一点,你必须对此进行捕捉。
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] )
);