Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Split string with X values Post Reply Post New Topic
Author Message
nilsbinnemans
Newbie
Newbie


Joined: 13 May 2012
Online Status: Offline
Posts: 1
Quote nilsbinnemans Replybullet Topic: Split string with X values
     Posted: 13 May 2012 at 10:25pm
Hi,

I need to split a string into multiple fields. The string contains multiple values and looks like this:
{String}: Value 1, Value 2, Value 3, ...
The maximum number of values is pretty much unlimited but I had never had more than 5 values up to now.
How can I split it looking like this:
Field 1: Value 1
Field 2: Value 2
Field 3: Value 3

Any ideas?

Thank you!
Nils

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 14 May 2012 at 3:15am
you can use Split() to split the string into an array, then you can write formulas to display the values.  something like:
 
shared stringvar array main := split({table.field}, ",")
 
I would probably put this in a section above where you are going to display the values...like detail a, and then do the display in detail b.
 
display:
shared stringvar array main;
if ubound(main) <= thisIndex then
  main[thisIndex]
else
  ""
 
 
thisIndex would be manually coded, and would refer to each index/field.
 
This biggest issue is that CR doesn't like a dynamic number of columns...it sees a schema of x columns and won't let you code against schema columns that don't exist....
 
HTH
 
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