报告和按钮框参考亲爱的社区,
我希望你能帮忙解决这个问题。 下面的示例脚本创建一个表并打开分析器平台。 此外,它还向报告附加了两个控件。 “打开”按钮的功能是将复选框的值设置为 1/true。 通过使用对探查器报告“PF”的引用来添加控件。 现在,当连续运行脚本两次时就会出现问题。 通过这样做,“PF”引用将被覆盖以引用最新的报告。 当我在旧报告上使用“打开”按钮时,它现在会在新报告中设置复选框的值。 当然,这不是我想要的行为。 我想我必须以某种方式为每份报告使用一个唯一的参考。 有人可以帮忙吗? 谢谢。
Table 1 = New Table( "Table 1",
Add Rows( 1 ),
New Column( "p1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2] ) ),
New Column( "p2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [3] ) ),
New Column( "model",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :p1 ^ 2 + :p2 ^ 2 ),
Set Selected
),
Set Row States( [1] )
);
PF = Profiler(
Y( :model ),
Profiler(
1,
Term Value(
p1( 2, Min( 1.9 ), Max( 2.1 ), Lock( 0 ), Show( 1 ) ),
p2( 3, Min( 2.9 ), Max( 3.1 ), Lock( 0 ), Show( 1 ) )
)
)
);
Report( PF )["Prediction Profiler"] << Append(
NewButton = Button Box( "Turn On" );
//NewIndicator = Radio Box();
);
Report( PF )["Prediction Profiler"] << Append( CheckBox = Check Box( "Item 1" ) );
Report( PF )[Button Box( 1 )] << Set Script(
CheckBox << Set( 1 )
);
回复:报告和按钮框参考所以这成功了,谢谢。
Eval(
Substitute(
Expr(
Report( PF )["Prediction Profiler"] << Append( _NewButton_ = Button Box( "Turn On" ) );
Report( PF )["Prediction Profiler"] << Append( _CheckBox_ = Check Box( "Item 1" ) );
_NewButton_ << Set Script( _CheckBox_ << Set( 1 ) );
),
Expr( __NewButton__ ), Parse( "NewButton" || Char( counter ) ),
Expr( _CheckBox_ ), Parse( "CheckBox" || Char( counter ) )
)
);
回复:报告和按钮框参考<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />嗨克雷奇
这次真是万分感谢。 本示例中的复选框仅用于说明行为。 在我的“真实”应用程序中,按钮框根据报告创建日记。 所以问题是让按钮引用正确的报告窗口。 您的解决方案可能会在其他时候派上用场。 谢谢。
回复:报告和按钮框参考您的示例有一个复选框,它是按钮框的下一个同级,这意味着按钮框很容易找到复选框,只要按钮框可以找到自己即可。如果您使用 setFunction 而不是 set script,则可以。粗体文字,如下。变量消失了。您现在拥有一个匿名函数(未分配给 JSL 变量),按钮框可以将“this”传递给该函数。“this”是按钮框,“this”的兄弟是复选框。PF 变量仍然更改,但我不确定您是否需要它。该函数有可能通过<<父链向上爬行,找到持有该按钮的平台。
Table 1 = New Table( "Table 1",
Add Rows( 1 ),
New Column( "p1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2] ) ),
New Column( "p2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [3] ) ),
New Column( "model",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :p1 ^ 2 + :p2 ^ 2 ),
Set Selected
),
Set Row States( [1] )
);
PF = Profiler(
Y( :model ),
Profiler(
1,
Term Value(
p1( 2, Min( 1.9 ), Max( 2.1 ), Lock( 0 ), Show( 1 ) ),
p2( 3, Min( 2.9 ), Max( 3.1 ), Lock( 0 ), Show( 1 ) )
)
)
);
Report( PF )["Prediction Profiler"] << Append(
Button Box( "Turn On" );
//NewIndicator = Radio Box();
);
Report( PF )["Prediction Profiler"] << Append( Check Box( "Item 1" ) );
Report( PF )[Button Box( 1 )] << Set Function( Function( {this}, (this << sib) << Set( 1 ) ) );
回复:报告和按钮框参考我处理此类问题的方法是使用替换创建对具有不同内存变量的不同对象的引用
Names Default To Here( 1 );
// Create a counter that initializes only the first time it is run, so it increments for each execution
If( Is Empty( counter ) == 1,
counter = 0
);
counter = counter + 1;
Eval(
Substitute(
Expr(
Report( PF )["Prediction Profiler"] << Append(
__NewButton__ = Button Box( "Turn On" );
//NewIndicator = Radio Box();
)
),
Expr( __NewButton__ ), Parse( "NewButton" || Char( counter ) )
)
);
这将为每个后续执行创建 NewButton1、NewButton2 等。