Choose Language Hide Translation Bar
Yngeinstn
Community Trekker

Multiple scripts with only one unique change

I have a graph function and inside this function everything is the identical except the Where() clause. My .jsl are pretty long in nature and I would like to save time scrolling and size but just using one.. I have tried putting an If() statement but that didn't work. Any help is always appreciated.

D

S_323K694_SAVE_PART = Function(

	{dt, Yaxis, colsOverlay },

	Eval(
		Substitute( 
			Expr(
				gb = dt << Graph Builder(
					Invisible,
					Where( dt:tstFunc == plot & dt:part_number == h0 & dt:attenstate == attn & dt:phasestate == phas ),
					Size( 817, 635 ),
					Show Legend( 1 ),
					Show Control Panel( 0 ),
					Automatic Recalc( 1 ),
					Variables( X( :FREQ_GHz ), Y( Eval( Yaxis ) ), Overlay( Eval( colsOverlay ) ) ),
					Elements( Line( X, Y, Legend( 11 ) ) ),
				)
			),
			Expr( plot ), plot,
			Expr( attn ), attn,
			Expr( phas ), phas,
			Expr( mode ), mode,
			Expr( tfun ), tstFunc,
			Expr( over ), colsOverlay,
		)
	);
	
	(gb << Top Report)[Text Box( 1 )] << Delete;
	
	Report( gb )[Text Edit Box( 2 )] << Set Font Size( 8 ) << Set Font Style( "Bold" );
	Report( gb )[Text Edit Box( 1 )] << Set Font Size( 25 ) << Set Font Style( "Bold" );
	
	Report( gb )[Outline Box( 1 )] << Set Title( "" );
	
	Report( gb )[Axisbox( 1 )] << Inc( 1 ) << Minor Ticks( 1 );
	
	Report( gb )[Axisbox( 1 )] << Label Row(
		{Label Orientation( "Angled" ), Show Major Grid( 1 ), Show Minor Grid( 1 ), Set Font Size( 12 )}
	);
	
	Report( gb )[Axisbox( 2 )] << Label Row( {Show Major Grid( 1 ), Show Minor Grid( 1 ), Set Font Size( 10 )} );
	Report( gb )[Axisbox( 2 )] << Inc( 1 );
	
	Try(
		Text = Report( gb )[Text Box( 5 )] << Get Text;
		If( Contains( Text, "Where" ),
			Report( gb )[Text Box( 5 )] << Delete
		);
	);
);

// GB #1 uses Where( dt:tstFunc == plot & dt:part_number == h0 & dt:attenstate == attn & dt:phasestate == phas ),

// GB #2 uses Where( dt:tstFunc == plot & dt:attenstate == attn & dt:phasestate == phas ),

 

1 REPLY 1
Highlighted
txnelson
Super User

Re: Multiple scripts with only one unique change

I would like some additional information.

What are a typical value for plot, attn, phas, mode, tstFunc and colsOverlay?

 

Why are the variables h0 and Yaxis not specified in the Substitute Function? 

Jim