[fpc-pascal] splitting string into array
daniel.mantione at freepascal.org
Tue Jul 10 13:22:22 CEST 2007
Op Tue, 10 Jul 2007, schreef Marc Santhoff:
> is there any function in the libraries of fpc for splitting a string
> into an array naming the separator?
> In awk for eample if you do this:
> split("ab-cd-ef", x, "-")
> print x
> it would split up the first string using "-" as separator and print
> to the output. That's what I'm searching for.
> In pascal. ;)
In dynamically typed languages writing such a construction is very easy
because one can simply allocate an array at runtime of the needed type (if
there are multiple types at all).
In Pascal, being a statically typed language, the array element does
matter and cannot be decided about at runtime. Allocating an array at
runtime is possible to, but inefficient because the size isn't known in
advance, growing it one element at a time is a good way to fragment the
More information about the fpc-pascal