Spliting a text string...how?
Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17377
Printed Date: 27 May 2024 at 2:08am
Topic: Spliting a text string...how?
Posted By: munchiet
Subject: Spliting a text string...how?
Date 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?
|
Replies:
Posted By: SonoItaliano
Date 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)
|
Posted By: munchiet
Date 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"
|
Posted By: z9962
Date Posted: 21 Aug 2012 at 4:29am
stringvar array MYARRAY:= Split ( mailto:%7b@String - {@String }, " - "); MYARRAY [2]
|
Posted By: munchiet
Date 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
|
|