2006/4/13, Marc Weustink <[EMAIL PROTECTED]>:
> johnf wrote:
> > On Thursday 13 April 2006 13:13, Marc Weustink wrote:
> >
> >>Paulo wrote:
> >>
> >>>Please, help me:
> >>>In following Lazarus code (Lazarus 0.9.15 - Mandriva2006):
> >>>
> >>>var a, b, c, d: string;
> >>>begin
> >>>
> >>> a := 'who';
> >>> b := 'quote';
> >>> c := 'this';
> >>> d := a + ' ' + b + ' ' + c;
> >>> Result: d = 'who quote this'
> >>
> >>Thats right.
> >>
> >>
> >>>... continue ...
> >>>
> >>> b := quotedstr( b );
> >>> d := a + ' ' + b + ' ' + c;
> >>> Result: d = 'who ''quote'' this'
> >>
> >>How did you check ? Since
> >>
> >> WriteLN('Who ''quote'' this');
> >>
> >>will write:
> >>
> >> Who 'quote' thi
> >>
> >>Marc
> >>
> >>
> >>>I'm expected result
> >>>' who 'quote' this'
> >>>such as result obtained in Delphi or Kylix.
> >>>
> >>>Please, who solve it?
> >>>
> >>>Thank's
> >>>
> >>>Paulo Nievierowski
> >
> >
> > Are you sure? a+''+quotedstr+c should give {a''str''b} and not {a'str'b}.
> > this is because '' will provide the single quote then the quotedstr which is
> > 'str' with both leading single quote and ending single quote. Right?
>
> There is a difference what is in the string (the char sequence stored in
> memory) and the char sequnece you write in your source. The latter is
> compined by the compiler, and the compiler compiles a '.''.' into a dot,
> quote, dot. And that is what is in memory.
> So if you have in source s := 'a' + quoted('b') + 'c', the compiled
> result is a'b'c
>
> Try running next example:
>
> program quote;
> {$mode objfpc}{$h+}
> uses
> SysUtils;
> begin
> WriteLn('a'+QuotedStr('b')+'c');
> end.
>
> [EMAIL PROTECTED] test]$ ./quote
> a'b'c
Technically in Delphi this would be simple as: a + '''' + b + '''' +
c; Note that you need 4 string/quote chars > ' < where two are for the
string itself and two for the actual quote (one will be removed as an
escape char; kind of).
Regards.
--
Alexandre Leclerc
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives