I hope that I understand what you are asking. This script illustrates one way that might work. The first part is just a way to have some open (data table and Graph Builder) for which the rest of the script to work. That is the part that you might use with your own open Graph Builder objects. You could save this script as an add-in so then it is just a matter of selecting a menu command when you want to use it.
Names Default to Here( 1 );
// example of Graph Builder
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( :weight ) ),
Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
// now the script to save table script with desired name
// ask user for name of script
dialog = New Window( "Name of Script", << Modal,
Panel Box( "Script Name",
Line Up Box( N Col( 2 ),
Text Box( "Name:" ),
teb = Text Edit Box( "Graph Builder Script" )
),
H List Box(
Button Box( "OK",
name = teb << Get Text;
),
Button Box( "Cancel" )
)
)
);
If( dialog["Button"] == -1, Throw( "User cancelled" ) );
// save script for current instance of Graph Builder
window = Get Window List();
wName = window << Get Window Title;
nWindows = N Items( window );
For( i = nWindows, i > 0, i--,
If( Contains( wName[i], "Graph Builder" ),
Break();
);
);
obj = window[i]["Graph Builder"] << Get Scriptable Object;
obj << Save Script to Data Table( name, << Prompt( 0 ), << Replace( 1 ) );
// update table script
script = dt << Get Property( name );
Eval(
Substitute(
Expr(
dt << Set Property( nnn,
w = sss;
w << Set Window Title( nnn )
)
),
Expr( sss ), Name Expr( script ),
Expr( nnn ), name
)
);