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
Marc
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives