Choose Language Hide Translation Bar
Highlighted
Elofar
Level II

Script: Use RadioBox & "If" to determine the legend of a graph

Hi everyone,

 

I'm building a script to automatize the routine graphs that we do. 

I have scripted a window where the operator can select 1 out of 3 different legend parameters, and this selected parameter should be used as "Color" of the following graph. I used RadioBox as the operator should be able to select only 1 (at the opposite of CheckBox).

Now I was thinking to use something like "If RadioBox gets 1, then use Legend 1 as Color" etc.

 

I tried the following but it doesn't work, the script just skip the "Color" setting:

 

Color( 
		If (rb << Get (1), :Legend 1 ) ,
		If (rb << Get (2), :Legend 2 ),
		If (rb << Get (2), :Legend 2 )
		)
If (rb << Get (1), Color(:Legend 1 )) ,
		If (rb << Get (2), Color(:Legend 2 )),
		If (rb << Get (2), Color(:Legend 2 ))
		),

 

I don't  really understand (1) how to construct the actual "if radiobox = 1", as well as (2) where to place it in the script.

What I shared is a simplified version, in my actual script I have ~35 graphs that are built so I don't want to put the "If radiobox = 1", then "graph builder with legend 1" (and do it for 3 x 35) otherwise this is going to be crazy

 

Do you have any idea how to do that?

 

CC @martindemel  

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Script: Use RadioBox & "If" to determine the legend of a graph

Please look to the Scripting Guide for what messages can be passed to a RadioBox();

     Help==>Scripting Index==>Radio Box()

Your script was almost complete.  Below is the script, with the 2 modifications I made to make it work.

Names Default To Here( 1 );


// Open a window to select parameters to be plotted:
window = New Window( "Graph parameters",  
Outline Box ("Please select of the parameter to be used in the legend"),
rb = Radio Box ({"Legend 1", "Legend 2", "Legend 3"}),
Button Box( "Create graphs",
theLegend = rb << get selected;

// Create a Journal:
Journal = New Window("Journal graphs", <<Journal);

// Graph builder:
gb = Graph Builder(
	Size( 908, 551 ),
	Show Control Panel( 0 ),
	Variables( X( :Parameter X ), Y( :Variable Y ),  
	Color(eval(theLegend) )
	) ,
	Elements( Points( X, Y, Legend( 9 ) ), Smoother( X, Y, Legend( 10 ) ) )
);


// Save graph into the Journal:
gb << Journal;

// Close the graph:
gb << Close Window;


	
window << Close Window
));
Jim
Highlighted
Elofar
Level II

Re: Script: Use RadioBox & "If" to determine the legend of a graph

Thanks @txnelson , I am actually quite familiar with the Scripting index (or Bible as I call it) but coulnd't find this information. Thank you very much for your help, that is exactly what I needed !!  

Article Labels