Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mixed font style within a string var 3

Status
Not open for further replies.

vincer

Programmer
Mar 12, 2002
45
0
0
GB
crystal 8.5
Does anyone know if is possible to format a section of a string in a different font style to the rest?

Eg I want to be able to use <b>bold</b> or <i>italic</i> or colour a section of a string.

I thought I remember reading a couple of years ago that you could embed html style tags <b> etc to do this but I can't seem to get it to work.

The string is basically a hexadecimal dump that I want to highlight key parts within.

Thanks
 
You can use HTML tags in a formula like this:

"<b>"+left({table.string},4)+"</b>" + "<font color = red>"+mid({table.string},5,2)+ "</font color>"+"<i>" + mid({table.string},7)+"</i>"

Then go to format field->paragraph formatting and set the text interpretation to HTML text.

-LB
 
The HTML method has some minor drawbacks, such as a different looking font.

You can also change formatting of strings within a text object, inclusive of formulas dropped into it.

-k
 
Dear SV,

You can reference the font in the html:

The following is from one of the exercises in my Advanced Crystal Class (using variables, loops, and html formatting in a formula):

whileprintingrecords;
local numbervar i;
numbervar delimit;
stringvar Graphic;

delimit := iif(isnull(count({Incident.Incident #}, {Clients.Client ID})), 0, count({Incident.Incident #}, {Clients.Client ID}));

for i :=1 to delimit
do
Graphic := Graphic + '(';

if delimit = 0
then
'No Incidents'
else
'<pre><font face = wingdings SIZE= 3>' &
Graphic & '</font>' & ' Total Incidents: ' & count({Incident.Incident #}, {Clients.Client ID}) & '</pre>';

The result is a string with the number of phones (the '(' in wingdings) representing the number of calls for a client along with text that indicates the same concatenated.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
I agree, Ro, the problem is you'll note slight shifting for HTML mixed with other fonts.

Nice code though, thanks!

-k
 
Dear SV,

Thanks,

The students really like the exercise ... they have a lot of fun changing the character to get different icons...

The exercise isn't complete without the reset formula:

//Reset Graphic
EvaluateAfter({@loop}); //the name of the original formula
stringvar graphic := '';
graphic
//

Place on the line with the original formula.

regards,

ro

Rosemary Lieberman
rosemary-at-microflo.com, Microflo provides expert consulting on MagicTSD and Crystal Reports.

You will get answers more quickly if you read this before posting: faq149-3762
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top