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
David_Burnham
Super User (Alumni)

Can I Post JSL Code

Get DOE Factor Names = Function({table},{Default Local},
	
	lstFactors = {};
	dt = Open(table);
	For (i=1,i<=NCols(dt),i++,
		col = Column(dt,i);
		colName = col << Get Name;
		changes = col << Get Property("Factor Changes");
		If (!IsEmpty(changes),
			InsertInto(lstFactors,colName)
		);
	);
	Close(dt,NoSave);
	Return(lstFactors);
	
);

The "insert code" icon seems to do its job. There is also a link to a "jsl syntax highlighter" but I hot lost with that one.
-Dave
1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Can I Post JSL Code

@stan_koprowski is right. The icon for the insert JSL Code button is missing but the functionality still works.

 

Click the gap between the insert code and insert link buttons and you'll get a dialog where you can paste your JSL code. It will appear unformatted until you post it but then, just like Dorothy landing in Oz, everything will be in color. 

 

Here's an example:

 

/*
TIMING CHART CREATOR
jay holavarri 10-13-2016

Requires a table with the columns Component, Start, End.
*/
Names Default to Here(1);
dt=current datatable();
maxTime = ColMax(:End);
Summarize(dt, compList = By(:Component));

dt2 = New Table("Timing Chart");
New Column("Component_", Character);
colTime = New Column("Time (ms)");
New Column("Bit Status");

Current Data Table(dt);

catListAll = {};
timeIndexAll = [];
timeIndex0 = Index(0, maxTime, 10);
bitMatrix = [];

//Loop for ON time of each component
For(i=1, i<=N Rows(dt), i++, 
	timeIndex = Index(:Start[i],:End[i],10);
	timeRows = N Cols(timeIndex);
	catString = Repeat(:Component[i] || ",", timeRows);
	catList = Words(catString, ","); 
	
	InsertInto(catListAll, catList);
	timeIndexAll = Concat(timeIndexAll, timeIndex); 
	
	bitMatrix ||= J(1, timeRows, 1); 
	
);


//Loop for OFF time of each component. Note that it puts a 0 for every available time,
//and the 1's appear in the chart by using the Max function in Graph Builder
For(i=1, i<= N Items(compList), i++,
	timeRows0 = N Cols(timeIndex0);
	catString0 = Repeat(compList[i] || ",", timeRows0);
	catList0 = Words(catString0, ","); 
	
	InsertInto(catListAll, catList0);
	timeIndexAll = Concat(timeIndexAll, timeIndex0); 
	
	bitMatrix ||= J(1, timeRows0, 0);
);

//Write to the datatable
dt2:Component_ << Set Values(catListAll);
colTime << Set Values(timeIndexAll);
dt2:bitStatus << Set Values(bitMatrix);


dt2 << Graph Builder(
	Variables( X( :Name( "Time (ms)" ) ), Y( :Bit Status ), Group Y( :Component_ ) ),
	Elements( Line( X, Y, Legend( 25 ), Summary Statistic( "Max" ) ) )
);
-Jeff

View solution in original post

5 REPLIES 5
pmroz
Super User

Re: Can I Post JSL Code

Here's code posted the "usual" way (copy/paste to MS-Word, and then to here).  Loses all formatting:

 

// This is a comment

a = 123;

for (k = 1, k <= 99, k++,

     m = k^2;

);

 

This is code posted with the insert code button. Loses syntax colorization.

// This is a comment
a = 123;
for (k = 1, k <= 99, k++,
	m = k^2;
);

 

David_Burnham
Super User (Alumni)

Re: Can I Post JSL Code

(using reply button)

So I'm glad we don't have to resort to the usual method of cut & paste via MS-Word, but it would be nice if that still worked

-Dave
David_Burnham
Super User (Alumni)

Re: Can I Post JSL Code

(using the quick reply button)

but maintaining the colour formatting would be really helpful. Or put another way, having a discussion forum that is so heavily focused on the scripting language, needs to be code-friendly
-Dave
stan_koprowski
Community Manager Community Manager

Re: Can I Post JSL Code

Yes the JSL syntax highlighter seems to be on vacation at the moment.

Normally it would appear between the insert code icon and the insert link icon.

 

 

Jeff_Perkinson
Community Manager Community Manager

Re: Can I Post JSL Code

@stan_koprowski is right. The icon for the insert JSL Code button is missing but the functionality still works.

 

Click the gap between the insert code and insert link buttons and you'll get a dialog where you can paste your JSL code. It will appear unformatted until you post it but then, just like Dorothy landing in Oz, everything will be in color. 

 

Here's an example:

 

/*
TIMING CHART CREATOR
jay holavarri 10-13-2016

Requires a table with the columns Component, Start, End.
*/
Names Default to Here(1);
dt=current datatable();
maxTime = ColMax(:End);
Summarize(dt, compList = By(:Component));

dt2 = New Table("Timing Chart");
New Column("Component_", Character);
colTime = New Column("Time (ms)");
New Column("Bit Status");

Current Data Table(dt);

catListAll = {};
timeIndexAll = [];
timeIndex0 = Index(0, maxTime, 10);
bitMatrix = [];

//Loop for ON time of each component
For(i=1, i<=N Rows(dt), i++, 
	timeIndex = Index(:Start[i],:End[i],10);
	timeRows = N Cols(timeIndex);
	catString = Repeat(:Component[i] || ",", timeRows);
	catList = Words(catString, ","); 
	
	InsertInto(catListAll, catList);
	timeIndexAll = Concat(timeIndexAll, timeIndex); 
	
	bitMatrix ||= J(1, timeRows, 1); 
	
);


//Loop for OFF time of each component. Note that it puts a 0 for every available time,
//and the 1's appear in the chart by using the Max function in Graph Builder
For(i=1, i<= N Items(compList), i++,
	timeRows0 = N Cols(timeIndex0);
	catString0 = Repeat(compList[i] || ",", timeRows0);
	catList0 = Words(catString0, ","); 
	
	InsertInto(catListAll, catList0);
	timeIndexAll = Concat(timeIndexAll, timeIndex0); 
	
	bitMatrix ||= J(1, timeRows0, 0);
);

//Write to the datatable
dt2:Component_ << Set Values(catListAll);
colTime << Set Values(timeIndexAll);
dt2:bitStatus << Set Values(bitMatrix);


dt2 << Graph Builder(
	Variables( X( :Name( "Time (ms)" ) ), Y( :Bit Status ), Group Y( :Component_ ) ),
	Elements( Line( X, Y, Legend( 25 ), Summary Statistic( "Max" ) ) )
);
-Jeff