-
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
22 ExcellentTechnical Information
-
Delphi-Version
Delphi 10.3 Rio
Recent Profile Visitors
-
Load and save cookies with System.Net.HttpClient, how?
0x8000FFFF replied to softtouch's topic in Network, Cloud and Web
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. -
I use ie4uinit.exe -show to refresh icon cache. Source: Refresh Icon Cache Without Rebooting
-
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.
-
Suggestion: Debugger inspection templates for complex types
0x8000FFFF replied to Lars Fosdal's topic in Delphi IDE and APIs
To add - DebuggerDisplayAttribute -
\b47\b https://regex101.com/r/FhA9Hx/1
-
Which implementation of this is easier to understand?
0x8000FFFF replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
First time I see this phrase. Makes sense. -
Why empty dynamic arrays = NIL?
0x8000FFFF replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
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. -
Why empty dynamic arrays = NIL?
0x8000FFFF replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
I'm quite happy that I don't need any string.IsNullOrEmpty all over the place in my Delphi code as opposed to C#. -
Why empty dynamic arrays = NIL?
0x8000FFFF replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
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. -
Maybe you should disable the item anyway to prevent navigating to it using arrow keys.
-
Anybody changing FileVersion directly in dproj file?
0x8000FFFF replied to Mike Torrettinni's topic in General Help
See also: How to define application version in one place for multiple applications? Delphi Version number central but other info decentral -
10.4.1+ Custom Managed Records usable?
0x8000FFFF replied to Darian Miller's topic in RTL and Delphi Object Pascal
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. -
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])); ...
-
Jolyon Smith published series of articles in his blog about integration with Azure DevOps. You'll find much useful information there.
-
What do you mean, what is the difference between 'the whole JSON string' and 'a certaing value'? Can you name some examples?