• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Split line into fields and put fields in an array

What is the best way to split a line into an array?

The line looks like this:


field1^field2^field3^


The individual fields can be different lenghts and the number of fields can also be different.

0
tommykjensen
Asked:
tommykjensen
1 Solution
 
esoftbgCommented:
S := 'field1^field2^field3^';
I := 0;
P := Pos('^', S);
while (P>0) do
begin
  A[I] := Copy(S, 1, P-1);
  Delete(S, 1, P);
  P := Pos('^', S);
  Inc(I);
end;
0
 
tommykjensenAuthor Commented:
Excellent, works perfectly and much better than my own clumsy attemp.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now