You are specifying
Names Default To Here( 1 );
which creates a separate memory namespace for that specific script. That is, in your extract_cols script, there is a list named "fruit". If in your heatmap script you specified
myFruit = fruit[1];
your heatmap script would not know anything about your variable called fruit.
In your heatmap script, you set the variable "dt" equal to the current data table. From your description, you are running the headmap script right after running the extract_cols script. At any given time in JMP, there is only 1 data table that is the current active data table. Therefore when you specify
dt = Current Data Table();
the heatmap script gets the current active data table, which would be the last data table that you created in the extract_cols script
If you need to pass the original data table reference to the second script, and possibly the other 4 data table references, one way of doing this is to create a separate namespace and to place the references into that namespace. Here is a modification to your script creates the namespace and places the data table references into it.
Names Default To Here( 1 );
Clear Symbols();
dt = Current Data Table();
if(isnamespace("trans")==0, trans = new namespace("trans"));
trans:theList = {};
insert into(theList,dt);
fruit = {"Apple","Banana","Mango","Orange"};
For(i = 1, i <= N Items(fruit), i++,
obj = dt << Tabulate(
Set Format( Uniform Format( 10, 0 ) ),
Add Table(
Column Table(
Statistics( Median ),
Grouping Columns( :fruits ),
Analysis Columns( :Values )
),
Row Table( Grouping Columns( :Countries, :locations ) )
),
Local Data Filter(
Add Filter(
columns( :fruits),
Where( :fruits == fruit[i] ),
Display( :fruits, N Items( 14 ) )
)
)
);
trans:theList[i+1] = obj<< make into data table;
Current Report() << Close Window
);
Then you can reference the namespace in your heatmap script to get the primary table reference or any of the data table references that were saved in the namespace.
Names Default To Here( 1 );
Clear Symbols();
dt = trans:thelist[1];
dt << Begin Data Update;
///////////////////////////////////
// Setting Variables for script ///
//rev_scale = "Reverse Scale";
rev_scale =0;
mean_median = 1; //mean=0, median=1
print(mean_median);
///////////////////////////////////
//gets all columns that are continous and stores that in a list as strings.
colList = dt << get column names( continuous, string );
print(colList);
// Create a temporary subset where the columns are the column list, selects all rows,
// invisible makes it so you don't see the datatable on screen since it is temporary
dtsub = dt << subset(columns(colList), selected rows(0),invisible);
// Move the data into a matrix this will be used later to get min, max, median|mean
allData = dtsub << get as matrix;
// Close the no longer needed temporary data table
close(dtsub, nosave);
// Calculate the statistics across the full data matrix
myMax = Maximum(allData);
myMin = Minimum(allData);
if(mean_median == 0,
myMid = Mean(allData),
myMid = Median(allData)
);
print(myMax);
print(myMin);
print(myMid);
print(colList);
// Run for loop over data table with the min, max and median|mean calculated from above
// gradient color scheme needs to be set.
if(rev_scale == 1,
For( i = 1, i <= N Items( colList ), i++,
Eval(
Substitute(
Expr(
Column( __col__ ) <<
set property(
"color gradient",
{"Green Yellow Red",
Range( {__Max__, __Min__, __Mid__} ),"Reverse Scale"}
) << Color Cell by Value( 1 );
),
Expr( __col__ ), colList[i],
Expr( __Max__ ), myMax,
Expr( __Min__ ), myMin,
Expr( __Mid__ ), myMid
)
);
);
,
For( i = 1, i <= N Items( colList ), i++,
Eval(
Substitute(
Expr(
Column( __col__ ) <<
//Column( colList[i] ) <<
set property(
"color gradient",
{"Green Yellow Red",
Range( {__Max__, __Min__, __Mid__} )}
) << Color Cell by Value( 1 );
),
Expr( __col__ ), colList[i],
Expr( __Max__ ), myMax,
Expr( __Min__ ), myMin,
Expr( __Mid__ ), myMid
)
);
);
);
Jim