cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
FN
FN
Level VI

Column() vs As Column() vs datable:column vs dt:As name("column")

JSL has several ways to refer to columns. Let's open a data table first.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Bands data.jmp" );

Now we create a table script that has something like this.

dt = current data table();

print(dt:timestamp == Column(dt, "timestamp")); 
// 0

print(Column(dt, "timestamp")==As Column(dt, "timestamp")); 
//0

In automated scripts (for example, a graph), when a user changes the name of a column, it seems to adapt the script to the new column name. This failed in custom JSL, with something like Index() appearing.

 

How one would use all of these methods to make a JSL script robust to column name changes?

 

Regards,

 

13 REPLIES 13
FN
FN
Level VI

Re: Column() vs As Column() vs datable:column vs dt:As name("column")

Could you please include in your answer a reference that explains this bit?

"As Column() "accesses" a column (what this means depends on the case...)."

 

 

 

 

 

jthi
Super User

Re: Column() vs As Column() vs datable:column vs dt:As name("column")

Best reference (outside of my own experience and lots and lots of trial and error) is from scripting index:

jthi_0-1662735794267.png

jthi_1-1662735806153.png

 

Help pages is other place Column(<dt>, "name", "formatted")  and As Column(name). This also has some information  Scripting Guide > JSL Building Blocks > Rules for Name Resolution > Frequently Asked Questions abou... and  Scripting Guide > Data Tables > Columns > Send Messages to Data Column Objects also Iterate on Rows in a Table , so basically the documentation (especially Scripting Guide).

-Jarmo
hogi
Level XII

Re: Column() vs As Column() vs datable:column vs dt:As name("column")

Nice video tutorial about the differences between column() and as column():

 

(starting @ 5:18 min)

with the example

dt << Select Where( Column( colName )[Row()] == 14 );
dt << Select Where( As Column( colName ) == 14 );


Concerning 
How one would use all of these methods to make a JSL script robust to column name changes?

 

How about an error handling feature which catches missing-column-events after column name changes - with an option to auto-fix the code.

The idea:

In case of a missing column, instead of showing an error message, JMP could open a window with a column list to pick the correct one.

Then the execution of the code could continue to run - and the source code could be fixed automatically.

 

hogi
Level XII

Re: Column() vs As Column() vs datable:column vs dt:As name("column")

Here is the wish
catch "missing column" error and provide a selection menu 

 

Should be easy to implement now for JSL Editor - as a similar functionality was just introduced with Jmp 17's new Workflow builder:
https://community.jmp.com/t5/JMP-Wish-List/catch-quot-missing-column-quot-error-and-provide-a-select...