Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Split Ignore Spaces Post Reply Post New Topic
Author Message
crystalnewb
Newbie
Newbie


Joined: 19 Mar 2013
Online Status: Offline
Posts: 2
Quote crystalnewb Replybullet Topic: Split Ignore Spaces
     Posted: 20 Mar 2013 at 12:45am

The issue I am having is that I am trying to separate a string of text for a part program into drop down boxes etc, I know how to accomplish this however it would appear I am stuck at the first hurdle I require to split the following string there are many with many different outcomes therefore I need a liquid command as opposed to a left Instr ?

::::DATA EXAMPLES::::
 
SCREW,SOCKET CHEESE HEAD,1/4"UNC ,1 1/2",CARBON STEEL,BS4168,GR12.9,BRIGHT
 
BOLT,SHOULDER,1/4"UNC ,1 1/8",CARBON STEEL,BS4168,GR12.9,BLACK
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
Current Formula::
 
stringVar array Names := Split ({@JoinDescript},",");
Names[1]
 
RETURNS:: SCREW
 
stringVar array Names := Split ({@JoinDescript},",");
Names[2]
 
RETURNS:: error 'A subscript must be between 1 and the size of the array'
 
I have managed  the split with the following Formula but still can't seperate out the variables to use to populate drop down boxes for use with parameter fields::
 
stringVar array x := split({@JoinDescript},",");
Local numberVar i;
Local stringVar outputString := "";
For i:=1 to Count(x) do
(
outputString := outputString + x + Chr(10)
);
outputString;
 
RETURNS::
SCREW
SOCKET CHEESE HEAD
1/4"UNC
1 1/2"
CARBON STEEL
BS4168
GR12.9
BRIGHT
 
HELP THANKS IN ADVANCE:-)
IP IP Logged
crystalnewb
Newbie
Newbie


Joined: 19 Mar 2013
Online Status: Offline
Posts: 2
Quote crystalnewb Replybullet Posted: 20 Mar 2013 at 4:06am
A possible solution that works for a minute

stringVar array Names := Split({@JoinDescript},",");
if UBound(Names)>=2 then
Names[2] else "unavailable";
IP IP Logged
iSing
Newbie
Newbie


Joined: 12 Mar 2013
Online Status: Offline
Posts: 22
Quote iSing Replybullet Posted: 20 Mar 2013 at 7:54pm
Hi
 
Here's something I had to use to split a text field which had returns at the end of each line.  I had to split the string into 4 separate strings in order to maniuplate each line separately.  Here's the code I used to extract the third substring. 
 
//1.  Splits the string into substrings at each carriage return - each substring contains a single line of the original string. 
//2.  Only display the third substring, eg the third line of the original string
//3.  replace the line feed at the beginning of this substring with a blank character
//(otherwise detail appears on second line of field)
//4.  trim the left most character of the substring, so that it appears at the top of the field.

//Step 4 BEGIN - trim the leftmost character of the second substring you've created
ServiceRequest := trimleft (
//Step 3 BEGIN - replace the line feed at the beginning of the substring with a blank character
Replace (
//Step 1  BEGIN - If there are more than 3 carriage returns (eg 3 lines or more) split the string into substrings
if ubound(split({fieldname},Chr(13))) >= 3 then
//Step 2 BEGIN & END  - only display the third substring
split({fieldname},Chr(13))[3] else "not recorded"
//Step 1 end
//Step 3 end
, chr(10) ," " )

//Step 4 end
);
 
I used this instead of an array (but it can be turned into one too).
 
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