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

Parsing through large string for last entry 1

Status
Not open for further replies.

robg82

Technical User
Nov 17, 2011
19
US
Hello
I need to parse through a 'work log' and grab the last entry into the field. The table i am working with does not have a time stamp field for the specific entries. The entries are prefaced by a datetime stamp (dd/mm/yyyy hh:mm:ss am/pm), and a username. If the user is part of any groups their group is appended as the next line in the entry followed by their work log update.

Below i colored the work log stamp in read and the users entry in blue.

In this example i would like to grab user2's 2nd entry.

I've tried to split using time stamp fields and 'modified by' fields but they are not consistently related to work log entries.

example formula:

stringvar array x := split({table.Work Log},{table.Last Modified By});
x[ubound(x)]


Example work log entries:


11/27/2012 6:45:22 AM user1
Process ID: E3045
Node: node1
Summary: equipmentFailure: SLOT-10 Slot:10 Port:1 Line:0 Index:

Outage Discovered: 11/27/12 06:41:33

Outage Occurred: 11/27/12 06:36:56

11/27/2012 7:29:49 AM user2
NOC - IP - Group

There is no maintenaces in the area, dispatching tech with possible spare and to reseat the card.
11/27/2012 7:33:30 AM user2
NOC - IP - Group

Called tech headend tech and left VM.






Any help would be greatly appreciated. Thanks.
 
This request is really confusing to me.....

Which field is {table.Work Log} and which is {table.Last Modified By}

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Below is an example of whats in the work log memo field. Ive got no way to split out the last entry starting at '11/27/2012 7:33:30 AM user2' in the example. last modified by would be the user that made a change to the ticket (e.g. user1, user2). My problem is the change may not update the work log so splitting using that field may not always grab the last work log entry. I need a way to show everything from the timestamp '11/27/2012 7:33:30 AM' down.

Sorry for the confusion. Over explained and just made it convoluted.


Work log:

11/27/2012 6:45:22 AM user1
Process ID: E3045
Node: node1
Summary: equipmentFailure: SLOT-10 Slot:10 Port:1 Line:0 Index:

Outage Discovered: 11/27/12 06:41:33

Outage Occurred: 11/27/12 06:36:56
11/27/2012 7:29:49 AM user2
NOC - IP - Group
There is no maintenaces in the area, dispatching tech with possible spare and to reseat the card.
11/27/2012 7:33:30 AM user2
NOC - IP - Group
Called tech headend tech and left VM.
 
still confused ... you said you were trying the formula above ...

Which field is {table.Work Log} and which is {table.Last Modified By}

what other fields are in the work log or is that one large field?

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
The work log is 1 field. The last modified by field is not displayed in my example.

The formula above works, but doesnt grab only the last work log entry. New entries are appended at the bottom of the work log field so it grows with each entry.
 
large text records like that are always hard for me to work with but this might work...

stringvar array x := split({table.Work Log},"/");
stringvar y;
y := right(x[ubound(x)-2],2) &"/"& x[ubound(x)-1] &"/"& x[ubound(x)]

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
For the most part that grabs the last entry. Only if there are some '/' in the entry does it return partial work log entries. Thanks this gets me started down the right track.
 
yep I was going to mention that if there were any /'s in the memo part of the last entry then it will blow up on you

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Try this:

stringvar x := {table.worklog};
stringvar array y := split(x,chr(13));
numbervar i := 0;
numbervar j := ubound(y);
numbervar k := 0;
stringvar array z := "";
for i := 1 to j do(
if isdatetime(left(y,21)) then (
k := k + 1;
redim preserve z[k];
z[k] := z[k]+ y
));
stringvar array b := split(x, z[k]);
z[k]+b[ubound(b)]

-LB
 
Morning LBass
I changed the split char for stringvar "y" from 'chr(13)' to 'chr(10)' and its grabbing the last entry on every test ticket ive checked so far.

Thank you very much, sir. Exactly what i needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top