Jump to content

Rollo62

Members
  • Content Count

    1649
  • Joined

  • Last visited

  • Days Won

    20

Everything posted by Rollo62

  1. Rollo62

    Range check error.

    Have you checked that ComHandle is valid and accessible ? Maybe the hardware behind has died or changed. Can you open and read the port with other tools ?
  2. Hi there, I just wanted to use MulDiv, and my initial reflex was just take it , but: It seems not to be there in Systems, Math or the other, only in Winapi.Windows is the Windows version. I would bet my left finger that MulDiv should be there, am I missing something. The only thing I can find, from older messages, like this: function MathRound(AValue: Extended): Int64; inline; begin if AValue >= 0 then Result := Trunc(AValue + 0.5) else Result := Trunc(AValue - 0.5); end; function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer; begin if nDenominator = 0 then Result := -1 else Result := MathRound(Int64(nNumber) * Int64(nNumerator) / nDenominator); end; That looks a way over the top to me, why do they need floating point ? I will use it like this: function MulDiv(nNumber, nNumerator, nDenominator: Integer): Integer; begin if nDenominator = 0 then Result := -1 else Result := (Int64(nNumber) * Int64(nNumerator)) div nDenominator); end; But much better if someone can tell me where can I find a cross-platform, optimized version in the RTL ?
  3. Ok, thanks. But a simple MulDiv for Integer 32-Bit ? Nothing pops up. At least they are using the same method than I do for Int32. MulDiv64 := Int64((Int128(AValue) * Int128(AMul)) div Int128(ADiv)).
  4. Hi there, I'm trying to make the right choice for above, and tried some simple function. I also have seen a nice explanation about that from David When comparing both options, it seems to have only minor differences, see below. (Rx10.4.2) What I asked myself if there is any advantage of the record constructor over class function anyway, also in regard of the more modern CustomRecords ? type TRecConstructor = record private FValue : Integer; constructor Create( const AValue : Integer ); end; TRecClassFunc = record private FValue : Integer; class function Create( const AValue : Integer ) : TRecClassFunc; static; end; procedure TS4DunitX_Basic__Tests.Test01; var LRecCon : TRecConstructor; LRecCls : TRecClassFunc; begin LRecCon := TRecConstructor.Create( 42 ); LRecCls := TRecClassFunc.Create( 84 ); end; { TRecConstructor } constructor TRecConstructor.Create(const AValue: Integer); begin FValue := AValue; end; { TRecClassFunc } class function TRecClassFunc.Create(const AValue: Integer): TRecClassFunc; begin Result.FValue := AValue; end;
  5. Beside memory, I think of "constructor" Create as the necessary 1st step to setup an item correctly, before I can make use of anything from this item. Thats not the case for records, I could work without a "creation", that why I dislike the "Create" nomenclature for records and look for something that points out the difference. (and of course, I could name constructors anything else, but that makes it even more fuzzy).
  6. Ok, I will leave the class functions then as-is, if this makes no practical difference. Concerning the "constructor" naming, has a somewhat different meaning IMHO, not so well fitting to records. I will stay with the naming convention "class function TMyRecord.Make(...) : TMyRecord; static;" instead of construtors then, to be sure not to mix both concepts.
  7. @Dalija Prasnikar Thanks, that is not so bad news than I expected. We better all vote for RSP-22944 then, to keep things moving.
  8. Yes and no, I mean "out" is giving back a fresh variable to its caller. The state before should be considered undefined, it can exist, can have values, can be nil. I would say that in the 1. line inside the method, this does not exist, since the out parameter shall give back a new parameter. Whatever it was before shall not matter. From my opinion this is what "out" should originally stands for, even if it maybe can be misused somehow. On the other side, "var" brings in an existing parameter, inside the method, which can be used or changed at will.
  9. The message tells you: The out parameter should be considered as not-existing inside the method, so it cannot be used before its creation. If you want to use it like that you maybe better consider to use a var parameter.
  10. Hi there, I checked the latest Spring4D master, and it seems that the TPair<K,V> was removed from Spring.Collections.pas TPair<TKey, TValue> = packed record Key: TKey; Value: TValue; constructor Create(const key: TKey; const value: TValue); end; I know this was redundant in System.Generics.Collections.pas, but now I have to include this unit to get access to TPair. From the philosophy of S4D I understood that Spring.Collections should be able to replace the System.Generics.Collections in the long run completely, so I wonder why this TPair was removed then, its used in many places. That means I need to keep a reference to both units now, if I need this. Does this really make sense, why was it removed, and why not for example moved, separated into another Spring unit ?
  11. Rollo62

    Spring4D TPair removed

    Oooh yes, maybe its too late and hot right now 🙂
  12. Rollo62

    Spring4D TPair removed

    Ok, thanks. So I thought the new released master is a newer one, and included all from the development branch. Then I better stay with the development branch.
  13. Hi there, I used to have a free tier account for some years, but was not very active there. https://www.experts-exchange.com/ From my experience the coverage of Delphi was quite low, and maybe other topics like C#, JS, Java, PHP, C++ were maybe better covered. Maybe there is a kind of ranking of their abilities and quality ? I would like to know if anybody here is using this site, and if a full membership is worth the money. What are the strengths of www.experts-exchange.com , if not Delphi ? Can a full membership change the activity and quality of the answers in that channel ? Are the experts cross-platform, how well does www.experts-exchange.com can cover hardcore crossplatform topics ? I assume its a lot Web,Windows, DevOps biased (which is not bad eigher). Would be great if you could exchange your experiences, to help make decisions. I think this platform is over its zenith, since StackOverflow, but maybe you can proof me wrong.
  14. Rollo62

    [Android]How to make an event listener?

    You could look into TMessage and TMessageManager, which is used internally a lot, but probably not all events. Anyway, you could build something around this, also for custom events, it works quite reliable .
  15. Yes, of course I meant that the experts would get some profit from their support too, I assume that this was the business idea of EE in the first place . As a kind of micropayment "UpWork", for special answers, e.g. where Delphi user could get help to integrate Java .
  16. Thanks for your opinions, I think we share the same thoughts about EE. Its a pity, for a real, payed support site it would be worth to pay money.
  17. Rollo62

    Using VMWare: what files remain on host?

    @Remy Lebeau Interesting idea, so I assume you still generate the heavy DCU's, BPL, binaries etc. inside each VM, to keep them well separated. Does this help to reduce the overall VM size, if the sources were not inside the VM, I'm afraid not ? How about compile speed when using the transfer folders instead of VM folders, could you see any difference ? Since I use the host mainly as "empty, easy replaceable shell" for the VM's, I've tried to keep it clean and do everything in VM's inside, but a common source folder can make sense.
  18. @mjustin Nice product. I assume this works under VCL only, is that correct ? Since there were no infos about other platforms.
  19. Rollo62

    Using VMWare: what files remain on host?

    I find it very convenient to have a common _Transfer\ folder, which is available on the host, and shared in all VM's. This helps to easily share files and data between the different VM's. Thos files were stored on the host, and in the VM's they were only virtually binded. Of course this is not intended to be opend for write from several VM's or the host at the same time, but just for manual exchange (e.g. for PAServer files, etc).
  20. http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TStringList.Add
  21. @Stefan Glienke Thanks, thats very interesting, I thought about these issues too, which would be the reasons though, and I assumed there could be many reasons (inline, generics, other references). Do you know if the "inlining" is the only reason that causes this issue ?
  22. Need to be Edited again (lEditor lost all my text from 1st post). Seems mathematically correct, but may face internal integer overflows, to be tested in Delphi ...
  23. Rollo62

    What is the correct approach to "phone home"?

    Me too And even a simple, virtual website provider with PHP will do, at very affordable cost.
  24. Hi there, I was just reading @jeroenp 's blog, from here. Thats so much true, and I love Format() since the old C days What I wanted to add here is another "overlooked" option, adding leading zeroes, which is described here. Maybe there are even more "overlooked" features, I'm not aware of ? I'm curious.
  25. Just keep as-is ... but make a BIG !! WARNING !! and explaining comment ( pointing to this thread maybe )
×