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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to extract repeated text - Looping?

Status
Not open for further replies.

alexlc

Technical User
Oct 7, 2004
39
0
0
GB
Hi,

I have a field of user actions, such as below:

Staff Member NF selected by CW
Client Confirmed with HELEN with Ref : 0909004045. Entered by CW
Booking Edited by CW
Staff Cancelled reason working 3 nights wants two days off by KP staff member was NF
Booking Edited by KP
Name Change Set By KP. Name change was NF
Staff Member GM selected by CW
Booking Edited by CW
Name Change done by CW. Name change was NF
Staff Confirmed By SD
Booking Edited by SD
Booking status set to Complete by Server

I need to extract the lines where all instances of the line starting "Staff Member" appear.

I have tried a While formula:

stringVar NewName := {Booking.EditHistoryEventList};
numberVar i := -1;
numberVar Strlen := length (NewName);
numberVar Result := -1;

while i <= Strlen and Result = -1 do
(
stringVar Position:= mid (NewName, i, -1);
if Position = "Staff Member " then
Result := i;
i := i - 1;
);
stringVar NewName2 := mid (NewName, Result+1, (Strlen-Result));
NewName2

But I get the "Start position is less than 1 or not an interger" and it highlights the bold text above.

I have used this formula from a tutorial, without really understanding what it does, so any advice is gratefully recieved.
I am using Crystal 9, reading a Lotus Notes database over an ODBC connection.
 
I would try the following, assuming that returns are used at the end of each line:

stringvar array y := split({Booking.EditHistoryEventList},chr(13));
numbervar i;
numbervar j := ubound(y);
stringvar z := "";
for i := 1 to j do(
if y startswith "Staff Member" then
z := z + y + chr(13)
);
z

Format the formula to "can grow".

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top