

Der schöne Günther
Members-
Content Count
731 -
Joined
-
Last visited
-
Days Won
12
Everything posted by Der schöne Günther
-
json Trouble getting JSON FindValue (JSONPath) to work
Der schöne Günther replied to omnibrain's topic in Network, Cloud and Web
Take at the look at the documentation again, it has some examples. Get Rid of the $ and the dot. program Project1; uses System.SysUtils, System.JSON; begin var myjson:=TJSONObject.ParseJSONValue('{"name": "Chris","value": 10000}'); var myval:=myjson.FindValue('name'); Assert(myVal.Value() = 'Chris'); end. Or here, with arrays: program Project1; uses System.SysUtils, System.JSON; const json = '{'+ ' "name": "Chris",'+ ' "pets": ['+ ' {'+ ' "name": "Rufus",'+ ' "type": "dog",'+ ' "age": 10'+ ' },'+ ' {'+ ' "name": "Wraabargl",'+ ' "type": "Dinosaur",'+ ' "age": 113'+ ' }'+ ' ]'+ '}'; begin var myjson:=TJSONObject.ParseJSONValue(json); var myval:=myjson.FindValue('pets[1].type'); Assert(myVal.Value() = 'Dinosaur'); readln; end. -
Without more context, it's impossible to say what is wrong in your case. I was very pleasantly surprised when I updated on of our XE7 applications to 10.4 in order to support High DPI. It took me a few days, but everything seemed logical (I had to make a few small changes where the UI used a hard coded number of pixels) - And in the end, it turned out to be great.
-
Newly released book: Delphi Legacy Projects
Der schöne Günther replied to Bill Meyer's topic in Tips / Blogs / Tutorials / Videos
Same here. I can hardly see myself buying a textbook on paper ever again. Also, don't forget syncing your position. I really like to read something on my computer, or Kindle, and half a day later, I can continue reading on my phone, exactly where I left off. -
Its homepage has a lot of encoding errors (at least in my language), I don't remember when I last saw pictures of CD ROMs on web pages and the text advertises it to be compatible with Delphi 7 and Delphi 2006. Go figure. Delphi comes with FireDAC memory tables that support SQL. Local SQL (FireDAC) - RAD Studio (embarcadero.com) Delphi 10.2: Using Local SQL with Firedac Memory Tables - Stack Overflow
-
The voice recognition capabilities of SAPI are horrible, compared with what other technologies offer today. I'm sure it was fine when it was last updated 15 years ago, but as of today, it fails to even meet the most humble expectations.
-
Enable continuous dictation - Windows apps | Microsoft Docs Delphi How To Use Microsoft Speech Recognition API - Stack Overflow
-
Newly released book: Delphi Legacy Projects
Der schöne Günther replied to Bill Meyer's topic in Tips / Blogs / Tutorials / Videos
Amazon in my country lists it as "Currently not available, unknown when it will be". 😐 Please consider at least some kind of PDF. Kindle, however, would be much appreciated. It's just so incredibly comfortable, and other coding books have this option as well. -
Do you need an ARM64 compiler for Windows?
Der schöne Günther replied to Lars Fosdal's topic in Cross-platform
I have lost track for how many times Microsoft has tried to push Windows on ARM, advertised something great, but in the end, nothing of importance happened. It's not that I have anything against Windows on ARM, but if I want a good ARM based computer, I'm getting a M1 Mac. So, do I need an Windows/ARM64 compiler for RAD Studio? No. Embarcadero should rather focus on core functionality and the many platforms we already have. We don't need another one. -
pageControl
Der schöne Günther replied to abdellahmehdi's topic in Algorithms, Data Structures and Class Design
Vcl.ComCtrls.TTabSheet.TabVisible - RAD Studio API Documentation (embarcadero.com) -
A year or two ago, I used NPOI (.NET) for exporting to an excel sheet with formulas and different formats. It was a breeze NuGet Gallery | NPOI 2.5.6 nissl-lab/npoi: a .NET library that can read/write Office formats without Microsoft Office installed. No COM+, no interop. (github.com) Free, widely used, but not in Delphi. You'd have to go with .NET and include that in your Delphi app.
-
Rounded polygon
Der schöne Günther replied to A.M. Hoornweg's topic in Algorithms, Data Structures and Class Design
Bézier curve - Wikipedia -
TIP for Creating PDF Files from HTML / Image
Der schöne Günther replied to microtronx's topic in RTL and Delphi Object Pascal
Not sure where you got that from, browsers can do that perfectly fine. Here is an example with TEdgeBrowser and no additional libraries in Delphi: Printed, for example, in landscape orientation: -
TortoiseGit with Delphi 10 Seattle
Der schöne Günther replied to karl Jonson's topic in General Help
TortoiseGit is not Git! Quote from the official documentation:- 10 replies
-
TIP for Creating PDF Files from HTML / Image
Der schöne Günther replied to microtronx's topic in RTL and Delphi Object Pascal
WebView2 (used by TEdgeBrowser) can directly print to PDF, just saying. -
Don't want to be a party pooper, but I never saw the reason for having detailed stack traces. Tests should fail for exactly one reason. If you have a bunch of entirely different checks in your test case and struggle to find out what exactly failed, there's something wrong. Better split them up in seperate tests. I am still on DUnit and have never really used DUnitX, but can't you debug a test? That should easily tell you what, and where something is going wrong. The fabulous "Test Insight" plugin from Stefan allows you to directly debug the test at your cursor position with [Alt]+[F9] sglienke / TestInsight / wiki / Home — Bitbucket
-
The reason is that function GetDay(dt: TDateTime) doesn't yet know about the other overload. You either have to replace their order or, better, add a definition like you did when you added their definition in the interface section of the unit.
-
Cast an array of numbers to array of bytes without re-allocating
Der schöne Günther posted a topic in Algorithms, Data Structures and Class Design
I have some API that allocates and returns a TArray<Word>. I would then like to process this array with a library that operates exclusively on TArray<Byte>. How can I cast my_word_array to my_byte_array without re-allocating space for a new array and then copying the entire content over? My only idea so far was a clunky workaround using the absolute directive and manually overwriting the array's length indicator in memory: procedure changeLengthIndicator(const firstElement; const newLength: NativeInt); var ptr: PNativeInt; begin // Source regarding memory layout: // https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Internal_Data_Formats_(Delphi)#Dynamic_Array_Types ptr := Addr(firstElement); Dec(ptr); //set pointer to length indicator ptr^ := newLength; end; procedure p(); var words: TArray<Word>; bytes: TArray<Byte> absolute words; byteCount: NativeInt; begin words := [$0FF0, $FEFE, $0000, $0001, $ABAB]; byteCount := Length(words) * SizeOf(Word); changeLengthIndicator(bytes[0], byteCount); processBytes(bytes); end; Is there a better option? Unfortunately, there is no making sure no one will use the words array after the call to changeLengthIndicator(..). -
Cast an array of numbers to array of bytes without re-allocating
Der schöne Günther replied to Der schöne Günther's topic in Algorithms, Data Structures and Class Design
Of course. That's what unit tests are for 😎 True. Or, even better and less c-like, IEnumerable<Byte> -
Cast an array of numbers to array of bytes without re-allocating
Der schöne Günther replied to Der schöne Günther's topic in Algorithms, Data Structures and Class Design
That's actually an interesting idea. It will store if it's in "byte" or "word" mode, and if you're trying to get the "wrong" data, it will instead throw a runtime exception. That's certainly better than what I have right now. -
Cast an array of numbers to array of bytes without re-allocating
Der schöne Günther replied to Der schöne Günther's topic in Algorithms, Data Structures and Class Design
No, using the absolute variable does not increase the array's reference count. See this snippet: Project1.dpr · GitHub -
Cast an array of numbers to array of bytes without re-allocating
Der schöne Günther replied to Der schöne Günther's topic in Algorithms, Data Structures and Class Design
It will overwrite the second half of the existing data with zeroes because it considers it "newly allocated" System.SetLength - RAD Studio API Documentation (embarcadero.com) -
That does not sound typical at all. I don't know about Android, but on iOS you can either scroll by swiping on the space key, or by tap and holding within the text area. It is not a problem at all.
-
Does anyone know how to get the filesystem for usb mass storage?
Der schöne Günther replied to wilsonning's topic in FMX
Since he/he said "FMX" and an posted an Android screenshot, I think a "Windows only" solution will not help. -
Strange Benchmark Results; Am I Missing Something?
Der schöne Günther replied to Joseph MItzen's topic in I made this
Just for your information, the following snippet in Rust was around 1250 ms on my system. Compilation about 1 second. fn main() { let mut total: u64 = 0; for number in 1..=1000000000 { if ((number % 3) == 0) || ((number % 5) == 0) { total += number; }; } println!("total is {}", total); } The Delphi implementation was around 7.5 seconds on this machine. -
Doesn't TIniFile fall back to some extremely ancient Windows methods? I would have expected an encoding problem with your text file. Can you provide the original .ini file?