cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
mostarr
Level IV

Referencing a Column in JSL

I'm continually astounded by how much basic information on JSL is missing from tutorials and internet searches. I'm not sure how one is expected to learn the basics of this language without poring through massive quantities of addon unnecessary information, and then fail in the end to find what is needed anyway. I guess that's why the Discussion forums are available as a resource.

 

I'm trying to simply reference a column given a data table in JSL.

dt = Open("filepath.jsl");
col = dt:"Column Title/Name";

when I Write() the col nothing shows up, implying the reference doesn't reference. The column is clearly populated with data, it's not empty, I checked. Stupid error to make but I've got that covered. Having said that, I don't know what's wrong. I thought this was a pretty basic thing in JSL but I'm continuously finding that these "very basic things in JSL" fall through and cost precious minutes to hours of troubleshooting when I could be working on the logic of my code. I'm inclined to file a complaint with my manager about our use of this language and suggest potentially switching to something more logical and well-designed for programming (obviously JSL is for statistical use, not really for programming logic), like Python.

 

<sigh>. Thank you for your any assistance.

3 REPLIES 3
Thierry_S
Super User

Re: Referencing a Column in JSL

The correct syntax is : col = Column (dt, "Name")
Thierry R. Sornasse
jthi
Super User

Re: Referencing a Column in JSL

If I remember correctly using dt:"colname" (same as you would use As Column()) will get you direct access to current value of the current Row() of the column named "colname" in datatable with reference dt. To get a reference to column you can use Column(dt, "colname") as @Thierry_S said.

 

Names Default To Here(1);

dt = New Table("Untitled",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("Column Title/Name",
		Character,
		"Nominal",
		Set Values({"a1", "b2", "c3", "d4", ""})
	)
);
For each row(dt,
	col = dt:"Column Title/Name";
	Show(col);	
);

Row() = 1;
col = AsColumn(dt, "Column Title/Name");
Show(col);

col = Column(dt, "Column Title/Name");
Show(col);

I'm definitely not saying that JSL documentation is best, but it does have quite a bit of material (and great community and support with email). For starters these are good sources:

JMP15 - Scripting Guide 

JMP Help 

Scripting Index directly from JMP

 

If there is something missing or unclear in JMP Help or Scripting Index, I'm fairly sure JMP would be happy to improve them.

 

@Jeff_Perkinson 

-Jarmo
Jeff_Perkinson
Community Manager Community Manager

Re: Referencing a Column in JSL

[NB: I had written most of this before @jthi replied and said much the same thing.]

 

First, if you haven't read (at least the first few chapters) of the JMP Scripting Guide (PDF, if preferred) you really should.

 

JMP is a scripting language, not a programming language. It's tied very closely to the user interface for JMP and meant to allow for automation of JMP tasks. Trying to think of it the same way you think of Python or other languages which are not controlling a user interface will lead to frustration.

I'm trying to simply reference a column given a data table in JSL.

Your question is an example of that. The concept of "referenc[ing] a column" is complicated because a "column" could mean different things in different contexts (e.g., a platform call, manipulating the properties of a column, a column formula).

 

So, what did you what "col" to contain in your example? The data contained in the column? The value of a particular row of that column?

 

Or, asked differently? Where did you want to use "col" after you got it set to whatever you wanted it to contain? In a platform call (e.g., Distribution(Y(col))? Or somewhere else? 

 

-Jeff