Andries,
> I already found the TStringlist and the ability to add a second parameter
> (an object),
> but i mis on how I could use this as a counter? ("Add to add a new word,
> and Objects
> (typecast as an Integer") to increment the count of a word that is already
> in
> the list.
> )
> A small sniplet of code could help maybe. It sounds like the easiest
> solution.
Peter Luijer has already posted good code. Let me explain it.
StringList.Objects[I] := TObject(Succ(Integer(StringList.Objects[I])));
This takes the object associated with the word, typecasts it to an Integer
so calculations can be done on it, adds 1, then typecasts it back to an
object.
If you're not used to this kind of thing, it can look frightening. Breaking
it out into several lines makes it look simpler but that also involves other
variables. This kind of thing is need in a strictly-typed language like
Pascal when you are using a type in non-standard way. That adds a little
more work for the programmer, but avoids many nasty bugs overall, so I like
it.
Rory Daulton
[email protected]