cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
mvanderaa1
Level IV

In a script, return the selected table scripts as a list

Hi, I am aware of using the code below to return all the table scripts

scriptNames = dt << Get Table Script Names;

Is there a way to only return the scripts that I have selected (if any are selected, otherwise return all).

So return [Bivariate,Logistic] in the case below

mvanderaa1_0-1660807701175.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: In a script, return the selected table scripts as a list

The information is contained in the results from get selected properties, but you might have to do some work to unpick the information.  Here is an example:

 

// example from the scripting guide

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Properties( {2, 4} );
proplist = dt << Get Selected Properties();

// number of selected scripts

numSelectedScripts = nitems(proplist);

// pattern for picking out the script name

pat = "\!"en\!" => \!"" + PatArb()>>strScriptName + "\!"";

// build list of script names based on selection

lstScriptNames = {};

for (i=1,i<=numSelectedScripts,i++,
	
	strScriptName = char(proplist[i]);
	success = PatMatch(strScriptName,pat);
	if (success,
		insertinto(lstScriptNames,strScriptName)
	)
	
);

show(lstScriptNames);
-Dave

View solution in original post

8 REPLIES 8
David_Burnham
Super User (Alumni)

Re: In a script, return the selected table scripts as a list

This illustrates how to get the script:

 

dt = open("$SAMPLE_DATA/Big Class.jmp");
scriptNames = dt << get table script names;

// as an example, get the first script
scriptName = scriptNames[1];
script = dt << get table variable(scriptName);

The script comes back as a string.  You can use parse to convert it to executable JSL.

To work with selected scripts try the GetSelectedProperties message.

 

-Dave
jthi
Super User

Re: In a script, return the selected table scripts as a list

<< Get Selected Properties seems to do the trick dt<<Get Selected Properties(<{list of properties}>) 

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt << Select Properties({2, 4});
proplist = dt << Get Selected Properties();
-Jarmo
mvanderaa1
Level IV

Re: In a script, return the selected table scripts as a list

To clarify, the selected scripts are variable. So an answer with hard coded script indices is not what I'm looking for.

 

In other words, I want to first determine WHICH scripts I have selected and then return those.

jthi
Super User

Re: In a script, return the selected table scripts as a list

There are no hard-coded indices. Selection of properties is there for demonstration purposes, but maybe this is more suited for you (it will return Empty() as nothing is selected):

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
proplist = dt << Get Selected Properties();

<< Get Selected Properties won't directly return you with the names of the scripts but you can fairly easily get the names from what it returns by using Arg() for example.

-Jarmo
David_Burnham
Super User (Alumni)

Re: In a script, return the selected table scripts as a list

The information is contained in the results from get selected properties, but you might have to do some work to unpick the information.  Here is an example:

 

// example from the scripting guide

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << Select Properties( {2, 4} );
proplist = dt << Get Selected Properties();

// number of selected scripts

numSelectedScripts = nitems(proplist);

// pattern for picking out the script name

pat = "\!"en\!" => \!"" + PatArb()>>strScriptName + "\!"";

// build list of script names based on selection

lstScriptNames = {};

for (i=1,i<=numSelectedScripts,i++,
	
	strScriptName = char(proplist[i]);
	success = PatMatch(strScriptName,pat);
	if (success,
		insertinto(lstScriptNames,strScriptName)
	)
	
);

show(lstScriptNames);
-Dave
mvanderaa1
Level IV

Re: In a script, return the selected table scripts as a list

That is perfect! Thanks for the detailed solution

mvanderaa1
Level IV

Re: In a script, return the selected table scripts as a list

I see now that in my own datatables the specific extraction you're using to get the English script name is not working. I do not have the multi-language structure that I see in the big class datatable. Is this something that changed recently, or possibly some language setting within JMP that causes it to be different between systems?

 

I've changed your pat variable to be like this to make it work for me.

pat = "\!"" + Pat Arb() >> strScriptName + "\!"";
Craige_Hales
Super User

Re: In a script, return the selected table scripts as a list

The localized sample tables are created by the JMP localization team. Tables you create will not have L10N data. Your solution is fine for non-sample data tables (any table you create.)

 

Keeping only one copy of each sample table makes shipping a new version of JMP every 18 months easier. During the JMP 4 era the sample tables were cloned and translated, and then updated tables had to be re-translated for JMP 5. What a nightmare!

Craige