Sounds like you might want to put everything into one script. If so, the example below should get you started (though it uses a CSV file).
Do 'File > New > New Script' to open a window, copy the code below, and paste it in. You can run it as it is (with 'Edit > Run Script'), and then adapt it to your case. Do 'File > Save' to save your new script file.
To learn a little about JSL, try 'Help > Books > Scripting Guide'.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_IMPORT_DATA/Book1.csv" );
dt <<
New Column( "Formula", Numeric, "Continuous", Formula( (:Name( "1" ) + :Name( "2" )) / :Name( "3" ) ) );
dt <<
Graph Builder(
Size( 531, 452 ),
Show Control Panel( 0 ),
Variables( X( :Name( "1" ) ), Y( :Formula ) ),
Elements( Points( X, Y, Legend( 6 ) ), Smoother( X, Y, Legend( 7 ) ) )
);