Jump to content

David Heffernan

Members
  • Content Count

    3711
  • Joined

  • Last visited

  • Days Won

    185

Everything posted by David Heffernan

  1. David Heffernan

    Prefix unit local variable names

    a is for argument
  2. David Heffernan

    How create a website whit Delhpi

    We still have basically no idea what you are asking.
  3. Generally it's wise to try not to do this.
  4. David Heffernan

    How create a website whit Delhpi

    There are countless ways in which Delphi code may be involved in web development. If you want anybody to spend their time helping you I suggest that you spend more of your time thinking about your problem, and specifying in more detail what specifically you need help with.
  5. This has been answered above. It's the use of an intermediate string variable that holds the entire text which is then saved. And strings have 32 bit length. I'm not sure what @emailx45 is getting at but the problem you face is not due to a shortage of memory or address space. It's just that the string length is stored in a 32 variable. And a string is used by SaveToFile to save the text. FWIW, it seems wasteful to me to make an in memory copy of GBs of text just to save it. I'd be looking for a writer based approach. Just not using the raw RTL classes because of their dire performance.
  6. David Heffernan

    Multiple Instances of Python Engine

    What exactly is your rationale for wanting to use multiple engines? Why is it not possible to do this with a single engine?
  7. David Heffernan

    Generic record helper for enumeration types

    You can't have generic helpers.
  8. You don't need the if. You know that sList is not nil. Also, Free already includes a nil check. Also, there is the <> operator for not equals.
  9. Is your executable compiled with the overflow checks compiler option enabled?
  10. In what way? Can you be more specific. As for the main problem, I'm not surprised. I'd expect that you'd be better off using a stream writer to write such a huge collection to a stream. I'd submit a bug report to QP, in case on doesn't already exist, and then write some helper code to workaround the issue.
  11. David Heffernan

    null terminated string array

    Maybe, but I'm still using XE7 which is why my own code doesn't use the RTL string helper.
  12. David Heffernan

    null terminated string array

    https://quality.embarcadero.com/browse/RSP-10041 https://quality.embarcadero.com/browse/RSP-11302 Here are a couple of examples, but there are more.
  13. David Heffernan

    null terminated string array

    Good point. But I'm using XE7 and the string helper has many many bugs, including I believe in one of the split or join functions. Plus, my version minimise heap allocation.
  14. David Heffernan

    null terminated string array

    I mean. I'd start by using TRegistry. And I'd write the code myself rather than hacking at scraps found from the web.
  15. David Heffernan

    null terminated string array

    I'm sure you will be able to debug it. Good luck.
  16. David Heffernan

    null terminated string array

    Best to be clear on what you are doing here. The code seems to assume ANSI. Again are you using ANSI text?
  17. David Heffernan

    null terminated string array

    Once you get to the first double null then the rest of the data should be ignored. I'd remove everything after the first double null and then your original idea will work. You'll need to make sure you add back a double null terminator when you write it back. Are you really using ANSI text?
  18. David Heffernan

    null terminated string array

    I doubt that what your posted in your original post really is a REG_MULTI_SZ. That really is double null terminated rather than null separated.
  19. David Heffernan

    Manage overloaded IfThen functions

    This is pretty flaky mind you. Sometimes type inference works, sometimes it doesn't and you have to be explicit. It is something that may have improved in more recent releases, but IIRC some issues remain.
  20. David Heffernan

    Manage overloaded IfThen functions

    I'm not sure what looking through assembly would tell you. If performance was your motivation then you'd time the code in a realistic setting, and if it was a hotspot then you'd do something about it.
  21. David Heffernan

    null terminated string array

    That's a pretty unusual data representation. Double null-terminated strings are not uncommon on Windows at least. For what it is worth, you cannot call that null terminated, it is actually null separated. Personally, I would probably work with this sort of structure by converting to a string list and working on that internally. Then, at the interface between your code and the code that handles null separated data, convert it back to null separated. I use these methods to split and join: function Join(const Strings: array of string; Separator: Char): string; var Index: Integer; Len: Integer; Pos: Integer; begin if Length(Strings)=0 then begin Result := ''; Exit; end; Len := 0; for Index := 0 to High(Strings) do begin Inc(Len, Length(Strings[Index])); end; SetLength(Result, Len + High(Strings)); Pos := 1; for Index := 0 to High(Strings) do begin if Index>0 then begin Result[Pos] := Separator; Inc(Pos); end; Len := Length(Strings[Index]); Move(Pointer(Strings[Index])^, Result[Pos], Len*SizeOf(Char)); Inc(Pos, Len); end; end; function Split(const Str: string; Separator: Char): TArray<string>; var i, ItemIndex: Integer; len: Integer; SeparatorCount: Integer; Start: Integer; begin len := Length(Str); if len=0 then begin Result := nil; Exit; end; SeparatorCount := 0; for i := 1 to len do begin if Str[i]=Separator then begin Inc(SeparatorCount); end; end; SetLength(Result, SeparatorCount+1); ItemIndex := 0; Start := 1; for i := 1 to len do begin if Str[i]=Separator then begin Result[ItemIndex] := Copy(Str, Start, i-Start); Inc(ItemIndex); Start := i+1; end; end; Result[ItemIndex] := Copy(Str, Start, len-Start+1); end; Of course, you can work directly with the null separated strings. That will involve a function to find the index of the character at the start of the n-th item. Just loop through the string looking for the separator (null in your case). And then you can use Insert and Delete to modify the string.
  22. David Heffernan

    Manage overloaded IfThen functions

    That depends. I prefer to let the compiler choose whether or jot to inline. That seems to have better results than me doing it manually.
  23. David Heffernan

    Manage overloaded IfThen functions

    No. For static class methods it makes no difference whether its a class or a record.
  24. David Heffernan

    Manage overloaded IfThen functions

    Mine looks like this type Generic = class public class function IfThen<T>(Value: Boolean; const TrueResult, FalseResult: T): T; static; end; I don't think the name is that great, but my motivation was to use the same naming as the RTL. How I wish we could have generic functions outside of classes or records. Note that you should make this a static class method so that the class reference does not get passed.
×