2006/6/6, Michael Van Canneyt <[EMAIL PROTECTED]>:


On Tue, 6 Jun 2006, Alexandre Leclerc wrote:

> Hi all,
>
> here is the CSV decoding function. I have a problem with the array of
> string as the compiler is saying the type is not good when trying the
> SetLength(a). I must create a type for this.

This is perfectly normal;
otherwise the a: array of string is seen as an open array, which is
different from a dynamical array.

>
> Now I submit this procedure (because a function cant' return an array
> of string, but could probably return the type?) and I want inputs:
> - a better solution for 'array of string'
> - if no solution, is a function better?
>
> Then after I received the input I'll send a patch for sysutils (when
> the forum is up again).

Strutils you mean ?

Indeed.

I would like to add this function later on, I think it's useful indeed.
You may want to consider creating a WideString version, and a version
which returns an nil-terminated array of PChars.

Yes, when working with DB and string I always come to need a CSV
function or module. I think that would be usefull for many.

Is the type TArrayOfString acceptable for the unit and for coders that
will use the function? (Since it is in strutils I wanted as much
low-level code as possible.)

I'm totally ignorant of WideString. Any wiki pointers for me?

Is there a peculiar reason for and array of PChars? This would mean
that the user of the resulting procedure will have to free himself all
the allocation PChars? (Is using SetLength with PChars the good
function? I cant' remember and too occupied to check that now).

Also, start by allocating in blocks of 10 fields. Reallocating for each
field is memory intensive. At the end you can do a setlength call with
the correct number of fields.

Indeed. Much better. 10 sounds good. (Any defined const in the system
for this '10' number I should use?)

Just some ideas.

Thanks.

--
Alexandre Leclerc

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to