cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
aharro
Level II

Dynamic Coding Problem

Hello,

Looking for tips on how to make my script more dynamic.

Given the snippet below we have a data table << Get as Report that we add onto a Col Box() with dynamic buttons.

Now, here lies the issue. I need to put X amount of data tables into my window and I'm not sure how to go about it since I also need to add dynamic buttons to each table.

 

The exact amount of data tables can vary.

 

Thanks for the help

	data_window = New Window("Down Time Exceeding 5mins",
		<< Size Window( 1000, 600 ),
		H List Box(
			OutLine Box ("foo",
				dt_Rpt = dt_dt << Get as Report();
			)
		)
	);

 

        tb = dt_Rpt[Table Box( 1 )];
	tb << append(
		bb = col box("Pull Alarms")		
	);
	
	bblist = {};
	for (i = 1, i<=N Rows(dt_dt), i++,
		bb_expr = evalinsert("\[bblist[i] = buttonbox("Pull Alarms", 
			tb << Set Selected Rows(Matrix({^i^}));

			dt = Get Data Table( "foo Alarms for rows " || char(^i^));

			dt << ShowWindow( 1 );

			dt << Bring Window To Front;
		)]\");
		eval(parse(bb_expr));
		bb << append(bblist[i]);
	);
3 REPLIES 3
LinkageFrog
Level I

Re: Dynamic Coding Problem

Create a function to generate a data table with buttons:

 

Define Function( Create_Data_Table_With_Buttons( dt_name, window_title ),
    dt_Rpt = dt_name << Get as Report();
    tb = dt_Rpt[Table Box( 1 )];
    tb << append(
        bb = col box("Pull Alarms")
    );
    
    bblist = {};
    for (i = 1, i <= N Rows(dt_name), i++,
        bb_expr = evalinsert("\[bblist[i] = buttonbox("Pull Alarms", 
            tb << Set Selected Rows(Matrix({^i^}));
            dt = Get Data Table( "^window_title^ Alarms for rows " || char(^i^));
            dt << ShowWindow( 1 );
            dt << Bring Window To Front;
        )]\");
        eval(parse(bb_expr));
        bb << append(bblist[i]);
    );
    
    return dt_Rpt;
);

 

 

Create a list of data table names and their corresponding window titles:

 

data_table_info = {
    {"dt_1", "Down Time Exceeding 5mins"},
    {"dt_2", "Another Data Table1"},
    {"dt_3", "Another Data Table2"}
};

 

 

Use a loop to create multiple OutLine boxes with data tables and buttons:

 

data_window = New Window("Multiple Data Tables",
    << Size Window( 1000, 600 ),
    H List Box(
        V List Box(
            for(i = 1, i <= N Items(data_table_info), i++,
                OutLine Box(data_table_info[i][2],
                    Create_Data_Table_With_Buttons(
                        Eval(data_table_info[i][1]),
                        data_table_info[i][2]
                    )
                )
            )
        )
    )
);

 

 

Hope that helps.

aharro
Level II

Re: Dynamic Coding Problem

Thanks!! Didn't even think about using several functions. I thought I might have to create some gigantic headache string to parse, but this totally worked.

I have a function that creates the data tables for each string in my query list. Then I pass the dt to another function that 
appends Lbox which creates the report in my window

window = expr(
	nw = New Window("Down Time Exceeding 5mins",
		<< Size Window( 1500, 800 ),
		Lbox = Line Up Box(Spacing(5),
			N Col(3),
		)
	);
);

eval(window);
nw <<Bring Window To Front;
create_data_tables(list_of_querys);

jthi
Super User

Re: Dynamic Coding Problem

Are you possibly looking something like this?

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");

data_window = New Window("Down Time Exceeding 5mins",
	<<Size Window(1000, 600),
	H List Box(
		Outline Box("foo", 
			ownerbox = dt << Get as Report()
		)
	)
);

tb = ownerbox[Table Box(1)];
tb << append(cb_alarms = Col Box("Pull Alarms"));

For Each Row(dt,
	Eval(EvalExpr(
		cb_alarms << Append(
			Button Box("Pull Alarms",
				tb << Set Selected Rows(Matrix(Expr(Row())));
				show("foo Alarms for rows " || char(Expr(Row())));
				/*
				dt_temp = Get Data Table("foo Alarms for rows " || char(Expr(Row())));
				dt_temp << ShowWindow(1);
				dt_temp << Bring Window To Front;
				*/
			);
		)
	));
);

Write();
-Jarmo