On Sat, 2 Jun 2007, Rainer Stratmann wrote:
> Am Samstag, 2. Juni 2007 19:59 schrieb Peter Vreman: > > At 19:58 2-6-2007, you wrote: > > >Hello, > > > > > >1. > > > > > >var s:string; > > >... > > >s[1]:='#'; --> causes an access violation > > > > > >2. > > > > > >Why is it no more possible to assign the length index s[0] in a string? > > >I find that is too much security to supress that. > > >It is cutting responsibility from the programmers. > > > > You are using ansistrings instead of shortstrings. Use SetLength() > > first to allocate memory. > > > Does that mean that > > var s:string; is definig an ansistring in delphi mode? Yes. > > In the previous version this works, is it now changing generally to > ansistrings? Yes. In old versions {$mode delphi} did not automatically imply {$h+}. Now it does. > How can I assign "normal" pascalstrings? Put {$h-} at the start of your file, or use the -Sh- option on the command-line. Alternatively, define your string as Var S : Shortstring; This works in any mode, and is delphi compatible. > Is there a description about the behaviour of strings and ansistrings in the > various modes? Yes, the reference documentation. The only effect of the {$h} directive is to map String->Ansistring when {$h ON} or String-> Shortstring when {$h off} is in effect. You can always force either of those by explicitly using ansistring, shortstring or declaring a fixed-length string. This is 100% delphi compatible. The only thing that has changed is that {$mode delphi} now implicitly implies {$h+}. This is again compatible with newer versions of Delphi, where {$H+} is now the default. Hope this clarifies matters a bit. I'll add a statement of the changed behaviour to the documentation of {$mode} and {$H} Michael. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal