When trying to use the Stringutils unit I've run into a issue. In that how do you determin the number of strings returned from the Tokenize funcions?
For instance TokenizeString returns PPStrings but does not use a nil sentinal at the end of the array of strings. So with out the use of a nil sentinal how do you find out how many strings are being returned?
The PPStrings are dynamicaly allocated so can't use SizeOf on it to get what I need. I know there must be a way to do it or the Tokenize routines would use a nil sentinal.
I made a local copy of the routine I'm using and added a nil sentinal to it so I can get done what I need but I'm still wondering how you would do this.
Thanks Richard
Richard D. Jackson wrote:
When trying to use the Stringutils unit I've run into a issue. In that how do you determin the number of strings returned from the Tokenize funcions?
For instance TokenizeString returns PPStrings but does not use a nil sentinal at the end of the array of strings. So with out the use of a nil sentinal how do you find out how many strings are being returned?
Just look at the type declaration (in gpc.pas):
type { `+ 1' is a waste, but it is so the size of the array is not zero for Count = 0 } PPStrings = ^TPStrings; TPStrings (Count: Cardinal) = array [1 .. Count + 1] of PString;
So there's `Count'.
Frank
On Tue, 2003-02-25 at 20:43, Frank Heckenbach wrote:
Richard D. Jackson wrote:
When trying to use the Stringutils unit I've run into a issue. In that how do you determin the number of strings returned from the Tokenize funcions?
For instance TokenizeString returns PPStrings but does not use a nil sentinal at the end of the array of strings. So with out the use of a nil sentinal how do you find out how many strings are being returned?
Just look at the type declaration (in gpc.pas):
type { `+ 1' is a waste, but it is so the size of the array is not zero for Count = 0 } PPStrings = ^TPStrings; TPStrings (Count: Cardinal) = array [1 .. Count + 1] of PString;
So there's `Count'.
The EP Schemata stuf is new to me so it did not register when I did look at the declaration. But when you pointed it out the light came on and I went this is neat as it can be used to solve many things in a much cleaner way. I wonder why Delphi doesn't support this.
Oh well thanks for the enlightenment :) I guess I should really be asking these types of questions over on the iso news group verses here though.
Richard
Richard D. Jackson wrote:
Just look at the type declaration (in gpc.pas):
type { `+ 1' is a waste, but it is so the size of the array is not zero for Count = 0 } PPStrings = ^TPStrings; TPStrings (Count: Cardinal) = array [1 .. Count + 1] of PString;
So there's `Count'.
The EP Schemata stuf is new to me so it did not register when I did look at the declaration. But when you pointed it out the light came on and I went this is neat as it can be used to solve many things in a much cleaner way. I wonder why Delphi doesn't support this.
Oh well thanks for the enlightenment :) I guess I should really be asking these types of questions over on the iso news group verses here though.
Depends. They (generally) don't have the GPC type definition, so you'd have to copy it there ...
Frank