"FindFirstItem" works and gives me the first entry in the selected area.
After that, "FindNextItem" will not work. always gives me the same entry and thus hang in an infinite loop.... I have once extended the TMSFNCPlanner demo with the following function. The same procedure in the VCLPlanner works.
procedure TForm130.TMSFNCPlanner1SelectCell(Sender: TObject; AStartCell,
AEndCell: TTMSFNCPlannerCell);
var
item: TTMSFNCPlannerItem;
begin
label3.text:=DateTimeToStr(TMSFNCPlanner1.SelectedStartDateTime); // these 3 lines only to control
label5.Text:=DateTimeToStr(TMSFNCPlanner1.SelectedEndDateTime); // Start-, Endtime and
label6.Text:=TMSFNCPlanner1.SelectedResource.ToString; // Resource
item:=TMSFNCPlanner1.FindFirstItem(TMSFNCPlanner1.SelectedStartDateTime,
TMSFNCPlanner1.SelectedEndDateTime,
TMSFNCPlanner1.SelectedResource);
while assigned(item) do
begin
memo1.Lines.Add(item.Title);
item:=TMSFNCPlanner1.FindNextItem(TMSFNCPlanner1.SelectedStartDateTime,
TMSFNCPlanner1.SelectedEndDateTime,
TMSFNCPlanner1.SelectedResource);
end;
end;
Hi,
We have applied a fix, the next version will address this. Thanks for reporting!
Ok. Thank for your quick response!
1 Like
Hello Pieter,
Is there already an appointment for the next release of the TMCFNCPlanner (TMS FNC Component Studio). We urgently need a working "TMSFNCPlanner.FindNextItem". Otherwise, we will not be able to publish our app.
Greetings
Andreas
Hi,
There is currently no release planned. Actually the fix is quite simple. You need to add a + 1 to FFindItemIndex to fix the issue. See the fixed code snippet below.
function TTMSFNCCustomPlanner.FindNextItem(AStartTime, AEndTime: TDateTime;
APosition: Integer): TTMSFNCPlannerItem;
var
I: Integer;
it: TTMSFNCPlannerItem;
begin
Result := nil;
for I := FFindItemIndex + 1 to Items.Count - 1 do
begin
it := Items[I];
if IsValidItem(it) and (it.Resource = PositionToResource(APosition)) then
begin
if DateTimeInRangeEx(AStartTime, it.StartTime, it.EndTime, False) or DateTimeInRangeEx(AEndTime, it.StartTime, it.EndTime, False)
or DateTimeInRangeEx(it.StartTime, AStartTime, AEndTime, False) or DateTimeInRangeEx(it.EndTime, AStartTime, AEndTime, False) or
((CompareDateTime(it.StartTime, AStartTime) = EqualsValue) and (CompareDateTime(it.EndTime, AEndTime) = EqualsValue)) then
begin
FFindItemIndex := it.Index;
Result := it;
Break;
end;
end;
end;
end;
Thank you Pieter.
That works and will help us.
Greetings
Andreas
1 Like