Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse a string into fields 1

Status
Not open for further replies.

pgmr

Programmer
Dec 30, 2001
51
US


Hi,
CR 8.5, SQL 7.0
I need to parse a string of fields seperated by commas
example (Hong Kong,Russia,USA...) the fields would be

Country1=Hong Kong

Country2=Russia
Country3=USA

Etc…

Thanks in advance


 
If the comma separated string is a database field, you can use the 'join' function to place each element into an array. Steve Phillips, Crystal Consultant
 
Have a look at the 'join' and 'split' functions - they may help you. Steve Phillips, Crystal Consultant
 
Thanks for the reply,
I am using the code below but am only getting the first field Hong Kong

WhileReadingRecords;
stringVar array Country:= split("{@CountryParm}",",");
Country[1] ;
 
That's because Country[1] is referring to the 1st array location only. Similarly Country[2] would show "Russia".

Perhaps you want something like:

WhileReadingRecords;
stringVar array Country:= split("{@CountryParm}",",");

NumberVar i;
StringVar myText;

for i = 1 to UBound(Country)
myText := myText & "Country " & i & ": " & Country & chr(13);
next i;

myText Steve Phillips, Crystal Consultant
 
I really appreciate your help!!
Thank You

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top