set textstyle bold

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
link76
Posts: 99
Joined: Fri Nov 04, 2011 1:52 pm

set textstyle bold

Post by link76 » Thu Apr 21, 2016 8:40 am

I would like to set textstyle "bold" of all words after the character ":"

example my field:

Lorem Ipsum: is simply dummy text

Film:
The point
The point1
The point2
The point3

Sound: exmple1

thank you

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: set textstyle bold

Post by dunbarx » Thu Apr 21, 2016 3:28 pm

This is a good example of brute-force coding. Put your text into fld 1. Make a fld 2. Put this into a button:

Code: Select all

on mouseUp
   put fld 1 into fld 2
   repeat with y = 1 to the number of lines of fld 2
      switch
         case char -1 of word 1 of line y of fld 2 = ":" and the number of words of line y of fld 2 = 1
            put "bold" into tStyle
            break
         case char -1 of word 1 of line y of fld 2 = ":" and the number of words of line y of fld 2 > 1
            set the textStyle of word 2 to (the number of words of line y of fld 2) of line y of fld 2 to "bold"
            break
         case line y of fld 2 <> ""
            set the textStyle of line y of fld 2 to tStyle
            break
      end switch      
   end repeat
end mouseUp
I recommend testing this...

Craig Newman

Post Reply