Choose Language Hide Translation Bar
Highlighted
ThomasZatValcon
New Contributor

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?

6 REPLIES 6
vince_faller
Super User

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
Highlighted
ThomasZatValcon
New Contributor

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 ) ) )}
);
0 Kudos
Highlighted
ThomasZatValcon
New Contributor

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. 

0 Kudos
Highlighted
vince_faller
Super User

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
0 Kudos
Highlighted
ThomasZatValcon
New Contributor

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.

0 Kudos
Highlighted
Craige_Hales
Staff (Retired)

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
0 Kudos