cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
mng1
Level I

Adding color text in a If() JSL

Hi,

I am writing a JSL Script and not sure how to add color text in this If() code. I want to add green color indicate for "Ideal" and red color for "Not Ideal".

 

If(P <= 0.5 & C > 0.8, "Ideal",
P > 0.5 & C < 0.8, "Not Ideal",
);

 

Thanks!

4 REPLIES 4
txnelson
Super User

Re: Adding color text in a If() JSL

Where is the "Ideal" or ""Not Ideal" going to be displayed?  In a data table, a report, a dialog box?

Jim
mng1
Level I

Re: Adding color text in a If() JSL

Hi Jim,

Thanks for replying back!

 

Here is a simplified version of my code. The "Ideal" or ""Not Ideal" is going to be displayed in a dialog box.

 

 

P = 0.4

M = If(
    P <= 0.5 & C > 0.8, "Ideal",
    P > 0.5 & C < 0.8, "Not Ideal",

);

M_Output << set text( Char( M ) );
),
Outline Box( "Results",
Panel Box( "Message",
Lineup Box( N Col( 2 ),
Text Box( "Output: " ),
M_Output = Text Box(),
)

),

 

 

Maria

 

txnelson
Super User

Re: Adding color text in a If() JSL

You will need to use Markup notation to change the text color.

See the Scripting Index

     Text Box=>Markup

Here is an example from the Scripting Index entry

Names Default To Here( 1 );
win = New Window( "Example", fontobj = text = Text Box( "Example Text" ) );
text << setText(
	"This is <font color='Blue'>blue</font> text. This is a <background color='yellow'>yellow</background> background. This is <font color='#0000ff'><background color='0xffff00'>blue text on a yellow background</background></font>."
);
text << markup;
Jim
pmroz
Super User

Re: Adding color text in a If() JSL

If you want the entire string to be one color you can use << text color("color").

nw = new window("Test Colors",
	r = text box("Red Color", << text color("red")),
	b = text box("Blue Color", << text color("blue"))
);

pmroz_0-1680707825510.png

The scripting index is your friend here.  

Recommended Articles