Jump to content

Attila Kovacs

Members
  • Content Count

    1936
  • Joined

  • Last visited

  • Days Won

    25

Everything posted by Attila Kovacs

  1. Attila Kovacs

    No C/S FireDac for Delphi Professional

    https://www.devart.com/unidac/
  2. Attila Kovacs

    Reading fields with different lenghts

    it's not necessary to move the data anywhere, just cast the memory to the record type TMyData = record bSTX: Byte; bSep1: Byte; Field1: Word; bSep2: Byte; Field2: Array [0 .. 5] of Byte; bSep3: Byte; Field3: Array [0 .. 2] of Byte; Field4: Array [0 .. 4] of Byte; bsep4: Byte; bETX: Byte; bLRC: Byte; end; PMyData = ^TMyData; var DataFromCOM: TBytes; begin SetLength(DataFromCOM, SizeOf(TMyData)); DataFromCOM[2] := 122; WriteLn(PMyData(DataFromCOM).Field1.ToString); ReadLn; end.
  3. I was tired writing IncludeTrailingURLDelimiter(IncludeTrailingURLDelimiter(dir1)+dir2) ... etc. so I thought I can write a little URL Builder. As I'm a lazy dog, I did not want to go with classes, I wanted something self managed, but to have that I had to solve the auto initialization, so here I'm (see the code) Sure this is not the most resource saver solution, but this wasn't my goal. Any thoughts? Positive, negative, everything welcome, just that we can learn something. lURL := TURLBuilder.AddDir('dir').AddDir('dir2').AddFile('file'); unit URLBuilder; interface type TURLBuilder = class //record private type TURLBuilder = record private FUrl: string; public function AddDir(const ADir: string): TURLBuilder.TURLBuilder; function AddFile(const AFile: string): TURLBuilder.TURLBuilder; class operator Implicit(a: TURLBuilder.TURLBuilder): string; class operator Explicit(a: TURLBuilder.TURLBuilder): string; end; public class function AddDir(const ADir: string): TURLBuilder.TURLBuilder; static; end; function IncludeTrailingURLDelimiter(const AURL: string): string; implementation function IncludeTrailingURLDelimiter(const AURL: string): string; begin Result := AURL; if (AURL <> '') and (AURL[High(AURL)] <> '/') then Result := Result + '/'; end; { TURLBuilder } class function TURLBuilder.AddDir(const ADir: string): TURLBuilder.TURLBuilder; begin Result.FUrl := IncludeTrailingURLDelimiter(ADir); end; { TURLBuilder.TURLBuilder } function TURLBuilder.TURLBuilder.AddDir(const ADir: string): TURLBuilder.TURLBuilder; begin Result.FUrl := FUrl + IncludeTrailingURLDelimiter(ADir); end; function TURLBuilder.TURLBuilder.AddFile(const AFile: string): TURLBuilder.TURLBuilder; begin Result.FUrl := FUrl + AFile; end; class operator TURLBuilder.TURLBuilder.Explicit(a: TURLBuilder.TURLBuilder): string; begin Result := a.FUrl; end; class operator TURLBuilder.TURLBuilder.Implicit(a: TURLBuilder.TURLBuilder): string; begin Result := a.FUrl; end; end.
  4. Attila Kovacs

    Reading fields with different lenghts

    @AndrewHoward cast the data to a corresponding packed record
  5. Attila Kovacs

    Reading fields with different lenghts

    @Mike Torrettinni Woww. Even if the presented protocol is a binary one?
  6. Attila Kovacs

    Having fun with Delphi

    I don't know, it's URL not a Path, and PathSeparator etc.. are class vars, I would not touch it for a second. ah, it's a record, in this case that's what I did not find. I knew there was something but could not remember what, thx. Edit: I tried TPath.Combine and I can't alter the separator char. Either I'm missing something or it's just for file paths.
  7. Attila Kovacs

    Having fun with Delphi

    @Kas Ob. I went through all these versions in my mind, even with clearing in the class operators, but it's just not right. You also have to know the implementation details for that version. @Marat1961 There is no desire on reinventing the wheel, I would have been pleased if there were something in the RTL. The cited func works with path separators and not url separators, as far as I can see. However the suggestion by @Kryvich to introduce a TURIPart=type string; and add some helpers sounds good.
  8. Attila Kovacs

    Having fun with Delphi

    @Kryvich I'll think about #2, sounds legit. thx
  9. Attila Kovacs

    Having fun with Delphi

    @Kryvich Yes, but It's slightly different from my wishes. Dir1 Dir2 has to be TURL.
  10. Attila Kovacs

    New funcionality proposal

    I'm using A and O. And I can write it down by my own.
  11. Attila Kovacs

    Organizing enums

    He wants to _find_ the appropriate enum and not obfuscate it deeper. It should be a task for the IDE which fail big time in it, even the help provided by emba is trying to hide which are the possible values. Still, I would not say that your example is a "better way" but you are mixing variables with types. So it should be something like: type TGEnums = class type THTMLType = (htTemplate, htStatic, htHeader, htCustom); end; var x: TGEnums.THTMLType; begin x := TGEnums.THTMLType.htTemplate; --- or --- type THTMLType = (htTemplate, htStatic, htHeader, htCustom); TGEnums = class type HTMLType = THTMLType; end; var x: THTMLType; begin x := TGEnums.HTMLType.htTemplate;
  12. Attila Kovacs

    An XML DOM with just 8 bytes per node

    I just felt like with the best cow of the dairy-farm which gives 40 liters of milk then knocks over the bucket. Can't compile the code because of the inline variables 😕
  13. Attila Kovacs

    Simple inlined function question

    Well, maybe you could write a generic search class having the whole code only once in your app, but hard to give any advice without knowing the details. Just leave it as it is, it always works.
  14. Attila Kovacs

    Simple inlined function question

    move the loop into the inlinded proc
  15. Attila Kovacs

    Simple inlined function question

    Register optimization, I never put more than one test into one procedure, but the problem is the inlining introduce the extra boolean evaluation instead of just the 3 in the "if". 🤷‍♂️
  16. Attila Kovacs

    Simple inlined function question

    change the order of the 2 loops and give us the new results
  17. looks like "TsgList<T> = record" should be "TsgList<T: record> = record"
  18. Attila Kovacs

    Delphi 10.4.1 and the IDE FIx Pack

    There was a problem with the Compile Dialog as it was refreshed too frequently and since it's also themed it was very slow. I can't find anything anymore regarding this issue, maybe it has been solved since, but it's easy to check if you disable the dialog and measure the compile time. AFAIR IdeFixPack was targeting this problem too.
  19. Attila Kovacs

    Migration from BDE paradox to TFDtable or other options

    there is also https://www.componentace.com/bde_replacement_database_delphi_absolute_database.htm
  20. Attila Kovacs

    Any Known Issues with ZCompressStream?

    There are bunch of "endless loop" hits on zlib from 2015, the one in RTL has a date from 2014, maybe you should re-compress the original data and see if it happens again. That would also make others satisfied when you switch to another lib. Eventually try to decompress it with more recent zlib version. https://unix.stackexchange.com/questions/22834/how-to-uncompress-zlib-data-in-unix It would be cool to know the results.
  21. Attila Kovacs

    Cast error when using Ctrl+#

    Ctrl+# is the toggle comment menuitem on the editors context menu in the german IDE, not sure though if it has anything to do with whatever it is, but I'm sure you already checked where this "Sender" belongs to.
  22. Attila Kovacs

    Any Known Issues with ZCompressStream?

    It is no coincidence that checksums were invented.
  23. Attila Kovacs

    Button needs two clicks

    a swallowed windows message like button down / up, usually when you manipulate the focus inside events, for example
  24. Attila Kovacs

    Unit scope names in IDE - possible 2+ lines?

    Nope, it has nothing to do with santiago's except the idea is stolen. It's a working plugin without any OTA conventions so it's ugly and would be harder to maintain. But the OTA is somewhat limited to get this plugin thin and versatile, so I had to go this way. Also, getting the breakpoint list from Parnassus depends on code which was bought by emba and gone under without a ripple. 😞
×