Re: [fpc-pascal] splitting string into array

2007-07-12 Thread Marc Santhoff
Am Mittwoch, den 11.07.2007, 20:48 -0700 schrieb L: > > > > Wouldn't this function be a candidate for crawling into the 'strutils' > > > > unit? > > > > > > Probably, but I would change the interface: > > > > > > function Split(const str: string; const separator: string; var Res : array > of > > >

Re: [fpc-pascal] splitting string into array

2007-07-12 Thread Vinzent Hoefler
On Thursday 12 July 2007 07:30, Michael Van Canneyt wrote: > Can you, BTW, explain the reference to Knuth ? I know who Donald > Knuth is, but fail to see the link... ? http://www.brainyquote.com/quotes/quotes/d/donaldknut181625.html Vinzent. ___ fpc-

Re: [fpc-pascal] splitting string into array

2007-07-11 Thread Michael Van Canneyt
On Wed, 11 Jul 2007, L wrote: > > > > Wouldn't this function be a candidate for crawling into the 'strutils' > > > > unit? > > > > > > Probably, but I would change the interface: > > > > > > function Split(const str: string; const separator: string; var Res : array > of > > > string) : Integer;

Re: [fpc-pascal] splitting string into array

2007-07-11 Thread L
> > > Wouldn't this function be a candidate for crawling into the 'strutils' > > > unit? > > > > Probably, but I would change the interface: > > > > function Split(const str: string; const separator: string; var Res : array of > > string) : Integer; > > > > So the function returns the number of ele

Re: [fpc-pascal] splitting string into array

2007-07-11 Thread Marc Santhoff
Am Mittwoch, den 11.07.2007, 12:09 +0200 schrieb Michael Van Canneyt: > > On Tue, 10 Jul 2007, Marc Santhoff wrote: [...] > > Wouldn't this function be a candidate for crawling into the 'strutils' > > unit? > > Probably, but I would change the interface: > > function Split(const str: string; c

Re: [fpc-pascal] splitting string into array

2007-07-11 Thread Michael Van Canneyt
On Tue, 10 Jul 2007, Marc Santhoff wrote: > Am Dienstag, den 10.07.2007, 14:56 +0200 schrieb Andrea Mauri: > > I used this, check it. > > > > // Returns an array with the parts of "str" separated by "separator" > > function Split(const str: string; const separator: string): array of string; > >

Re: [fpc-pascal] splitting string into array

2007-07-11 Thread Michael Van Canneyt
On Wed, 11 Jul 2007, L wrote: > Marc Santhoff wrote: > > Hi, > > > > is there any function in the libraries of fpc for splitting a string > > into an array naming the separator? > > There is a function in the substrings.pas unit included in this > package: > > http://z505.com/cgi-bin/powtils/d

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Luca Olivetti
En/na L ha escrit: Many functions should be merged into an FPC rtl unit I suppose, since it appears many of us are reinventing the wheel each time rolling our own private units. It's amazing the amount of extremely useful types/classes/functions available out of the box, but they are virtuall

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread L
Marc Santhoff wrote: > Hi, > > is there any function in the libraries of fpc for splitting a string > into an array naming the separator? There is a function in the substrings.pas unit included in this package: http://z505.com/cgi-bin/powtils/docs/1.6/idx.cgi?file=substrsplit&unit=substrings And

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Marc Santhoff
Am Dienstag, den 10.07.2007, 14:56 +0200 schrieb Andrea Mauri: > I used this, check it. > > // Returns an array with the parts of "str" separated by "separator" > function Split(const str: string; const separator: string): array of string; > var > i, n: integer; > strline, strfield: string; >

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Martin Schreiber
On Tuesday 10 July 2007 13.00, Marc Santhoff wrote: > Hi, > > is there any function in the libraries of fpc for splitting a string > into an array naming the separator? > Procedure splitstring from MSEgui, file lib/common/kernel/msestrings.pas. http://www.homepage.bluewin.ch/msegui/ Martin _

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Andrea Mauri
occurs is: function Occurs(const str, separator: string): integer; var i, nSep: integer; begin nSep:= 0; for i:= 1 to Length(str) do if str[i] = separator then Inc(nSep); Result:= nSep; end; Andrea Mauri ha scritto: I used this, check it. // Returns an array with the parts of "str" sepa

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Andrea Mauri
I used this, check it. // Returns an array with the parts of "str" separated by "separator" function Split(const str: string; const separator: string): array of string; var i, n: integer; strline, strfield: string; begin n:= Occurs(str, separator); SetLength(Result, n + 1); i := 0; strline:

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Wolfram Kläger
Here is a Delphi implementation of the common PHP function 'explode'. http://www.michael-puff.de/Developer/Delphi/Code-Snippets/Explode.html Your example then becomes to .. A := Explode('-', 'ab-cd-ef'); writeln(A[1]); // expect 'cd' .. The inverse is accomplished by using PHP like 'implode', wh

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Marc Santhoff
Am Dienstag, den 10.07.2007, 13:17 +0200 schrieb Luca Olivetti: > En/na Marc Santhoff ha escrit: > > Hi, > > > > is there any function in the libraries of fpc for splitting a string > > into an array naming the separator? > > not exactly but I found: > > http://www.freepascal.org/docs-html/rtl/s

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Daniël Mantione
Op Tue, 10 Jul 2007, schreef Marc Santhoff: > Hi, > > 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[2] > > it would split up the first string

Re: [fpc-pascal] splitting string into array

2007-07-10 Thread Luca Olivetti
En/na Marc Santhoff ha escrit: Hi, is there any function in the libraries of fpc for splitting a string into an array naming the separator? not exactly but I found: http://www.freepascal.org/docs-html/rtl/strutils/extractdelimited.html maybe exactly what you're searching is already there, s