anton.tichawa at chello.at
Fri Oct 26 02:59:41 CEST 2001
try the following piece of code:
S := ''; // make S empty
S[Length(S)] := 'a';
This results in an access violation, because, AFAIK, an empty ansi-string
actually has no space allocated, but is a nil pointer. Make sure that your
strings aren't empty before changing the last character (if the string is
empty, there is no last character). Hope this helps.
----- Original Message -----
From: Ivan Montes <Drslump at btopenworld.com>
To: <fpc-pascal at deadlock.et.tudelft.nl>
Sent: Friday, October 26, 2001 2:46 AM
> Hi everybody,
> I just discover ansi-strings (long strings) a couple of months ago, and
> very happy with them. They help me a lot in everything I do.
> But I found that if I access the last character of it, like
> s[length(s)]:='A'; sometimes I get an access violation. Why is that?
> If it's because I can't do that due to the internals of ansistrings, how
> should I do to change the last character of the string?
> thanks, Ivan
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
More information about the fpc-pascal