cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
ThomasZatValcon
Level III

Setting link ID in jsl seems not to work - what is wrong?

I am trying to set a link ID in JSL, but when setting it in JSL, the link ID seems to be set in the table like it should, but the link reference in the other table that is supposed to reference it does not work.

If I remove the link ID and set it by right clicking on the link ID, everything works fine.

I use this:

 

dfps:name( "Country" ) << Set Property( "Link ID", 1 );

 

Can't see what is wrong with this. Am I missing some refresh operation to make it work? Any suggestions?

12 REPLIES 12
vince_faller
Super User (Alumni)

Re: Setting link ID in jsl seems not to work - what is wrong?

Are you saying that you're setting the reference before the ID?  Not sure how you'd do that, but this works fine for me.  

 

Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
// creating a unique ID
dt << New Column("_Row", << Set Each Value(Row()));
// subsetting just so I have something to link
dt_sub =  dt << Subset(
	Selected Rows( 0 ),
	Rows( [1, 2, 3, 4, 5] ),
	columns( :_Row )
);


Column(dt, "_Row") << Set Property( "Link ID", 1 );
Column(dt_sub, "_Row") << Set Property( "Link Reference",
	Reference Table( "$SAMPLE_DATA\Big Class.jmp" )
);
Vince Faller - Predictum
ThomasZatValcon
Level III

Re: Setting link ID in jsl seems not to work - what is wrong?

Thanks. I modified your code to represent better what is going on (tables are only in memory) to represent what is going on more closely and expected it to fail, but it actually works. Still haven't figured out what makes my other code fail, but will update this thread if I find out.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
// creating a unique ID
dt2 = dt << subset( all rows, all columns );

dt2 << New Column( "_Row", <<Set Each Value( Row() ) );
// subsetting just so I have something to link
dt_sub = dt2 << Subset( Selected Rows( 0 ), Rows( [1, 2, 3, 4, 5] ), all rows );


Column( dt2, "_Row" ) << Set Property( "Link ID", 1 );
Column( dt_sub, "_Row" ) << Set Property(
	"Link Reference",
	{Reference Table( dt2 ),
	Options( Row States Synchronization with Referenced Table( Accept( 1 ), Row States( Select, Exclude, Hide, Marker ) ) )}
);
ThomasZatValcon
Level III

Re: Setting link ID in jsl seems not to work - what is wrong?

Still haven't figured it out, but I am getting some truly strange behavior here:

 

Having the same code in two windows:

ThomasZatValcon_0-1585340549523.png

When I run the code in the left window, notice the icon with the two keys is grey (it doesn't work):

ThomasZatValcon_3-1585340647372.png

 

When I run the same two lines in the right window it works:

ThomasZatValcon_4-1585340679776.png

 

The code in the left window is where the jsl was created. All the code is just running in the global namespace. I even tried with names default to here(1) and get the same behavior which surprised me, as I expected not to be able to reference the table variables from another script window. 

vince_faller
Super User (Alumni)

Re: Setting link ID in jsl seems not to work - what is wrong?

Are they supposed to be the same? Because the two tables have different number of columns.
Have you looked that `dfps` is right? Or tried using `Column(dt, "Country")`?
Vince Faller - Predictum
ThomasZatValcon
Level III

Re: Setting link ID in jsl seems not to work - what is wrong?

It's two different tables. The one to the left is the table with the ID, the left table is the table with the reference.

 

Yes, I tried column(dt...) and dt:name()... referencing.

 

I also tried to put the code that works (when it is run from a separate script window) into a separate file and include it. Didn't work either. I tried to put it into an expr() and evaluate it. Also didn't help.

 

But the two lines of code work if I create a separate script window and run them from there, which is unexpected.

Craige_Hales
Super User

Re: Setting link ID in jsl seems not to work - what is wrong?

Try saving the tables before linking and see if your results become consistent. I'm not sure how the links work internally, but it might depend on a file name being available.

Craige
Robbb
Level III

Re: Setting link ID in jsl seems not to work - what is wrong?

Hi everybody,

 

I have got the very same problem with linking two tables via script.

It behaves exactly as @ThomasZatValcon described.

After doing it manually through clicking I then copied the two lines of code from the log.

Then it depends where they are inserted. If I insert them in a new script window, the script works. If I insert them in my current script under development (from which the two tables were opened originally) it does not work.
Are there some new insights into this issue?

 

Cheers
Robert

 

Btw. In the meantime I found a related thread. The workaround is to save the datatables first, but this is not always convenient.
https://community.jmp.com/t5/Discussions/Virtual-Join-via-JSL-does-not-work/td-p/360675

 

Robbb
Level III

Re: Setting link ID in jsl seems not to work - what is wrong?

I discovered somethink new:

 

If the JSL script that I am executing is not saved and was never saved before (so if source code was written or copied into a brand new opened scripting window), linking two unsaved data tables works like a charm.

If it is saved or if it is an existing script that was just modified and not saved, it is not working.

 

 

Craige_Hales
Super User

Re: Setting link ID in jsl seems not to work - what is wrong?

@Robbb   I just sent a note to the dev team; I've not tested your theory, but I'm hoping you've identified a cause of the unpredictability. It is believable because there is something different about the current directory when a script isn't saved, and the tables depend on something related to that, maybe.

Craige