Choose Language Hide Translation Bar
Highlighted
smithwoosley
Level II

Output of one script as input for another

New to JMP, looking for direction on utilizing script data table outputs as inputs for another script.

 

I have developed a script which takes a user defined input (lot code), pulls data referencing the input, combines data from several sources, performs a few simple calculations, and outputs a finalized data table.  This script works well and does exactly what I need it to do for one user input.  The final result is about a dozen columns and between 4-12 rows.

 

Now I have developed another script which pulls a list of lot codes from a specified date range.  The final result is one column, anywhere between 1-100+ rows based on length of input date range.

 

I'd like each of these lot codes from the second script to be used as individual inputs for the first script.  I'm looking for an efficient way to combine these two scripts.  I feel it should be a simple solution, grabbing the first lot code from the first row, running it through the first script, and repeating for the 2 - nth row.  Just not quite sure where to start.

 

If anyone could point me in the right direction, I'd very much appreciate it.  Thank you!

5 REPLIES 5
Highlighted
txnelson
Super User

Re: Output of one script as input for another

What I think you need to do, is to change the code from your first script, into a function, with Lot Code being a value passed to the function.

Names default to here(1);

firstPGM = Function( {Lot Code}, {default local},
     Your first script
);
Your second Script;
Loop across each of the Lot Codes and call the function
For(I=1,i<= lotcodeCount,i++,
     xout = firstPGM(LotCode[I]);
);

 

Jim
Highlighted
smithwoosley
Level II

Re: Output of one script as input for another

Thanks so much for the reply.  This solution certainly sounds like what I'm trying to get to, but I'm having trouble implementing.

 

In my first code, I'm using a text edit box and lotcode = lotcode_teb << get text to set the input lotcode, then using select ... where vcLotCode like '" || lotcode || "' to pull the data for that lot.

 

So, in the suggested for loop, how might I implement the new lot codes from the script which pulls all lot codes from a date range and stores them in one column?

 

I'm trying to play with things like select rows or get values from the column of lot codes, but not having any luck.

 

Thanks.

Highlighted
txnelson
Super User

Re: Output of one script as input for another

My suggestion is to simplify the code, and to take it step by step.  Then if you run into an issue, your can upload the script to the Discussion Group, so the community can better see your issue, and then help you solve it.

 

Jim
Highlighted
smithwoosley
Level II

Re: Output of one script as input for another

Thanks.  Certainly trying to simplify.  Right now I'm here, trying to get the first row of the column to run.  Then I'll need to work on implementing the for loop.

 

I was thinking I could loop through row selection, and set lot code to selected row, but that doesn't seem to be working.

 

// Below replicates output of lot code script
dt=New Table ("Lots", Add Rows(5), New Column ("vcLotCode", Character, Nominal, Set Values ({"lcode.0123","12345.4321","dcode.0123","54321.0123","lotcd.4567"}) ), );
// Attempting to set lot code to values from lot code table
dt<<Select Rows(1); lotcode = :vcLotCode <<Get Selected;
// Attempting to pull data from database using lot code as lookup variable
DSNString = "Driver={SQL Server}; SERVER=rpt; DATABASE=FAB; UID=rrpt; "; sqlStr= " select vcLotCode, vcWaferCode, dAvg from fr.database where vcLotCode like '"||lotcode||"' "; dt2 = Eval(Substitute(Expr(dt=Open Database(DataSource,sqlcode,"Data");),Expr(sqlcode),sqlstr,Expr(DataSource),DSNString));
Highlighted
smithwoosley
Level II

Re: Output of one script as input for another

Sorry, here:

 

// Below replicates output of lot code script

dt=New Table ("Lots",
	Add Rows(5),
	New Column ("vcLotCode",
		Character,
		Nominal,
		Set Values ({"lcode.0123","12345.4321","dcode.0123","54321.0123","lotcd.4567"})
	),
);

// Attempting to set lot code to values from lot code table

dt<<Select Rows(1);
lotcode = :vcLotCode <<Get Selected;

// Attempting to pull data from database using lot code as lookup variable

DSNString = "Driver={SQL Server}; SERVER=rpt; DATABASE=FAB; UID=rrpt; ";

sqlStr=
"
select vcLotCode, vcWaferCode, dAvg
from fr.database
where vcLotCode like '"||lotcode||"'
";

dt2 = Eval(Substitute(Expr(dt=Open Database(DataSource,sqlcode,"Data");),Expr(sqlcode),sqlstr,Expr(DataSource),DSNString));
 
Article Labels

    There are no labels assigned to this post.