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

String Splitting

Status
Not open for further replies.

Smithsc

MIS
Apr 20, 2007
143
GB
I am trying to split a string into an array. I thought I had managed it with the following code:

Numbervar NoteLength := Len({Opportunity.oppo_downtimenotes});
Numbervar a;
Numbervar b;
Numbervar counter;

//Calculate the number of Date/Time records in Downtime Notes
For a := 1 To NoteLength Do
(
If Mid({Opportunity.oppo_downtimenotes},a,4) = "<BR>" Then counter := counter +1
);

Global Stringvar Array NoteArray[counter];

For b:=1 To counter Do
(
NoteArray[counter]:=Split({Opportunity.oppo_downtimenotes},"<BR>")[counter]
);

The field {Opportunity.oppo_downtimenotes} contains the string
Incomplete:03/08/2010 16:25:00<BR>Corrected:03/08/2010 16:25:00<BR>Incomplete:03/08/2010 16:27:00<BR>Corrected:03/08/2010 16:30:00<BR>

When I run the report I get the error message "A Subscript must be between 1 and the size of the array".

This is probably an easy fix but I don't know where I'm going wrong.

Many thanks for any help.

Stuart.
 
What do you want to do with the results? You can test for the number of elements in an array by using ubound(). You need to add the following:

Stringvar Array NoteArray[counter];

For b:=1 To counter Do
(
redim preserve NoteArray[ubound(NoteArray)];
NoteArray[counter]:=Split({Opportunity.oppo_downtimenotes},"<BR>")[counter]
);

-LB
 
Thanks LB.
I used your piece of code but I still got the same error message.
Any ideas.
 
Forgot to say what i want to use the data for.
I want to be able to calculate the time diff between each incomplete date/time and Corrected date/time.
If there's a better way to do this I would love to know.

Stuart.
 
Try removing the index on this:

Stringvar Array NoteArray;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top