Topic Options
#39551 - 05/14/12 06:01 AM Bold text within a custom variable
DeanB Offline
OL Toddler

Registered: 04/05/12
Posts: 37
Loc: Harrogate, UK
Hi Forum,

I have an IF statement which will present a paragraph of text within a larger text box depending on the data flag.

However within this variable is a telephone number which my client would like in BOLD. Is there a way of doing something along the lines of <b>0123456 789<b/> within my expression?

Top
#39552 - 05/14/12 09:31 AM Re: Bold text within a custom variable [Re: DeanB]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4458
Loc: Objectif Lune Montreal
Dean,

Not natively, you would have to make a custom PressTalk object to handle this.

I've done a simple code to do this before, so I'm going to post it here. Here's the code:

Code:
define(&i, integer, 0)
define(&j, integer, 0)
define(&s, string, '')
define(&st, string, '')

% Put your variable text in the &s variable.
&s := @(1,1,200)
&st := ''

for(&i,1,1,length(&s))
  % Check if we enter a tag.
  if(mid(&s, &i, 1) = '<')
    &j := &i
    &st := ''
    repeat
      &st := &st + mid(&s, &j, 1)
      &j := &j + 1
    until(mid(&s, &j, 1) = '>')
    &st := &st + '>'
    &i := &j + 1
  endif()

  % Hanle the different styles.
  if((&st = '</b>') or (&st = '</i>'))
    setstyleext(&Style1, 12, 0, [100], 100)
  endif()
  if(&st = '<b>')
    setstyleext(&Style1.b, 12, 0, [100], 100)
  endif()
  if(&st = '<i>')
    setstyleext(&Style1.i, 12, 0, [100], 100)
  endif()

  % Show the text.
  show(mid(&s, &i, 1))

  % Handle moving to next line if the line is longer
  % than a certain value(by default 4.0 inches long,
  % replace it with whatever you need).
  if((mid(&s, &i, 1) = ' ') and (&current.x >= 4.0))
    crlf()
  endif()
endfor()



This is to be placed in a PressTalk object. Basically, it will display the string assigned to "&s", but you can have the tags <b> or <i> in your text, for bolding and italic respectively. You close them using </b> and </i>. It will display the text word by word, and move to the next line after reaching a certain length, which you can adjust. It will check for this after displaying entire words, so no worry about it cutting off a word to move to the next line.

Hope that helps!

Regards,
RaphaŽl Lalonde Lefebvre

Top
#39571 - 05/15/12 03:55 AM Re: Bold text within a custom variable [Re: Raphael Lalonde Lefebvre]
DeanB Offline
OL Toddler

Registered: 04/05/12
Posts: 37
Loc: Harrogate, UK
Hi Raphael,

Thanks for your help; the above code makes sense, however my variable text is not in a data field, but typed to appear when the data flag is either Y or N:

=IF(Field('BUYOUT_FLAG',1)='N','If you'+Char(146)+'ve got any questions or would like more information please contact Barnett Waddingham LLP who administer the scheme on our behalf and will be happy to help. Please remember to quote your policy number which can be found in the '+Char(146)+'please quote'+Char(146)+' section on the right.','')

I would like 'Barnett Waddington LLP' in Bold in this instance.

Alternatively, is it possible to put all this text in a box, format it as I like and then enter a command that pulls in the text from this box i.e. =IF(Field('BUYOUT_FLAG',1)='N',[text4])

If that makes sense?

Top