cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
%3CLINGO-SUB%20id%3D%22lingo-sub-637421%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E6%A0%B9%E6%93%9A%E7%94%A8%E6%88%B6%E8%BC%B8%E5%85%A5%E7%9A%84%E9%80%9A%E9%85%8D%E7%AC%A6%E5%BE%AA%E7%92%B0%E9%81%8D%E6%AD%B7%E6%95%B8%E6%93%9A%E8%A1%A8%E7%9A%84%E8%A1%8C%EF%BC%8C%E4%BB%A5%E4%BE%BF%E7%82%BA%E6%AF%8F%E5%80%8B%E9%81%B8%E5%AE%9A%E7%9A%84%E8%A1%8C%E9%A0%85%E5%BE%9E%E6%95%B8%E6%93%9A%E5%BA%AB%E5%8A%A0%E8%BC%89%E6%95%B8%E6%93%9A%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-637421%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%B0%8D%E6%96%BC%E7%AC%AC%E4%B8%80%E9%83%A8%E5%88%86%EF%BC%8C%E9%80%99%E5%8F%AF%E8%83%BD%E6%9C%83%E8%AE%93%E4%BD%A0%E9%96%8B%E5%A7%8B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20New%20Table(%22Untitled%22%2C%0A%20Add%20Rows(6)%2C%0A%20Compress%20File%20When%20Saved(1)%2C%0A%20New%20Column(%22ID%22%2C%0A%20%20Character%2C%0A%20%20%22Nominal%22%2C%0A%20%20Set%20Values(%7B%22A001%22%2C%20%22A002%22%2C%20%22A003%22%2C%20%22B001%22%2C%20%22B002%22%2C%20%22B003%22%7D)%0A%20)%0A)%3B%0A%0Anw%20%3D%20New%20Window(%22%22%2C%20%26lt%3B%26lt%3B%20modal%2C%20%26lt%3B%26lt%3B%20return%20result%2C%0A%20v%20list%20box(%0A%20%20teb%20%3D%20text%20edit%20box(%22A00*%22)%2C%0A%20%20h%20list%20box(%0A%20%20%20Button%20Box(%22OK%22)%2C%0A%20%20%20Button%20Box(%22Cancel%22)%2C%0A%20%20)%0A%20)%0A)%3B%0A%0AIf(nw%5B%22Button%22%5D%20!%3D%201%2C%0A%20stop()%3B%0A)%3B%0A%0A%2F%2F%20no%20real%20idea%20behind%20the%20selection%20logic%2C%20so%20we%20will%20use%20very%20simple%20one%0A%2F%2F%20user%20has%20to%20always%20provide%20*%0Auser_input%20%3D%20nw%5B%22teb%22%5D%3B%0AIf(!Contains(user_input%2C%20%22*%22)%2C%0A%20Throw(%22No%20wild%20card%20provided!%22)%3B%0A)%3B%0A%0Auser_rows%20%3D%20dt%20%26lt%3B%26lt%3B%20Get%20Rows%20Where(Starts%20With(%3AID%2C%20Substitute(nw%5B%22teb%22%5D%2C%20%22*%22%2C%20%22%22)))%3B%0Auser_ids%20%3D%20dt%5Buser_rows%2C%20%22ID%22%5D%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E9%80%9A%E9%81%8E%E8%AE%93%20JMP%20%E7%82%BA%E5%AE%83%E5%89%B5%E5%BB%BA%E8%85%B3%E6%9C%AC%EF%BC%8C%E9%80%A3%E6%8E%A5%E5%BE%88%E5%AE%B9%E6%98%93%E5%AE%8C%E6%88%90%E3%80%82%20%E7%84%B6%E5%BE%8C%E5%8F%AA%E9%9C%80%E6%B7%BB%E5%8A%A0%E5%BC%95%E7%94%A8%E4%B8%A6%E5%8F%AF%E8%83%BD%E5%B0%87%E5%85%B6%E8%AE%8A%E6%88%90%E4%B8%80%E5%80%8B%E5%87%BD%E6%95%B8%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-637411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%A6%82%E4%BD%95%E6%A0%B9%E6%93%9A%E7%94%A8%E6%88%B6%E8%BC%B8%E5%85%A5%E7%9A%84%E9%80%9A%E9%85%8D%E7%AC%A6%E5%BE%AA%E7%92%B0%E9%81%8D%E6%AD%B7%E6%95%B8%E6%93%9A%E8%A1%A8%E7%9A%84%E8%A1%8C%EF%BC%8C%E4%BB%A5%E4%BE%BF%E5%BE%9E%E6%95%B8%E6%93%9A%E5%BA%AB%E4%B8%AD%E7%82%BA%E6%AF%8F%E5%80%8B%E9%81%B8%E5%AE%9A%E7%9A%84%E8%A1%8C%E9%A0%85%E7%9B%AE%E5%8A%A0%E8%BC%89%E6%95%B8%E6%93%9A%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-637411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E6%9C%89%E4%B8%80%E5%80%8B%E6%95%B8%E6%93%9A%E8%A1%A8%EF%BC%8C%E7%AC%AC%E4%B8%80%E5%88%97%E5%A1%AB%E5%85%85%E6%9C%89part_ID%EF%BC%88%E5%85%B6%E4%BB%96%E5%88%97%E6%9C%89%E8%88%87%E6%AF%8F%E5%80%8B%E9%9B%B6%E4%BB%B6%E7%9B%B8%E5%B0%8D%E6%87%89%E7%9A%84%E5%85%B6%E4%BB%96%E4%BF%A1%E6%81%AF%EF%BC%89%E5%92%8C%E4%B8%80%E5%80%8B%E5%B7%A5%E4%BD%9C%E5%87%BD%E6%95%B8%EF%BC%8C%E8%A9%B2%E5%87%BD%E6%95%B8%E5%BE%9E%E6%95%B8%E6%93%9A%E5%BA%AB%E5%8A%A0%E8%BC%89%E7%B5%A6%E5%AE%9A%EF%BC%88%E5%96%AE%E5%80%8B%EF%BC%89part_ID%20%E7%9A%84%E6%B8%AC%E8%A9%A6%E6%95%B8%E6%93%9A%E3%80%82%E6%88%91%E6%83%B3%E9%80%9A%E9%81%8E%E6%A8%A1%E5%BC%8F%E7%AA%97%E5%8F%A3%E7%8D%B2%E5%BE%97%E4%BB%A5%E4%B8%8B%E5%8A%9F%E8%83%BD%E3%80%82%3C%2FP%3E%3CP%3E1.%20%E8%AE%93%E7%94%A8%E6%88%B6%E4%BD%BF%E7%94%A8%E9%80%9A%E9%85%8D%E7%AC%A6%E9%81%B8%E6%93%87%E6%95%B8%E6%93%9A%E8%A1%A8%E4%B8%AD%E7%9A%84part_ID%E3%80%82%20%E4%BE%8B%E5%A6%82%EF%BC%8Cpart_ID%20%E7%9A%84%E5%BD%A2%E5%BC%8F%E7%82%BA%20A0012%E3%80%81A0013%E3%80%81A0014%20%E7%AD%89%EF%BC%8C%E7%84%B6%E5%BE%8C%E6%98%AF%20B7001%E3%80%81B7002%E3%80%81B7003%20%E7%AD%89%E3%80%82%20%E7%94%A8%E6%88%B6%E5%8F%AA%E9%9C%80%E6%8C%87%E5%AE%9A%20A00*%20%E6%88%96%20B70*%20%E4%B9%8B%E9%A1%9E%E7%9A%84%E5%85%A7%E5%AE%B9%EF%BC%8C%E7%84%B6%E5%BE%8C%E5%9C%A8%E6%95%B8%E6%93%9A%E8%A1%A8%E4%B8%AD%E9%81%B8%E6%93%87%E7%9B%B8%E6%87%89%E7%9A%84part_ID%EF%BC%8C%E5%85%B6%E4%B8%AD%20*%20%E6%98%AF%E9%80%9A%E9%85%8D%E7%AC%A6%E3%80%82%3C%2FP%3E%3CP%3E2.%20%E4%B8%80%E6%97%A6%E9%81%B8%E6%93%87%E4%BA%86part_ID%EF%BC%8C%E6%88%91%E6%83%B3%E5%BE%AA%E7%92%B0%E9%81%8D%E6%AD%B7%E5%AE%83%E5%80%91%E4%B8%A6%E9%80%9A%E9%81%8E%E6%88%91%E7%9A%84%E5%87%BD%E6%95%B8%E7%8D%B2%E5%8F%96%E6%B8%AC%E8%A9%A6%E6%95%B8%E6%93%9A%EF%BC%88%E8%A9%B2%E5%87%BD%E6%95%B8%E5%B0%87part_ID%E4%BD%9C%E7%82%BA%E8%BC%B8%E5%85%A5%E4%B8%A6%E5%9C%A8%E6%95%B8%E6%93%9A%E8%A1%A8%E4%B8%AD%E8%BF%94%E5%9B%9E%E6%B8%AC%E8%A9%A6%E6%95%B8%E6%93%9A%EF%BC%89%EF%BC%8C%E7%84%B6%E5%BE%8C%E9%80%A3%E6%8E%A5%E4%B8%8B%E9%9D%A2%E7%9A%84%E6%AF%8F%E5%80%8B%E6%96%B0%E6%95%B8%E6%93%9A%E8%A1%A8%E5%89%8D%E9%9D%A2%E7%9A%84%E5%BE%97%E5%88%B0%E6%9C%80%E7%B5%82%E7%9A%84%E6%95%B8%E6%93%9A%E8%A1%A8%EF%BC%88%E6%B3%A8%E6%84%8F%E6%89%80%E6%9C%89%E6%B8%AC%E8%A9%A6%E6%95%B8%E6%93%9A%E8%A1%A8%E9%83%BD%E6%9C%89%E7%9B%B8%E5%90%8C%E7%9A%84%E5%88%97%E5%90%8D%EF%BC%89%3C%2FP%3E%3CP%3E%E5%A6%82%E4%BD%95%E5%9C%A8%20JSL%20%E4%B8%AD%E5%AF%A6%E7%8F%BE%E9%80%99%E4%B8%80%E9%BB%9E%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-637411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%E8%B3%AA%E9%87%8F%E5%92%8C%E5%B7%A5%E8%97%9D%E5%B7%A5%E7%A8%8B%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to loop through rows of data table based on user input with wild card in order to load data from database for each selected row item

I have a data table with first column filled with part_IDs (other columns have got other info about corresponding to each part) and a working function which loads test data for a given (single) part_ID from the database.  I would like to have the following functionality via a modal window.

1. Have the user select the part_IDs in the data table using a wild card. For example, the part_IDs are of the form- A0012, A0013, A0014 and so on and then B7001, B7002, B7003 and so on. The user needs to be able to just specify something like A00* or B70* and select the corresponding part_IDs in the data table where * is the wild card character.

2.  Once the part_IDs are selected, I would like to loop through each of them and get the test data via my function (which takes the part_ID as input and returns the test data in a data table) and then concatenate each new data table below the previous to get a final data table (note all test data table have identical column names)

How to implement this in JSL?

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to loop through rows of data table based on user input with wild card in order to load data from database for each selected row item

For part one this might get you started

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(6),
	Compress File When Saved(1),
	New Column("ID",
		Character,
		"Nominal",
		Set Values({"A001", "A002", "A003", "B001", "B002", "B003"})
	)
);

nw = New Window("", << modal, << return result,
	v list box(
		teb = text edit box("A00*"),
		h list box(
			Button Box("OK"),
			Button Box("Cancel"),
		)
	)
);

If(nw["Button"] != 1,
	stop();
);

// no real idea behind the selection logic, so we will use very simple one
// user has to always provide *
user_input = nw["teb"];
If(!Contains(user_input, "*"),
	Throw("No wild card provided!");
);

user_rows = dt << Get Rows Where(Starts With(:ID, Substitute(nw["teb"], "*", "")));
user_ids = dt[user_rows, "ID"];

Concatenation is easy to do by letting JMP create script for it. Then just add references and maybe make it into a function

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: How to loop through rows of data table based on user input with wild card in order to load data from database for each selected row item

For part one this might get you started

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(6),
	Compress File When Saved(1),
	New Column("ID",
		Character,
		"Nominal",
		Set Values({"A001", "A002", "A003", "B001", "B002", "B003"})
	)
);

nw = New Window("", << modal, << return result,
	v list box(
		teb = text edit box("A00*"),
		h list box(
			Button Box("OK"),
			Button Box("Cancel"),
		)
	)
);

If(nw["Button"] != 1,
	stop();
);

// no real idea behind the selection logic, so we will use very simple one
// user has to always provide *
user_input = nw["teb"];
If(!Contains(user_input, "*"),
	Throw("No wild card provided!");
);

user_rows = dt << Get Rows Where(Starts With(:ID, Substitute(nw["teb"], "*", "")));
user_ids = dt[user_rows, "ID"];

Concatenation is easy to do by letting JMP create script for it. Then just add references and maybe make it into a function

-Jarmo