BookmarkSubscribeRSS Feed
Tomsalvo
Calcite | Level 5

This is a really simple question, and I am probably missing something obvious, but using JSL, how do I get a word in the middle of a textbox to appear in bold?

5 REPLIES 5
mrthomas
Calcite | Level 5

With the cursor on top of the text box, right click, then select Font and then Font Style "Bold".

Tomsalvo
Calcite | Level 5

I wrote my question in a hurry and perhaps I was not clear enough.

I am writing a textbox in JSL and want a single word within that to appear in bold:

textbox("blah blah blah blah blah blah");

If I use:

textbox("blah blah blah blah blah blah", set font style("Bold"));

then this makes the whole box bold, when I only want one word in bold.

Is this possible?

DavidQ_R
SAS Employee

Unless there's some way of inserting control characters into the text itself, the only way I can think of approaching it would be to break down the sentence into segments, each of them inside a different text box, and then just string them together something like the following:

tba = text box("   This ", set font style("italic"));

tbb = text box("is a ");

tbc = text box("very ", set font style("bold"));

tbd = text box("tricky question.   ");

nw1 = new window("Demo", hlistbox(tba, tbb, tbc, tbd));

If you don't know how many changes in style you're going to have in advance, you won't know how many text boxes you're going to need, but you could get around that by doing something like this, in which I've also added a border box with lines on all sides around the text:

textlist = {"   This ", "is a ", "very ", "tricky question.   "};

stylelist = {"italic", "", "bold", ""};

hlb = hlistbox();

for(i=1, i<=nItems(textlist), i++,

     hlb << append(textbox(textlist, set font style(stylelist)))

);

nw2 = new window("Demo2", borderbox(hlb, << sides(15)));

Is that of any use?

Tomsalvo
Calcite | Level 5

Thanks - that is really helpful.  I had a sneaking suspicion it was going to be something like that, but I hadn't managed to figure out the 'how'.

SB1
Calcite | Level 5 SB1
Calcite | Level 5

This is a very delayed reply, but I thought I should put it here in case anyone else has a similar question and comes across this thread.

In JMP 11, the textbox() command can accept 3 HTML markups - bold, italic, underlined.

From the scripting index:

win = New Window( "Example", text = Text Box( "Example Text" ) );

text << setText(

    "This is <b>bold</b> text. This is <i>italic</i> text. This is <u>underlined</u> text. This is <b><i><u>bold, italic, underlined</u></i></b> text."

);

text << markup;

Here's a one-line text box script: TB_MyTextBox = text box("My example <b>bold</b> text can also be <i>italicized</i> and <u>underlined</u>, as in <b><i><u>this example</u></i></b>.", <<Markup),

When combining, remember that order of the HTML markups matters. <m1><m2>text</m1></m2> will not work - the markups must be 'closed' in the opposite order they are opened, so </m2></m1>.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4073 views
  • 0 likes
  • 4 in conversation