On Thu, 9 Jun 2011, John Repucci wrote:

I was testing the below code from the fpc documentation and I get the "Can't
take the address of constant expressions" error, with the cursor positioned
just after "(S)" in the 2nd WriteLn statement.

I do not understand how to fix this.  I did search for the error, but it
none of it makes sense.
I'll solve my issue another way, but I'm wondering if this example should be
fixed.

0.9.31-30142, 2.4.2, win32-Vista

Any suggestions?

The following will work:

Program Example51;
{ This program demonstrates the AnsiQuotedStr function }
Uses sysutils;

Var
  S : AnsiString;
  P : PChar;

Begin
 S:='He said "Hello" and walked on';
 P:=Pchar(S);
 S:=AnsiQuotedStr(P,'"');
 Writeln (S);
 P:=Pchar(S);
 Writeln(AnsiExtractQuotedStr(P,'"'));
End.

The cause of the error may be that the signature of the AnsiExtractQuotedStr has
changed (the first parameter has been made a var) or else the compiler has become more strict in it's checking of the parameters.

I have corrected the example in the docs.

Michael.


source:
http://www.freepascal.org/docs-html/rtl/sysutils/ansiextractquotedstr.html

Program Example51;
{ This program demonstrates the AnsiQuotedStr function }
Uses sysutils;

Var S : AnsiString;

Begin
S:='He said "Hello" and walked on';
S:=AnsiQuotedStr(Pchar(S),'"');
Writeln (S);
Writeln(AnsiExtractQuotedStr(Pchar(S),'"'));
End.


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to