ボタンボックス内のローカル関数変数こんにちは、
関数内でボタンボックスを作成する際に、ローカル変数にアクセスする方法を探しています。以前、 こちらのフォーラムで、変数をウィンドウの名前空間に割り当てるという解決策が提案されているのを見ました。しかし、私が作成しようとしているレポートは同じウィンドウ内に複数の再利用パーツが含まれているため、この方法は適していないと考えています。
この例では、リンクリストの値を表示するだけですが、最終的なスクリプトではもっと多くのことを行いたいと思っています(グローバル変数を使用してテスト/不正行為を行った場合、すべて正常に動作します)。
// General Component - List Box
make_a_list_box = Function( {list_in},
{Default Local},
l_box = List Box( list_in );
Return( l_box );
);
// General Component - Button linked to a specific list box
linked_button_box = Function( {button_name, target_list_box},
{Default Local},
b_box = Button Box( button_name, Print( target_list_box << Get Items ) ); // Name Unresolved: target_list_box
Return( b_box );
);
// Basic Module - Expect multiple in a shared window
report_module = Function( {list_in, button_name},
{Default Local},
report_list = make_a_list_box( list_in );
report_button = linked_button_box( button_name, report_list );
report = H List Box( report_list, report_button );
Print( report_list << Get Items );
Return( report );
);
// Example Window using multiple modules
New Window( "Test",
V List Box(
report_module( {"A", "B", "C"}, "Letter" ),
report_module( {"1", "2", "3"}, "Number" )
)
);
自動化とスクリプト作成Re: ボタンボックスのローカル関数変数コンテキストボックスを使用できます
Names Default To Here(1);
make_a_list_box = Function({list_in},
{Default Local},
l_box = List Box(list_in);
Return(l_box);
);
// General Component - Button linked to a specific list box
linked_button_box = Function({button_name, target_list_box},
{Default Local},
b_box = Context Box(
box:target_list_box = target_list_box,
Button Box(button_name,
Print(box:target_list_box << Get Items)
)
);
Return(b_box);
);
report_module = Function({list_in, button_name},
{Default Local},
report_list = make_a_list_box(list_in);
report_button = linked_button_box(button_name, report_list);
report = H List Box(report_list, report_button);
Print(report_list << Get Items);
Return(report);
);
nw = New Window("Test",
V List Box(
report_module({"A", "B", "C"}, "Letter"),
report_module({"1", "2", "3"}, "Number")
)
);
Write();