Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Trouble removing } character Post Reply Post New Topic
Author Message
mileskb
Newbie
Newbie


Joined: 02 Dec 2010
Online Status: Offline
Posts: 6
Quote mileskb Replybullet Topic: Trouble removing } character
     Posted: 02 Dec 2010 at 11:10pm
I have this formula to tidy up my email addresses that are saved with the SMTP info... such as...    SMTP{the@email.com}  should come out.. the@email.com.

stringvar em := if isnull({Incident.C_Email}) then '' else {Incident.C_Email};
em := replace(em,'SMTP:{','');
em := replace(em,'}','');
 ' EMail Address: ' + em


For some reason, the } character in the replace causes the output to be blank.
I even tried this just for an experiment and it worked fine

em := trim(em);
em := replace(em,'SMTP:','');
em := replace(em,'{','');

But if I replace { with } in the last one the output is blank. So I even tried
this...

em := replace(em,chr(123),''); works

em := replace(em,chr(125),''); causes output to be blank

Huh ???? Is this a bug ?


IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 03 Dec 2010 at 3:09am
I wasn't able to reproduce the same outcome with my own data.

There is no special datatype for e-mails right? Just strings...
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Dec 2010 at 4:03am
well, what if you try:
local numbervar iBrace := instr(em, '}');
if iBrace > 0 then
 em := left(em, iBrace - 1) + mid(em, iBrace + 1);
 
em
 
 
it's not as simple/clean, but if it works.
 
All the comes to mind is that Crystal uses {} for many things and perhaps replacing it messes up things behind the scenes, since replace will replace all occurrances, not just the first one.
 
It's a thought, but I have absolutely no evidence/knowledge that this is occurring.
 
HTH
IP IP Logged
mileskb
Newbie
Newbie


Joined: 02 Dec 2010
Online Status: Offline
Posts: 6
Quote mileskb Replybullet Posted: 03 Dec 2010 at 6:51am
I finally landed on the following that works because the problem was NOT that it was outputing a blank but rather the source was actually more than I thought it was...  the standard format is
SMTP{name@place.com}name@place.com  I just wasn't seeing the full output...  

sooooo

if Length(em) > 0 then local numbervar iBrace := instr(em, '}');
if iBrace > 0 then em := mid(em, iBrace + 1);

em

thanks... 




Originally posted by lockwelle

well, what if you try:
local numbervar iBrace := instr(em, '}');
if iBrace > 0 then
 em := left(em, iBrace - 1) + mid(em, iBrace + 1);
 
em
 
 
it's not as simple/clean, but if it works.
 
All the comes to mind is that Crystal uses {} for many things and perhaps replacing it messes up things behind the scenes, since replace will replace all occurrances, not just the first one.
 
It's a thought, but I have absolutely no evidence/knowledge that this is occurring.
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum