報告和按鈕框參考親愛的社區,
我希望你能幫忙解決這個問題。 下面的示例腳本創建一個表並打開分析器平台。 此外,它還向報告附加了兩個控件。 “打開”按鈕的功能是將復選框的值設置為 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 等。