Jump to content

Alexander Elagin

Members
  • Content Count

    198
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Alexander Elagin

  1. Alexander Elagin

    Problems making a calculator with DELPHI in RAD STUDIO. (Tan, Cos, Sin)

    In Delphi, trigonometric functions (along with other mathematic routines) are implemented in the module (unit) System.Math. Do not forget to add this unit manually to the uses section of your module where you use them: uses System.SysUtils, (...other units), System.Math;
  2. Alexander Elagin

    Inherited on Properties and co.

    In fact, this was a pretty common trick when implementing ccustom lists before generics.
  3. Alexander Elagin

    Inherited on Properties and co.

    Because Data property is re-introduced with a new signature, thus it is necessary to explicitly use the inherited property and not the new one.
  4. Alexander Elagin

    Inherited on Properties and co.

    From the very beginning, i.e Delphi 1. What's the problem?
  5. Alexander Elagin

    Uniqueness and Security of domain name

    I do not know how secure it is, but function NetWkstaGetInfo can provide some information about the domain. There is also some code on the StackOverflow .
  6. Alexander Elagin

    I got bitten by an interface!

    The third one is QueryInterface: .... protected function QueryInterface({$IFDEF FPC}constref{$ELSE}const{$ENDIF} IID: TGUID; out Obj): HResult; stdcall; function _AddRef: Integer; stdcall; function _Release: Integer; stdcall; .... function TMyClass.QueryInterface({$IFDEF FPC}constref{$ELSE}const{$ENDIF} IID: TGUID; out Obj): HResult; stdcall; begin if GetInterface(IID, Obj) then Result := S_OK else Result := E_NOINTERFACE; end; function TMyClass._AddRef: Integer; stdcall; begin Result := -1; end; function TMyClass._Release: Integer; stdcall; begin Result := -1; end; Implement these three functions and you have a nice class with interfaces and without any reference counting.
  7. Alexander Elagin

    I got bitten by an interface!

    Or better inherit from TSingletonImplementation (I wonder who decided to give the base non-ARC interfaced object this misleading name...)
  8. Alexander Elagin

    Customizing source editor

    I use a custom colour scheme based on the Solarized Dark from Notepad++:
  9. Alexander Elagin

    Example of wasteful, innefficient string manipulation

    If you want to get the most of FastMM (different configurations for debug/release, fine tuning of settings) you still need the standalone version. The bundled one is a "good middle ground" but there always are options to get more...
  10. Alexander Elagin

    TeeChart with vertical bar?

    TeeChart Pro has TColorLineTool exactly for this purpose (in TeeTools.pas). I have no idea whether it is in the bundled Embarcadero edition of TeeChart or not.
  11. Alexander Elagin

    gem found in vcl.forms

    This function exists also in 10.1, but for obvious reasons there is no trace of this code in Delphi XE. Somebody probably used some black magic to force scaling engine into the two decades old and pretty stable code of the Forms unit, but had to put duct tape here and there to make it work. No doubt that the IDE theming used even more glue and tape, that's why the themed IDE is a slow monster.
  12. Alexander Elagin

    Hex2Binary

    FreePascal version of the same function in mode O1 (quick optimization): function foo(I: Integer): Integer; begin case I of 0: Exit(random(255)); 1: Exit(3); 2: Exit(4); 3: Exit(5); 4: Exit(6); 5: Exit(7); else Exit(0); end; end; FPC_Test.lpr:50 begin 00000001000018C0 55 push %rbp 00000001000018C1 4889e5 mov %rsp,%rbp 00000001000018C4 488d6424d0 lea -0x30(%rsp),%rsp 00000001000018C9 894df8 mov %ecx,-0x8(%rbp) FPC_Test.lpr:51 case I of 00000001000018CC 89c8 mov %ecx,%eax 00000001000018CE 85c9 test %ecx,%ecx 00000001000018D0 0f8c6e000000 jl 0x100001944 <FOO+132> 00000001000018D6 85c0 test %eax,%eax 00000001000018D8 741e je 0x1000018f8 <FOO+56> 00000001000018DA 83e801 sub $0x1,%eax 00000001000018DD 7429 je 0x100001908 <FOO+72> 00000001000018DF 83e801 sub $0x1,%eax 00000001000018E2 7430 je 0x100001914 <FOO+84> 00000001000018E4 83e801 sub $0x1,%eax 00000001000018E7 7437 je 0x100001920 <FOO+96> 00000001000018E9 83e801 sub $0x1,%eax 00000001000018EC 743e je 0x10000192c <FOO+108> 00000001000018EE 83e801 sub $0x1,%eax 00000001000018F1 7445 je 0x100001938 <FOO+120> 00000001000018F3 eb4f jmp 0x100001944 <FOO+132> 00000001000018F5 0f1f00 nopl (%rax) FPC_Test.lpr:52 0: Exit(random(255)); 00000001000018F8 b9ff000000 mov $0xff,%ecx 00000001000018FD e8bed70000 callq 0x10000f0c0 <SYSTEM_$$_RANDOM$LONGINT$$LONGINT> 0000000100001902 8945f4 mov %eax,-0xc(%rbp) 0000000100001905 eb45 jmp 0x10000194c <FOO+140> 0000000100001907 90 nop FPC_Test.lpr:53 1: Exit(3); 0000000100001908 c745f403000000 movl $0x3,-0xc(%rbp) 000000010000190F eb3b jmp 0x10000194c <FOO+140> 0000000100001911 0f1f00 nopl (%rax) FPC_Test.lpr:54 2: Exit(4); 0000000100001914 c745f404000000 movl $0x4,-0xc(%rbp) 000000010000191B eb2f jmp 0x10000194c <FOO+140> 000000010000191D 0f1f00 nopl (%rax) FPC_Test.lpr:55 3: Exit(5); 0000000100001920 c745f405000000 movl $0x5,-0xc(%rbp) 0000000100001927 eb23 jmp 0x10000194c <FOO+140> 0000000100001929 0f1f00 nopl (%rax) FPC_Test.lpr:56 4: Exit(6); 000000010000192C c745f406000000 movl $0x6,-0xc(%rbp) 0000000100001933 eb17 jmp 0x10000194c <FOO+140> 0000000100001935 0f1f00 nopl (%rax) FPC_Test.lpr:57 5: Exit(7); 0000000100001938 c745f407000000 movl $0x7,-0xc(%rbp) 000000010000193F eb0b jmp 0x10000194c <FOO+140> 0000000100001941 0f1f00 nopl (%rax) FPC_Test.lpr:59 Exit(0); 0000000100001944 c745f400000000 movl $0x0,-0xc(%rbp) 000000010000194B 90 nop FPC_Test.lpr:61 end; 000000010000194C 8b45f4 mov -0xc(%rbp),%eax 000000010000194F 90 nop 0000000100001950 488d6500 lea 0x0(%rbp),%rsp 0000000100001954 5d pop %rbp 0000000100001955 c3 retq Judge it yourself
  13. Alexander Elagin

    FireDAC Add On discountinued? (Good by Embarcadero?)

    UniDAC has a nice feature called Unified SQL (https://www.devart.com/unidac/docs/unisql.htm) which can be used to automatically preprocess SQL statements based on macros and conditionals. Maybe this can help you.
  14. Alexander Elagin

    Hex2Binary

    Copies four characters from the BinaryValues constant array item at index HexDigitValue to the location pointed by Ptr.
  15. Alexander Elagin

    FireDAC Add On discountinued? (Good by Embarcadero?)

    Use UniDAC, which is not too expensive and is a good independent alternative to FireDAC. It also supports Lazarus and older versions of Delphi. Switching from FireDAC is not difficult. https://www.devart.com/unidac/
  16. Reading it now. Finally a nice and clear introduction to FMX - I wish this were part of the documentation from the first introduction of this framework, instead of a dry list of obscure classes present in the official docs today. Thank you for the excellent book!
  17. Yes, but the point was that one has to use the collection's Count property for indexing and never the Length of the internal array, as the array may have more elements (preallocated for possible expansion) than the real number of elements in the collection.
  18. Alexander Elagin

    Soap Server and client downloading files

    Convert the binary data to base64-encoded string and return it to the client which can decode it back to binary. In my experience, passing 2-5 megabytes this way does not cause any problems.
  19. There are two great functions in the DateUtils module: DateToISO8601 and ISO8601ToDate. They can save a lot of pain when it is needed to store date/time in text files.
  20. Alexander Elagin

    Anybody up for an ethics question?

    If the manager assumes the responsibility, then just have a written document signed by him - be it a specification or a simple memo. If things go wrong, you'll have you covered.
  21. Alexander Elagin

    Your RAD Studio 10.4 Sydney issues

    It is strange that 10.4 does not show access violation here while the error is obvious: c1 := 'A'; p := PChar(c1); // wrong explicit conversion: widechar to integer to pointer. // Now p is a pointer to the memory location at the address 0x00000041 - that is, the value of Ord(A) showmessage(p^); // here p^ points to memory location at 0x00000041, obviously not was meant by the author
  22. Alexander Elagin

    Rx10.4 new feature blogs

    So if I am the Primary Contact (as I paid the bill myself) I still have to assign myself somewhere as an Authorized Contact? Damn, the Embarcadero's sales model does not change with years, they are targeting businesses, not developers. And don't remind me about all this reseller-only distribution and obligatory quote request for updates ☠️...
  23. Alexander Elagin

    Rx10.4 new feature blogs

    Same here.
  24. Alexander Elagin

    The interfaces in Delphi are bad?

    I guess yes (the {$INTERFACES} directive is local) but honestly I have not tried it myself because it is incompatible with Delphi code
×