You've already forked lazarus-ccr
fpspreadsheet: Fix cell references in several formulas.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6534 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4520,7 +4520,7 @@ begin
|
|||||||
AError := errOK;
|
AError := errOK;
|
||||||
SetLength(AData, BLOCKSIZE);
|
SetLength(AData, BLOCKSIZE);
|
||||||
n := 0;
|
n := 0;
|
||||||
for i:=0 to High(Args) do
|
for i:=Low(Args) to High(Args) do
|
||||||
begin
|
begin
|
||||||
arg := Args[i];
|
arg := Args[i];
|
||||||
if arg.ResultType = rtError then begin
|
if arg.ResultType = rtError then begin
|
||||||
|
@ -121,7 +121,7 @@ var
|
|||||||
x: TsExprFloat;
|
x: TsExprFloat;
|
||||||
n: Integer;
|
n: Integer;
|
||||||
begin
|
begin
|
||||||
if Args[0].ResultType in [rtInteger, rtFloat, rtDateTime, rtCell, rtEmpty] then begin
|
if Args[0].ResultType in [rtCell, rtInteger, rtFloat, rtDateTime, rtEmpty] then begin
|
||||||
x := ArgToFloat(Args[0]);
|
x := ArgToFloat(Args[0]);
|
||||||
if x > 0 then
|
if x > 0 then
|
||||||
begin
|
begin
|
||||||
@ -152,7 +152,7 @@ var
|
|||||||
res: TsExprFloat;
|
res: TsExprFloat;
|
||||||
i, n: Integer;
|
i, n: Integer;
|
||||||
begin
|
begin
|
||||||
if Args[0].ResultType in [rtInteger, rtFloat, rtEmpty, rtDateTime] then
|
if Args[0].ResultType in [rtCell, rtInteger, rtFloat, rtEmpty, rtDateTime] then
|
||||||
begin
|
begin
|
||||||
res := 1.0;
|
res := 1.0;
|
||||||
n := ArgToInt(Args[0]);
|
n := ArgToInt(Args[0]);
|
||||||
@ -263,7 +263,7 @@ var
|
|||||||
x: TsExprFloat;
|
x: TsExprFloat;
|
||||||
n: Integer;
|
n: Integer;
|
||||||
begin
|
begin
|
||||||
if Args[0].ResultType in [rtInteger, rtFloat, rtDateTime, rtCell, rtEmpty] then
|
if Args[0].ResultType in [rtCell, rtInteger, rtFloat, rtDateTime, rtEmpty] then
|
||||||
begin
|
begin
|
||||||
x := ArgToFloat(Args[0]);
|
x := ArgToFloat(Args[0]);
|
||||||
if x >= 0 then
|
if x >= 0 then
|
||||||
@ -421,22 +421,13 @@ procedure fpsDAY(var Result: TsExpressionResult; const Args: TsExprParameterArra
|
|||||||
// date_value can be a serial number or a string
|
// date_value can be a serial number or a string
|
||||||
var
|
var
|
||||||
y,m,d: Word;
|
y,m,d: Word;
|
||||||
dt: TDateTime;
|
|
||||||
begin
|
begin
|
||||||
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger]) then
|
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtString, rtCell])
|
||||||
DecodeDate(ArgToFloat(Args[0]), y,m,d)
|
then begin
|
||||||
else
|
DecodeDate(ArgToFloat(Args[0]), y, m, d);
|
||||||
if Args[0].ResultType in [rtString] then
|
Result := IntegerResult(d);
|
||||||
begin
|
end else
|
||||||
if TryStrToDate(Args[0].ResString, dt) then
|
Result := ErrorResult(errWrongType);
|
||||||
DecodeDate(dt, y,m,d)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Result := ErrorResult(errWrongType);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := IntegerResult(d);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsHOUR(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsHOUR(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
@ -446,20 +437,12 @@ var
|
|||||||
h, m, s, ms: Word;
|
h, m, s, ms: Word;
|
||||||
t: double;
|
t: double;
|
||||||
begin
|
begin
|
||||||
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger]) then
|
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtString, rtCell]) then
|
||||||
DecodeTime(ArgToFloat(Args[0]), h,m,s,ms)
|
|
||||||
else
|
|
||||||
if (Args[0].ResultType in [rtString]) then
|
|
||||||
begin
|
begin
|
||||||
if TryStrToTime(Args[0].ResString, t) then
|
DecodeTime(trunc(ArgToFloat(Args[0])), h,m,s,ms);
|
||||||
DecodeTime(t, h,m,s,ms)
|
Result := IntegerResult(h);
|
||||||
else
|
end else
|
||||||
begin
|
Result := ErrorResult(errWrongType);
|
||||||
Result := ErrorResult(errWrongType);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := IntegerResult(h);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsMINUTE(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsMINUTE(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
@ -468,20 +451,12 @@ var
|
|||||||
h, m, s, ms: Word;
|
h, m, s, ms: Word;
|
||||||
t: double;
|
t: double;
|
||||||
begin
|
begin
|
||||||
if (Args[0].resultType in [rtDateTime, rtFloat, rtInteger]) then
|
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtString, rtCell]) then
|
||||||
DecodeTime(ArgToFloat(Args[0]), h,m,s,ms)
|
|
||||||
else
|
|
||||||
if (Args[0].ResultType in [rtString]) then
|
|
||||||
begin
|
begin
|
||||||
if TryStrToTime(Args[0].ResString, t) then
|
DecodeTime(ArgToFloat(Args[0]), h,m,s,ms);
|
||||||
DecodeTime(t, h,m,s,ms)
|
Result := IntegerResult(m);
|
||||||
else
|
end else
|
||||||
begin
|
Result := ErrorResult(errWrongType);
|
||||||
Result := ErrorResult(errWrongType);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := IntegerResult(m);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsMONTH(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsMONTH(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
@ -490,20 +465,12 @@ var
|
|||||||
y,m,d: Word;
|
y,m,d: Word;
|
||||||
dt: TDateTime;
|
dt: TDateTime;
|
||||||
begin
|
begin
|
||||||
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger]) then
|
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtString, rtCell]) then
|
||||||
DecodeDate(ArgToFloat(Args[0]), y,m,d)
|
|
||||||
else
|
|
||||||
if (Args[0].ResultType in [rtString]) then
|
|
||||||
begin
|
begin
|
||||||
if TryStrToDate(Args[0].ResString, dt) then
|
DecodeDate(ArgToFloat(Args[0]), y,m,d);
|
||||||
DecodeDate(dt, y,m,d)
|
Result := IntegerResult(m);
|
||||||
else
|
end else
|
||||||
begin
|
Result := ErrorResult(errWrongType);
|
||||||
Result := ErrorResult(errWrongType);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := IntegerResult(m);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsNOW(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsNOW(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
@ -521,20 +488,12 @@ var
|
|||||||
h, m, s, ms: Word;
|
h, m, s, ms: Word;
|
||||||
t: Double;
|
t: Double;
|
||||||
begin
|
begin
|
||||||
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger]) then
|
if (Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtString, rtCell])
|
||||||
DecodeTime(ArgToFloat(Args[0]), h,m,s,ms)
|
then begin
|
||||||
else
|
DecodeTime(ArgToFloat(Args[0]), h,m,s,ms);
|
||||||
if (Args[0].ResultType in [rtString]) then
|
Result := IntegerResult(s);
|
||||||
begin
|
end else
|
||||||
if TryStrToTime(Args[0].ResString, t) then
|
Result := ErrorResult(errWrongType);
|
||||||
DecodeTime(t, h,m,s,ms)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Result := ErrorResult(errWrongType);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := IntegerResult(s);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsTIME(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsTIME(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
@ -580,7 +539,7 @@ begin
|
|||||||
n := ArgToInt(Args[1])
|
n := ArgToInt(Args[1])
|
||||||
else
|
else
|
||||||
n := 1;
|
n := 1;
|
||||||
if Args[0].ResultType in [rtCell, rtDateTime, rtFloat, rtInteger] then
|
if Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtCell] then
|
||||||
dt := ArgToDateTime(Args[0])
|
dt := ArgToDateTime(Args[0])
|
||||||
else
|
else
|
||||||
if Args[0].ResultType in [rtString] then
|
if Args[0].ResultType in [rtString] then
|
||||||
@ -604,20 +563,12 @@ var
|
|||||||
y,m,d: Word;
|
y,m,d: Word;
|
||||||
dt: TDateTime;
|
dt: TDateTime;
|
||||||
begin
|
begin
|
||||||
if Args[0].ResultType in [rtDateTime, rtFloat, rtInteger] then
|
if Args[0].ResultType in [rtDateTime, rtFloat, rtInteger, rtString, rtCell]
|
||||||
DecodeDate(ArgToFloat(Args[0]), y,m,d)
|
then begin
|
||||||
else
|
DecodeDate(ArgToFloat(Args[0]), y,m,d);
|
||||||
if Args[0].ResultType in [rtString] then
|
Result := IntegerResult(y);
|
||||||
begin
|
end else
|
||||||
if TryStrToDate(Args[0].ResString, dt) then
|
Result := ErrorResult(errWrongType);
|
||||||
DecodeDate(dt, y,m,d)
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
Result := ErrorResult(errWrongType);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Result := IntegerResult(y);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -905,7 +856,10 @@ var
|
|||||||
begin
|
begin
|
||||||
b := true;
|
b := true;
|
||||||
for i:=0 to High(Args) do
|
for i:=0 to High(Args) do
|
||||||
b := b and Args[i].ResBoolean;
|
if not ArgToBoolean(Args[i]) then begin
|
||||||
|
b := false;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
Result.ResBoolean := b;
|
Result.ResBoolean := b;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -921,13 +875,13 @@ procedure fpsIF(var Result: TsExpressionResult; const Args: TsExprParameterArray
|
|||||||
begin
|
begin
|
||||||
if Length(Args) > 2 then
|
if Length(Args) > 2 then
|
||||||
begin
|
begin
|
||||||
if Args[0].ResBoolean then
|
if ArgToBoolean(Args[0]) then
|
||||||
Result := Args[1]
|
Result := Args[1]
|
||||||
else
|
else
|
||||||
Result := Args[2];
|
Result := Args[2];
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
if Args[0].ResBoolean then
|
if ArgToBoolean(Args[0]) then
|
||||||
Result := Args[1]
|
Result := Args[1]
|
||||||
else
|
else
|
||||||
Result.ResBoolean := false;
|
Result.ResBoolean := false;
|
||||||
@ -937,7 +891,7 @@ end;
|
|||||||
procedure fpsNOT(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsNOT(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
// NOT( condition )
|
// NOT( condition )
|
||||||
begin
|
begin
|
||||||
Result.ResBoolean := not Args[0].ResBoolean;
|
Result.ResBoolean := not ArgToBoolean(Args[0]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure fpsOR(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
procedure fpsOR(var Result: TsExpressionResult; const Args: TsExprParameterArray);
|
||||||
@ -949,7 +903,10 @@ var
|
|||||||
begin
|
begin
|
||||||
b := false;
|
b := false;
|
||||||
for i:=0 to High(Args) do
|
for i:=0 to High(Args) do
|
||||||
b := b or Args[i].ResBoolean;
|
if ArgToBoolean(Args[i]) then begin
|
||||||
|
b := true;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
Result.ResBoolean := b;
|
Result.ResBoolean := b;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1939,6 +1939,7 @@ begin
|
|||||||
// Initiate validation of current input
|
// Initiate validation of current input
|
||||||
PostMessage(Handle, UM_VALIDATEINPUT, 0, LParam(Self));
|
PostMessage(Handle, UM_VALIDATEINPUT, 0, LParam(Self));
|
||||||
end;
|
end;
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user