Peter Gerwinski wrote:

Mon, 28 Apr 1997 18:03:40 +0200



> > Is there a way to change a string's length directly?
>
> AFAIK, there isn't.  Use the `SubStr' function (like BP's `copy' function)
> to shorten a string, and the `+' operator to make it longer.

Well, the problem is, I said "efficiently".
I don't assume, gpc would optimize statements like
 s:=s+'a'
where s is a (possibly quite long) string, so I'd have O(n) where actually
O(1) is possible. E.g. the examples from the documentation about converting
CStrings to Pascal strings append char by char in a loop -- O(n^2) instead
of O(n). I don't think that should be left as it is.

> And of course you can take a pointer to the string, cast it to a pointer
> to a record the fields of which you can manipulate like you wish ...

I'd have to do it like this if there's no other way...
But shouldn't it be possible to access the fields of the "string record" in
a direct way? Perhaps in the course of the schema project? (Are you planning
to make strings regular schema types then -- regular except for the extended
syntax that allows s[n]?)
-- 
Frank Heckenbach, Erlangen, Germany
heckenb[No_Spam! Remove this to reply.]@mi.uni-erlangen.de
Turbo Pascal:   http://www.mi.uni-erlangen.de/~heckenb/programs.htm
Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm


Frank Heckenbach (heckenb@mi.uni-erlangen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es