IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#38811 - 03/15/12 02:45 PM Different font style with in a variable
cpamc Offline
OL User

Registered: 01/03/06
Posts: 85
Loc: Des Moines
We have a variable sentence. If the data says "A" then sentence "A" appears else sentence "B" appears. But sentence "A" reads:
"You could get another discount on your Home and your Auto if you switch."

Since the font style changes within the variable we actual have to make a variable for each section. Then apply the style in design. So for the underline word it have to be a variable by itself. It would be great if you could code the whole sentence in the variable and apply attributes to change the style within the variable.

Top
#38812 - 03/15/12 03:01 PM Re: Different font style with in a variable [Re: cpamc]
Raphael Lalonde Lefebvre Offline
OL Expert

Registered: 10/14/05
Posts: 4956
Loc: Objectif Lune Montreal
cpamc,

You could always add some formatting characters into your variable, and then use a PressTalk Code that parses that string, character by character, and when it encounters a control characterm, it uses "setstyle" commands to apply the font changes.

For example, your variable could contain: "You could get <b>another discount<n> on your Home <u>and</u> your Auto if you switch."

Then you could use a PressTalk Code like this one:

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

&s := @(1,1,200)
&st := ''

for(&i,1,1,length(&s))
  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()

  if((&st = '') or (&st = '<n>'))
    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(mid(&s, &i, 1))
endfor()



This code will parse the string characters by characters, and use setstyleext commands to adjust the style accordingly.

You can take that code, and adapt to your needs. (you'll need to implement underline, amongst other things) In the end, this would allow you to put everything in one variable, and avoid having to create multiple variables.

Regards,
Raphaël Lalonde Lefebvre

Top