Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Loop question Post Reply Post New Topic
Author Message
sboll
Newbie
Newbie
Avatar

Joined: 15 Nov 2007
Location: United States
Online Status: Offline
Posts: 4
Quote sboll Replybullet Topic: Loop question
     Posted: 04 Sep 2008 at 11:15am
I have a field that concatinates values as it goes through records.
The value it came up with for one example is:
SMITH, JOHN R.0SMITH, JOHN R.0SMITH, JOHN R.0JONES, ROBERT R.00
It is a string of names with a zero separating each name.
The number of characters in the field can change in any given example.
I want the loop to capture the first full name before the zero. In this case it would be:
SMITH, JOHN R.
The name of the field it is pulling from is:
PROV_NAME_DISPLAY
Any help would be much appreciated!
Thanks
Steve Boll
IP IP Logged
JohnT
Groupie
Groupie
Avatar

Joined: 20 Jan 2008
Online Status: Offline
Posts: 92
Quote JohnT Replybullet Posted: 24 Sep 2008 at 8:25am
Is the 0 the last character of PROV_NAME_DISPLAY ?  Can you explain a bit more what you are doing.  It sounds like you concatenate the names and then you want to take each name out of the string.  If that is the case, why do you need to concatenate them ?

Edited by JohnT - 24 Sep 2008 at 8:30am
IP IP Logged
sboll
Newbie
Newbie
Avatar

Joined: 15 Nov 2007
Location: United States
Online Status: Offline
Posts: 4
Quote sboll Replybullet Posted: 24 Sep 2008 at 8:51am
I only wanted the last instance of a name as it concatenated each name from each record in a group. The problem was that the last record in the group might not have a name in it.
But I used instr({@PROV_NAME_DISPLAY},"0") that gave me the length up to the first zero. Then just used Left and subtracted 1 for the zero.
Thanks
Steve
IP IP Logged
ezeney
Newbie
Newbie
Avatar

Joined: 05 Sep 2008
Location: United States
Online Status: Offline
Posts: 14
Quote ezeney Replybullet Posted: 30 Sep 2008 at 8:16pm
Create a Formula Field with codes something like this
 
StringVar NewString := {@PROV_NAME_DISPLAY};
StringVar Name = "";
NumberVar index := 1;

while index < Length(NewString) Do
(
    index := InStr(index, NewString, "0");
    If index > 1 Then
        Name := Left(NewString, index - 1);

    NewString := Mid(NewString, index + 1);
    index := 1;
);
Name;



Edited by ezeney - 01 Oct 2008 at 1:22pm
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