Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Displaying values from split function Post Reply Post New Topic
Author Message
DiSi
Newbie
Newbie
Avatar

Joined: 25 Jun 2011
Online Status: Offline
Posts: 4
Quote DiSi Replybullet Topic: Displaying values from split function
     Posted: 17 Oct 2011 at 1:26am
I have a field which stores 1 or 2 IDs.
 
I am trying to separate them out by using the Split function.
 
But I am not able to print the  ID values.
 
here is my code:

If Count (Split ({Command.d},',' )) = 1 then Right({Command.id}, 11)
else
Right((Split ({Command.id},',' )[1]),11);
Right((Split ({Command.id},',' )[-1]),11);
 
it only prints the second value. I need to print both. The 2 IDs are then used to pull out data from another database. Can someone please point out where am I going wrong?
 
I am using the Right function to remove some char at the beginning of the ID.
 
I also tried:
 
stringvar array eid := (Split ({Command.id},',' ));
 numbervar length := count(eid);
 numbervar x;
 
for x := 1 to length do eid[x]
 
the above code only Print 'True'
 
Help!!!
 
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 18 Oct 2011 at 3:46am
seems like you doing a lot work and not really using what you are doing.
 
Why not try this:
if instr({Command.id}, ",") > 0 then
  right({Command.id}, 11)
else
  {Command.id}
 
 
if you really want to use split, I would something like:  (i am not array expert but...)
local stringvar array com := Split({command.id});
if count(com) = 1 then
  com[1];
else
  com[2];
 
 
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