Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Split String Post Reply Post New Topic
Author Message
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Topic: Split String
     Posted: 13 Jun 2011 at 4:25am
Hi
 
I am splitting a string of text at a certain character - which works ok.
However if the character doesn't exist in the string then the report errors
 
Is there a way that I can seach the string for the character first?
 
I'm using Crystal XI
 
Thanks
brockloch
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 13 Jun 2011 at 5:20am
try this, not sure if it is what you are looking for but it may work
 
substitut file name for your field or formula
 
Filename[instrrev(Filename,'\')+1 to length(Filename)];
sharona
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 13 Jun 2011 at 6:49am
Thanks I'll try that tonight and let you know the outcome
brockloch
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 13 Jun 2011 at 1:04pm

It didn't work quite as I expected but you gave me enough clues to get it working the way I wanted, thanks again.

brockloch
IP IP Logged
sharona
Senior Member
Senior Member
Avatar

Joined: 16 Oct 2008
Location: United States
Online Status: Offline
Posts: 255
Quote sharona Replybullet Posted: 15 Jun 2011 at 3:01am

try this

Split({Summary_W19.Staff}, "/")[1]
sharona
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 15 Jun 2011 at 3:58am
to check if a character exists
instr({table.field}, "string being looked for")
 
if > 0 then it exists, =0 it doesn't
 
instrrev() starts at the end of the string and looks back....so if you wanted the filename in directory path, you would want to use that as it would find the last "\".
 
HTH
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 15 Jun 2011 at 4:30am
Thanks Again
brockloch
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