Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: How to change text string Post Reply Post New Topic
Author Message
milosplacek
Newbie
Newbie


Joined: 01 Nov 2011
Online Status: Offline
Posts: 3
Quote milosplacek Replybullet Topic: How to change text string
     Posted: 01 Nov 2011 at 12:22am
Hello,
I am using Crystal Reports 2008. I have a Q how to replace/change a text string. I have in database following string (this is just an example, text are of course different) - "de=Guten tag|pl=Dzień dobry|en=Good day|ru=добрый день|es=buen día|cs=Dobrý den". This is few words in few languages and I need to prepare report for each language and for this language get just text in this language, for example in German report will get back "Guten Tag" in English report "Good day", etc. Could you please advise wich function and how to use? Thanks in advance.
IP IP Logged
CircleD
Senior Member
Senior Member
Avatar

Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
Quote CircleD Replybullet Posted: 01 Nov 2011 at 1:18am
If {Table.Field} = ("whatever is in the field") then "Guten Tag"
   else {Table.Field}


Not sure if that's exactly right but it should be close.Someone better at formulas than me will probably be along shortly to either fix it or submit a better solution.
IP IP Logged
milosplacek
Newbie
Newbie


Joined: 01 Nov 2011
Online Status: Offline
Posts: 3
Quote milosplacek Replybullet Posted: 01 Nov 2011 at 1:36am
Thanks but this is not exactly what I am looking for. I have in this field all languages just marked with de=german, en=english, etc. I would like replace a part of this string for example replace "de=*cs=" with "" and in this case will get back only cs language text....
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 01 Nov 2011 at 2:55am
Try something like:

whileprintingrecords;
local stringvar nlanguage:="en="
//This string variable would need to define the language of the report. I'm assuming you may have a parameter for this. If so, replace "en=" with "{?parameter}&"=")//

local stringvar ntext:=mid({table.textstring},instr({table.textstring},nlanguage)+3);

split(ntext, "|")[1];


Please let me know if that works for you.
|< /\ '][' ( )
IP IP Logged
milosplacek
Newbie
Newbie


Joined: 01 Nov 2011
Online Status: Offline
Posts: 3
Quote milosplacek Replybullet Posted: 01 Nov 2011 at 9:42pm
Thanks FrnhtGLI. It looks good but I got back error that the index must be between 1 and size of field and do not know what to do with this...
 
But I found something what works for me:
 
whileprintingrecords;
Stringvar array language:=split({table.textstring},"|");
If (count(language) >=4) Then
language[3]
else ""
 
it works without the error (but do not understand why :-))
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 02 Nov 2011 at 2:00am
Is the field set as an array? That's the only thing I can think of why it wouldn't work. Glad to hear you got something that does work for you though. Cheers!
|< /\ '][' ( )
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