Jump to content

0x8000FFFF

Members
  • Content Count

    25
  • Joined

  • Last visited

  • Days Won

    3

0x8000FFFF last won the day on September 27 2021

0x8000FFFF had the most liked content!

Community Reputation

21 Excellent

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

367 profile views
  1. This can't be done due to unfortunate design of TCookieManager class. The class is pretty much sealed for extension, because it lacks virtual methods. The best you can do is to apply nasty hacks or crate a QP ticket.
  2. 0x8000FFFF

    Delphi Icons with Version Info

    I use ie4uinit.exe -show to refresh icon cache. Source: Refresh Icon Cache Without Rebooting
  3. 0x8000FFFF

    Debug ISAPI on Windows 11

    I use IIS Express to debug 32/64-bit ISAPI modules by specifying iisexpress.exe as host application and /config parameter to point to ApplicationHost.config that configures web site that hosts the module.
  4. To add - DebuggerDisplayAttribute
  5. 0x8000FFFF

    Is a number in a string of numbers??

    \b47\b https://regex101.com/r/FhA9Hx/1
  6. First time I see this phrase. Makes sense.
  7. 0x8000FFFF

    Why empty dynamic arrays = NIL?

    Legacy code, libraries, defensive programming, input sanitization and normalization, data from unknown sources, ... Null-coalescing operator used with strings falls into the same category (s ?? ""). Luckily C# has made some improvements in this area by introducing nullable reference types since version 8.0.
  8. 0x8000FFFF

    Why empty dynamic arrays = NIL?

    I'm quite happy that I don't need any string.IsNullOrEmpty all over the place in my Delphi code as opposed to C#.
  9. 0x8000FFFF

    Why empty dynamic arrays = NIL?

    Isn't that the case for string? When it's empty, it's a pointer to empty, no? An empty string is equal to nil pointer. Try this: var s := ''; Writeln(Format('%p', [Pointer(s)])); One of the differences between arrays and lists is that even empty lists can have pre-allocated capacity. This is often an overlook feature of lists which helps reducing reallocations while populating the list if you know (or can estimate) the count in advance.
  10. 0x8000FFFF

    TPopupMenu with group headers

    Maybe you should disable the item anyway to prevent navigating to it using arrow keys.
  11. 0x8000FFFF

    Anybody changing FileVersion directly in dproj file?

    See also: How to define application version in one place for multiple applications? Delphi Version number central but other info decentral
  12. 0x8000FFFF

    10.4.1+ Custom Managed Records usable?

    We already have if and case statements in Delphi, we don't have expressions though. Expressions are parts of statements. Speaking of Oxygene, don't forget to mention colon operator, lambda expressions, for loop expressions, async & await (.NET only) expressions and more ... See also this Q&A that relates to the topic discussed in this thread - ternary conditional operator, null-coalescing operator (Elvis operator) and Oxygene colon operator: Escape from chain of Assigned() in Delphi It also provides some QP links of feature requests.
  13. 0x8000FFFF

    Return an array from a function??

    There is one fundamental thing missing in your function - copying the field values. The other thing is that you don't need to mess with TVarRec at all. Here's how I would do it: function RecordToArray(DS: TDataSet): TArray<Variant>; var FieldIndex: Integer; begin SetLength(Result, DS.FieldCount); for FieldIndex := 0 to DS.FieldCount - 1 do Result[FieldIndex] := DS.Fields[FieldIndex].Value; end; procedure ArrayToRecord(DS: TDataSet; const Values: TArray<Variant>); var FieldIndex: Integer; begin Assert(DS.FieldCount = Length(Values)); for FieldIndex := 0 to DS.FieldCount - 1 do DS.Fields[FieldIndex].Value := Values[FieldIndex]; end; Another option is to use variant array: function RecordToVarArray(DS: TDataSet): Variant; var FieldIndex: Integer; Data: PVariant; begin Result := VarArrayCreate([0, DS.FieldCount - 1], varVariant); Data := VarArrayLock(Result); try for FieldIndex := 0 to DS.FieldCount - 1 do begin Data^ := DS.Fields[FieldIndex].Value; Inc(Data); // move to next elemnt in resulting array end; finally VarArrayUnlock(Result); end; end; procedure VarArrayToRecord(DS: TDataSet; const Values: Variant); var FieldIndex: Integer; Data: PVariant; begin Assert(VarIsType(Values, varArray or varVariant)); Assert(VarArrayDimCount(Values) = 1); Data := VarArrayLock(Values); try for FieldIndex := 0 to DS.FieldCount - 1 do begin DS.Fields[FieldIndex].Value := Data^; Inc(Data); // move to next elemnt in resulting array end; finally VarArrayUnlock(Values); end; end; // you could then access those value using index: var Values := RecordToVarArray(DS); Writeln(VarToStr(Values[0])); Writeln(VarToStr(Values[1])); ...
  14. 0x8000FFFF

    Delphi and Azure DevOps?

    Jolyon Smith published series of articles in his blog about integration with Azure DevOps. You'll find much useful information there.
  15. 0x8000FFFF

    UnEscape JSON string

    What do you mean, what is the difference between 'the whole JSON string' and 'a certaing value'? Can you name some examples?
×