Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 07/05/24 in all areas

  1. The terminology in the quoted text is muddy, IMO. Reintroduce does not affect the compiler other than suppressing a warning. You will get the same code emitted whether you omit the reintroduce keyword or include it. When you use the keyword you are just telling the compiler you intend to do something that kind of looks like a mistake (hiding the inherited method), because it is not common to declare a method in a child class that has the same name as a virtual/dynamic method in its parent and not also override it. (There are times where this makes sense but I personally try to avoid it because of the inevitable confusion it may cause down the road when it is forgotten this was done...) It's also sometimes the case that the inherited class changes: someone adds a new virtual method that didn't exist when the child class was designed, and now there is an unknown conflict; the warning is a good one so you can know this happened and deal with it accordingly. I can't understand from your post what you actually want to do, so I can't offer you an alternative that works around the confusion.
  2. Embarcadero Partners with Raize Software for KSVC Maintenance
  3. the Purpose of reintroduce is to make a second introduce for same method from base class (not marked as virtual or dynamic) with overload arguments in Drived Class whith inherited ofcourse .. reintroduce let us add inherited in implementation of that overload method that reintroduced in Derrived Class ex: type TBaseClass = class public constructor Create; // no virtual or dynamic end; TDerivedClass = class(TBaseClass) public // constructor Create; overload// introduced as overload but no arguments there !! constructor Create(aArg:T); reintroduce; overload; end; implementation { TBaseClass } constructor TBaseClass.Create; begin // for example No code here !! end; { TDerivedClass } constructor TDerivedClass.Create; begin inherited Create; // reintroduce let us make inherited here //since base method is not marked as virtual or dynamic .. MyCode; // our method here will implement both (the inherited + MyCode) // but since the inherited is empty : the reintroduce here is Totally useless !! // the aim of reintroduce is to let us Merge the old method from base to reintroduce it // as a new method in derived class using directive [inherited] // does the overload necessary ? // if there is no necessary to add new arguments you can add just reintroduce to use // the inherited directive there .. // Is inherited mandatory when using reintroduce ? // a reintroduce without inherited is totally nosense !! end; finally : reintroduce is used especially for two Reasons: make inherited + overload with new parameters for same base method in Drived class make just inherited without overload it with new parameters Q1)does reintroduce work also with base methods marked as virtual or dynamic ? A1) do you heard about override ? Q2) but if i need to introduce it with my custom parameters ? A2) if that case ofcourse you need reintroduce; with overload; Q3) is overload mandatory ? A3) since reintroduce her second work is to hide any warnning compiler i can say yes the overload is a mandatory logically .. ----- if i'm wrong plz tell me (Many thanks in Advance)
  4. stephane

    Parallel.For optimization

    Thank you guys for your hints. After investigating further, it seems indeed that there are some memory allocation issues. I started fixing them and both the monothread version and the multithread version are now faster. I'll revert back here when I am done with this process.
  5. Remy Lebeau

    While not CaLculating

    Simply tweak the code a little to keep track of the quantity used while iterating, eg: var LocNos, LotNos: string; QtyWanted, QtyUsed: Double; ... Table2.First; while not Table2.Eof do begin QtyWanted := Table2QTY.AsFloat; if QtyWanted > 0.0 then begin Query1.SQL.Text = 'SELECT * FROM Table1 WHERE ITEMCODE = :ItemCode AND LOCQTY > 0'; Query1.ParamByName('ItemCode').AsString := Table2ItemNo.AsString; Query1.Open; try Query1.First; if not Query1.Eof then begin LocNos := ''; LotNos := ''; repeat QtyUsed := Math.Min(Query1.FieldByName('LOCQTY').AsFloat, QtyWanted); LocNos := LocNos + Query1.FieldByName('LOCNO').AsString + '=' + FloatToStr(QtyUsed) + ','; LotNos := LotNos + Query1.FieldByName('LOTNO').AsString + ','; QtyWanted := QtyWanted - QtyUsed; Query1.Next; until Query1.Eof or (QtyWanted <= 0.0); SetLength(LocNos, Length(LocNos)-1); SetLength(LotNos, Length(LotNos)-1); Table2.Edit; Table2LOCNO.AsString := LocNos; Table2LOTNO.AsString := LotNos; Table2.Post; end; finally Query1.Close; end; end; Table2.Next; end;
  6. Anders Melander

    Parallel.For optimization

    Exactly. The memory manager is not the problem. If anything, a better performing memory manager will just make it harder to locate and fix the problem. The goal is to not be reliant on a faster memory manager (and FWIW, FastMM4 isn't slow).
  7. Remy Lebeau

    While not CaLculating

    Given the example you provided, try something more like this: var LocNos, LotNos: string; ... Table2.First; while not Table2.Eof do begin Query1.SQL.Text = 'SELECT * FROM Table1 WHERE ITEMCODE = :ItemCode AND LOCQTY <= :Qty'; Query1.ParamByName('ItemCode').AsString := Table2ItemNo.AsString; Query1.ParamByName('Qty').AsFloat := Table2QTY.AsFloat; Query1.Open; try Query1.First; if not Query1.Eof then begin LocNos := Query1.FieldByName('LOCNO').AsString + '=' + Query1.FieldByName('LOCQTY').AsString; LotNos := Query1.FieldByName('LOTNO').AsString; repeat Query1.Next; if Query1.Eof then Break; LocNos := LocNos + ', ' + Query1.FieldByName('LOCNO').AsString + '=' + Query1.FieldByName('LOCQTY').AsString; LotNos := LotNos + ', ' + Query1.FieldByName('LOTNO').AsString; until False; Table2.Edit; Table2LOCNO.AsString := LocNos; Table2LOTNO.AsString := LotNos; Table2.Post; end; finally Query1.Close; end; Table2.Next; end; Alternatively: var LocNos, LotNos: TStringList; ... Table2.First; while not Table2.Eof do begin Query1.SQL.Text := 'SELECT * FROM Table1 WHERE ITEMCODE = :ItemCode AND LOCQTY <= :Qty'; Query1.ParamByName('ItemCode').AsString := Table2ItemNo.AsString; Query1.ParamByName('Qty').AsFloat := Table2QTY.AsFloat; Query1.Open; try Query1.First; if not Query1.Eof then begin LocNos.Clear; LotNos.Clear; repeat LocNos.Add(Query1.FieldByName('LOCNO').AsString + '=' + Query1.FieldByName('LOCQTY').AsString); LotNos.Add(Query1.FieldByName('LOTNO').AsString); Query1.Next; until Query1.Eof; Table2.Edit; Table2LOCNO.AsString := LocNos.CommaText; Table2LOTNO.AsString := LotNos.CommaText; Table2.Post; end; finally Query1.Close; end; Table2.Next; end;
×