You've already forked lazarus-ccr
fpspreadsheet: In expression parser, use double quotes (instead of single quots) to identify strings (Excel/OO/LO standard)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3502 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -69,7 +69,7 @@ begin
|
|||||||
case formula[i].ElementKind of
|
case formula[i].ElementKind of
|
||||||
fekCell : Write(' / cell: ' +GetCellString(formula[i].Row, formula[i].Col, formula[i].RelFlags));
|
fekCell : Write(' / cell: ' +GetCellString(formula[i].Row, formula[i].Col, formula[i].RelFlags));
|
||||||
fekNum : Write(' / number value: ', FloatToStr(formula[i].DoubleValue));
|
fekNum : Write(' / number value: ', FloatToStr(formula[i].DoubleValue));
|
||||||
fekString : Write(' / string value: ', formula[i].StringValue);
|
fekString : Write(' / string value: "', formula[i].StringValue, '"');
|
||||||
fekBool : Write(' / boolean value: ', BoolToStr(formula[i].DoubleValue <> 0));
|
fekBool : Write(' / boolean value: ', BoolToStr(formula[i].DoubleValue <> 0));
|
||||||
end;
|
end;
|
||||||
WriteLn;
|
WriteLn;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
- TsConcatExprNode and token "&" to handle string concatenation
|
- TsConcatExprNode and token "&" to handle string concatenation
|
||||||
- remove and modifiy built-in function such that the parser is compatible
|
- remove and modifiy built-in function such that the parser is compatible
|
||||||
with Excel syntax (and OpenOffice - which is the same).
|
with Excel syntax (and OpenOffice - which is the same).
|
||||||
|
- use double quotes for strings (instead of single quotes)
|
||||||
|
|
||||||
******************************************************************************}
|
******************************************************************************}
|
||||||
{$mode objfpc}
|
{$mode objfpc}
|
||||||
@ -735,7 +736,6 @@ uses
|
|||||||
|
|
||||||
const
|
const
|
||||||
cNull = #0;
|
cNull = #0;
|
||||||
cSingleQuote = '''';
|
|
||||||
cDoubleQuote = '"';
|
cDoubleQuote = '"';
|
||||||
|
|
||||||
Digits = ['0'..'9', '.'];
|
Digits = ['0'..'9', '.'];
|
||||||
@ -948,10 +948,8 @@ function TsExpressionScanner.DoString: TTokenType;
|
|||||||
function TerminatingChar(C: Char): boolean;
|
function TerminatingChar(C: Char): boolean;
|
||||||
begin
|
begin
|
||||||
Result := (C = cNull)
|
Result := (C = cNull)
|
||||||
or ((C = cSingleQuote) and
|
or ((C = cDoubleQuote) and
|
||||||
not ((FPos < LSource) and (FSource[FPos+1] = cSingleQuote)))
|
not ((FPos < LSource) and (FSource[FPos+1] = cDoubleQuote)));
|
||||||
or ((C = cDoubleQuote) and
|
|
||||||
not ((FPos < LSource) and (FSource[FPos+1] = cDoubleQuote)));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -962,8 +960,6 @@ begin
|
|||||||
while not TerminatingChar(C) do
|
while not TerminatingChar(C) do
|
||||||
begin
|
begin
|
||||||
FToken := FToken+C;
|
FToken := FToken+C;
|
||||||
if C = cSingleQuote then
|
|
||||||
NextPos;
|
|
||||||
if C = cDoubleQuote then
|
if C = cDoubleQuote then
|
||||||
NextPos;
|
NextPos;
|
||||||
C := NextPos;
|
C := NextPos;
|
||||||
@ -1058,7 +1054,7 @@ begin
|
|||||||
Result := ttEOF
|
Result := ttEOF
|
||||||
else if IsDelim(C) then
|
else if IsDelim(C) then
|
||||||
Result := DoDelimiter
|
Result := DoDelimiter
|
||||||
else if (C = cSingleQuote) or (C = cDoubleQuote) then
|
else if (C = cDoubleQuote) then
|
||||||
Result := DoString
|
Result := DoString
|
||||||
else if IsDigit(C) then
|
else if IsDigit(C) then
|
||||||
Result := DoNumber
|
Result := DoNumber
|
||||||
@ -2131,10 +2127,10 @@ end;
|
|||||||
function TsConstExprNode.AsString: string;
|
function TsConstExprNode.AsString: string;
|
||||||
begin
|
begin
|
||||||
case NodeType of
|
case NodeType of
|
||||||
rtString : Result := '''' + FValue.ResString + '''';
|
rtString : Result := cDoubleQuote + FValue.ResString + cDoubleQuote;
|
||||||
rtInteger : Result := IntToStr(FValue.ResInteger);
|
rtInteger : Result := IntToStr(FValue.ResInteger);
|
||||||
rtDateTime : Result := '''' + FormatDateTime('cccc', FValue.ResDateTime) + '''';
|
rtDateTime : Result := '''' + FormatDateTime('cccc', FValue.ResDateTime) + ''''; // Probably wrong !!!
|
||||||
rtBoolean : if FValue.ResBoolean then Result := 'True' else Result := 'False';
|
rtBoolean : if FValue.ResBoolean then Result := 'TRUE' else Result := 'FALSE';
|
||||||
rtFloat : Str(FValue.ResFloat, Result);
|
rtFloat : Str(FValue.ResFloat, Result);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user