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%3ERi%3A%20Come%20scorrere%20le%20righe%20della%20tabella%20di%20dati%20in%20base%20all'input%20dell'utente%20con%20caratteri%20jolly%20per%20caricare%20i%20dati%20dal%20database%20per%20ogni%20elemento%20di%20riga%20selezionato%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-637421%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPer%20la%20prima%20parte%20questo%20potrebbe%20farti%20iniziare%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%3ELa%20concatenazione%20%C3%A8%20facile%20da%20eseguire%20lasciando%20che%20JMP%20crei%20uno%20script%20per%20essa.%20Quindi%20aggiungi%20solo%20riferimenti%20e%20magari%20trasformali%20in%20una%20funzione%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-637411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECome%20scorrere%20le%20righe%20della%20tabella%20di%20dati%20in%20base%20all'input%20dell'utente%20con%20caratteri%20jolly%20per%20caricare%20i%20dati%20dal%20database%20per%20ogni%20elemento%20riga%20selezionato%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-637411%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHo%20una%20tabella%20di%20dati%20con%20la%20prima%20colonna%20riempita%20con%20part_ID%20(altre%20colonne%20hanno%20altre%20informazioni%20sulla%20corrispondenza%20di%20ciascuna%20parte)%20e%20una%20funzione%20funzionante%20che%20carica%20i%20dati%20di%20test%20per%20un%20dato%20(singolo)%20part_ID%20dal%20database.Vorrei%20avere%20la%20seguente%20funzionalit%C3%A0%20tramite%20una%20finestra%20modale.%3C%2FP%3E%3CP%3E1.%20Chiedere%20all'utente%20di%20selezionare%20i%20part_ID%20nella%20tabella%20dati%20utilizzando%20un%20carattere%20jolly.%20Ad%20esempio%2C%20i%20part_ID%20sono%20nel%20formato%20A0012%2C%20A0013%2C%20A0014%20e%20cos%C3%AC%20via%20e%20poi%20B7001%2C%20B7002%2C%20B7003%20e%20cos%C3%AC%20via.%20L'utente%20deve%20essere%20in%20grado%20di%20specificare%20semplicemente%20qualcosa%20come%20A00*%20o%20B70*%20e%20selezionare%20i%20part_ID%20corrispondenti%20nella%20tabella%20dati%20dove%20*%20%C3%A8%20il%20carattere%20jolly.%3C%2FP%3E%3CP%3E2.%20Una%20volta%20selezionati%20i%20part_ID%2C%20vorrei%20scorrere%20ciascuno%20di%20essi%20e%20ottenere%20i%20dati%20del%20test%20tramite%20la%20mia%20funzione%20(che%20prende%20il%20part_ID%20come%20input%20e%20restituisce%20i%20dati%20del%20test%20in%20una%20tabella%20di%20dati)%20e%20quindi%20concatenare%20ogni%20nuova%20tabella%20di%20dati%20di%20seguito%20il%20precedente%20per%20ottenere%20una%20tabella%20di%20dati%20finale%20(notare%20che%20tutte%20le%20tabelle%20di%20dati%20di%20test%20hanno%20nomi%20di%20colonna%20identici)%3C%2FP%3E%3CP%3ECome%20implementarlo%20in%20JSL%3F%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%3EQualit%C3%A0%20e%20ingegneria%20di%20processo%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