Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Spliting a text string...how? Post Reply Post New Topic
Author Message
munchiet
Newbie
Newbie


Joined: 21 Aug 2012
Location: United States
Online Status: Offline
Posts: 3
Quote munchiet Replybullet Topic: Spliting a text string...how?
    Posted: 21 Aug 2012 at 3:41am
Hi - I'm new to crystal reports.  I want to create a formula that will split a text string into 4

The text string field has this format:

date - supplier - mfg - description

example: 04/12/2012 - Costco - Cisco - maintenance support

I want to split the text where it is divided by " - "

so the end result would be a formula for each of the 4 items below.

Formula 1's results: 04/12/2012
Formula 2's results: Costco
Formula 3's results: Cisco
Formula 4's results: maintenance support

how do I do this?
IP IP Logged
SonoItaliano
Newbie
Newbie


Joined: 02 Aug 2012
Location: United States
Online Status: Offline
Posts: 9
Quote SonoItaliano Replybullet Posted: 21 Aug 2012 at 3:48am
This off the top of my head; test and adjust as necessary.

Create formula named SplitString:

   Split ({your_input_text_string}, " - ")

In your report, display the individual fields as:

    SplitString(1)    SplitString(2)    SplitString(3)    SplitString(4)

IP IP Logged
munchiet
Newbie
Newbie


Joined: 21 Aug 2012
Location: United States
Online Status: Offline
Posts: 3
Quote munchiet Replybullet Posted: 21 Aug 2012 at 4:08am
Thank you SonoItaliano,

When I do that, is displays this error:

"The result of the formula cannot be an array"
IP IP Logged
z9962
Senior Member
Senior Member
Avatar

Joined: 04 Jul 2012
Online Status: Offline
Posts: 161
Quote z9962 Replybullet Posted: 21 Aug 2012 at 4:29am
stringvar array MYARRAY:= Split ({@String}, " - ");
MYARRAY [2]
IP IP Logged
munchiet
Newbie
Newbie


Joined: 21 Aug 2012
Location: United States
Online Status: Offline
Posts: 3
Quote munchiet Replybullet Posted: 21 Aug 2012 at 4:51am
Figured it out....used this formula create the array.  The "" is so that the formula doesn't result in an array.

Formula 1:
whileprintingrecords;
stringvar array values:=Split({field}, "/");
""

Formula 2 (3,4, etc ) used to display each position within the array:
whileprintingrecords;
stringvar array values;
values[1]  //increment for each member
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.015 seconds.