I've written a JSL routine in which several graphics scripts are being added to - and removed from - the Graph Builder during a relatively complex animation sequence. The scripts that need to be added and removed depend on the data set being analyzed, so I'm having to script a lot of stuff like the following (where gb is my GraphBuilder object, and myScript1 and myScript2 are both expressions I've defined elsewhere):
If( k == 5, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Add Graphics Script( 1, Description( "Script" ), myScript1 )} ));
If( k == 10, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Remove Graphics Script( 2 )} ));
If( k == 15, Report( gb ) << dispatch( {}, "Graph Builder", FrameBox, {Add Graphics Script( 1, Description( "Script" ), myScript2 )} ));
My problem is that I'm losing track of which scripts I'm supposed to be deleting, because I'm referring to them by number - and the numbers allocated to them by the Graph Builder change each time each time a script is removed.
I know I should potentially be able to combine all the graphics scripts into a single large script in which the control is switched between the various sections by if-then-else clauses, but there are potentially dozens of them and the whole thing would probably get very messy.
Is it possible to refer to graphics scripts by name? Essentially I want to be able to do something like this:
report(gb) << dispatch( {}, "Graph Builder", FrameBox, {Remove Graphics Script( myScript2 )} );
The above doesn't work (obviously, or I wouldn't have a problem), but I'm wondering if there's something similar that I've missed.
Many thanks for any suggestions.