

Rollo62
Members-
Content Count
1976 -
Joined
-
Last visited
-
Days Won
26
Everything posted by Rollo62
-
A smart case statement in Delphi?
Rollo62 replied to PeterPanettone's topic in RTL and Delphi Object Pascal
Two places, I would say, thats what I noted above regarding its disadvantage. I'm fully aware of its pros and cons, it was just a proof of concept, but it works not that bad, I must say. The main usefulness perhaps comes from its wildcard and RegEx options and its general good readability, IMHO, while its not the most pure string to case solution of course. This was just a fast hack yesterday, combining my thoughts over some years, if this would makes sense or not, just think about that problem a bit deeper. Right, it doesn't replace a real, native string case of, but perhaps it has its place in the world too. True, that why I considered a combination with the enum type too, that should be easy to add and extend to the former enum proposals. All these "case TRttiEnumerationType<TMyStrings>.GetValue(s) of" solutions, I would see more related to enums, than to the original demand of a "case-of" implementation. They need perhaps even more than two pre-definitions and more code distributed over the whole unit, with defining specific enum types. To use kindof fluent interface with anonymous methods would work perfectly too, but thats way too far from the case-of look-and-feel I am thinking of. There are some ideas, but all of them has a lot of pros and cons, hard to find the sweet spot, for a general "case-of" implementation -
Interesting, do you have a small sample how you get this running? Its quite a messy protocol https://gpsd.gitlab.io/gpsd/NMEA.html#_talker_ids I wonder, what subset of the data will be available over Android phones, I think the phones will miss out a lot of data, right?
-
Thanks, that looks good, but I'm unsure if this is only working under Win11. It only tells us Win11 ready, but nothing about MacOS. My setup is on a MacBook (Intel x86), running Parallels Desktop VM with Windows and Delphi, when debugging on the MacOS hardware it was always possible to access the Mac's BT device when running on this. There three scenarios, I would think: A.) MacOS -> PLS -> Win11 -> Delphi -> Debugging on MacOS hardware -> Accessing MacOS BLE shall be possible still ( I hope so ) B.) MacOS -> PLS -> Win11 -> Delphi -> Debugging on Win11 VM -> Accessing original MacOS BLE through PLS -> seems to be gone in the future C.) MacOS -> PLS -> Win11 -> Delphi -> Debugging on Win11 VM -> Accessing BLE dongle via MacOS -> PLS making BLE dongle available in Win11 VM -> You mean this? Does such Asus BLE dongle works for the Mac too, or doesn't it need to work under MacOS as it is handled by Win11 alone? I've tried years ago to find some working dongle and gave up, as it is nearly impossible to get clear answers to the BLE dongle compatibility. At that time, it was only said possible by a specific Allpe-compatible chipset and some hacky driver installation, as far as I remember.
-
Hi there, I have see a new not that Parallels 26 is available, but with some not so nice news. It says, translated from German: One of my main functions was to use MacOS as a last resort for debugging iOS BLE devices and their protocols. Because the MacOS and iOS Bluetooth systems are fairly compatible, this has been a 100% error-free option up to now. According to the text above, this now seems to be a thing of the past. An external dongle brings with it a 99% probability of further new errors and problems during debugging, and 1:1 behavior between macOS and iOS may no longer be guaranteed. Because multi-platform debugging under Delphi is currently almost completely unusable anyway, this is my last hope for testing external Bluetooth devices (Android debugging is extremely unreliable, iOS debugging has not been possible for some time, and macOS debugging has still been possible until now). Yes, there is still the option of debugging under Windows with a BLE dongle, but that was also relatively tricky and not really compatible with iOS/Android, etc. It starts with finding a compatible BLE dongle that works with Windows/macOS. Does anyone else have the same concerns as me? Maybe there are already solutions for this, or, at best, everything still works as before under PLS 26? BTW: I'm still working on an Intel MacOS, which maybe also behaves different to the M1, regarding external BLE-Dongles.
-
A smart case statement in Delphi?
Rollo62 replied to PeterPanettone's topic in RTL and Delphi Object Pascal
Here the file, belongs to previous post. CaserTest.zip -
A smart case statement in Delphi?
Rollo62 replied to PeterPanettone's topic in RTL and Delphi Object Pascal
Here is another update, with registration of group patterns and guard options. Usable like this: procedure TMainFrm.SimpleWhenExample; begin Log_Memo('=== RegEx Pattern Matching Example ==='); var LCaser := TS4Caser_Factory.New( True, -1 ); LCaser .Register( 1, 'aaa' ) .Register( 2, 'bbbb' ) .Register( 3, 'ccc' ) .Register( 4, 'aa' ) ; var LTest := 'ccc'; case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); 4: Log_Memo( 'aa matched' ); else Log_Memo( 'nothing matched to ' + LTest ); end; LTest := 'bbb'; case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); 4: Log_Memo( 'aa matched' ); else Log_Memo( 'nothing matched to ' + LTest ); end; LTest := 'bbbb'; case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); 4: Log_Memo( 'aa matched' ); else Log_Memo( 'nothing matched to ' + LTest ); end; LTest := 'aa'; case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); 4: Log_Memo( 'aa matched' ); else Log_Memo( 'nothing matched to ' + LTest ); end; // // GUARD: Ignore <= 2 char lengths // LCaser .WhenAny( function ( const AValue : string ) : Boolean begin if AValue.Length > 2 then Result := True else Result := False; end ) ; LTest := 'aaa'; case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); 4: Log_Memo( 'aa matched' ); else Log_Memo( 'nothing matched to ' + LTest ); end; LTest := 'aa'; //! This ís guarded ( len <= 2 ) case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); 4: Log_Memo( 'aa matched' ); else Log_Memo( 'nothing matched to ' + LTest ); end; end; // Example 2: OR-Pattern for groups procedure TMainFrm.SimpleOrExample; var Command : string; LCaser : IS4Caser; begin Log_Memo( '=== OR Patterns Example ==='); LCaser := TS4Caser_Factory.New( False, -1 ); // RegisterOr: Mehrere exakte Alternativen für gleichen Index LCaser .RegisterOr( 1, ['start', 'run', 'begin', 'launch', 'execute']) .RegisterOr( 2, ['stop', 'halt', 'end', 'terminate', 'kill', 'abort']) .RegisterOr( 3, ['pause', 'suspend', 'hold', 'freeze']) .RegisterOr( 4, ['resume', 'continue', 'unpause', 'thaw']); // RegisterWildcardOr: Mehrere Wildcard-Pattern LCaser .RegisterWildcardOr(10, ['config_*', 'cfg_*', 'setting_*']) .RegisterWildcardOr(11, ['log_*', 'trace_*', 'debug_*']); Command := 'execute'; case LCaser.Match(Command) of 1: Log_Memo( ' Service startet: ', Command); 2: Log_Memo( ' Service estopped: ', Command); 3: Log_Memo( 'â¸ï¸Service paused: ', Command); 4: Log_Memo( 'â–¶ï¸ Service resumed: ', Command); 10: Log_Memo( 'âš™ï¸Config-Command: ', Command); 11: Log_Memo( ' Logging-Command: ', Command); else Log_Memo('â“ Unknown command: ', Command); end; Command := 'halt'; case LCaser.Match(Command) of 1: Log_Memo( ' Service startet: ', Command); 2: Log_Memo( ' Service estopped: ', Command); 3: Log_Memo( 'â¸ï¸Service paused: ', Command); 4: Log_Memo( 'â–¶ï¸ Service resumed: ', Command); 10: Log_Memo( 'âš™ï¸Config-Command: ', Command); 11: Log_Memo( ' Logging-Command: ', Command); else Log_Memo('â“ Unknown command: ', Command); end; Command := 'suspend'; case LCaser.Match(Command) of 1: Log_Memo( ' Service startet: ', Command); 2: Log_Memo( ' Service stopped: ', Command); 3: Log_Memo( 'â¸ï¸Service paused: ', Command); 4: Log_Memo( 'â–¶ï¸ Service resumed: ', Command); 10: Log_Memo( 'âš™ï¸Config-Command: ', Command); 11: Log_Memo( ' Logging-Command: ', Command); else Log_Memo('â“ Unknown command: ', Command); end; Command := 'go'; case LCaser.Match(Command) of 1: Log_Memo( ' Service startet: ', Command); 2: Log_Memo( ' Service estopped: ', Command); 3: Log_Memo( 'â¸ï¸Service paused: ', Command); 4: Log_Memo( 'â–¶ï¸ Service resumed: ', Command); 10: Log_Memo( 'âš™ï¸Config-Command: ', Command); 11: Log_Memo( ' Logging-Command: ', Command); else Log_Memo('â“ Unknown command: ', Command); end; Command := 'config_database'; case LCaser.Match(Command) of 1: Log_Memo(' Start-Command: ', Command); 10: Log_Memo('âš™ï¸Configuration in progress: ', Command); 11: Log_Memo(' Log-Command: ', Command); else Log_Memo('â“ Unknown Command: ', Command); end; end; -
A smart case statement in Delphi?
Rollo62 replied to PeterPanettone's topic in RTL and Delphi Object Pascal
Good question. This had been on my mind for quite some time, so I tried to come up with a universal solution that would be as painless as possible. Here is the first draft. I welcome feedback and suggestions for improvement. A real case is hardly possible, except in Delphi itself, I had been racking my brains over this for a long time. Neither attributes nor other tricks will get you very far. I found the most painless way for me, see the attachment, which unfortunately consists of two phases: 1. Definition of the cases 2. The actual match case, but with integer values This preserves the case feeling and adds RegEx and wildcard matches as a bonus. Just in short, as simple example, with direkt pattern-match var LCaser := TS4Caser_Factory.New( True, -1 ); LCaser .Register( 1, 'aaa' ) .Register( 2, 'bbb' ) .Register( 3, 'ccc' ) ; var LTest := 'ccc'; case LCaser.Match( LTest ) of 1: Log_Memo( 'aaa matched' ); 2: Log_Memo( 'bbb matched' ); 3: Log_Memo( 'ccc matched' ); else Log_Memo( 'nothing matched' ); end; buit it can do much more, in a similar, easy to handle RegEx style LCaser := TS4Caser_Factory.New( True, -1 ); // RegEx Pattern registrieren - viel mächtiger als einfache Strings! LCaser .RegisterRegex( 1, '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$') // E-Mail .RegisterRegex( 2, '^\d{3}-\d{2}-\d{4}$') // SSN Format .RegisterRegex( 3, '^(\+49|0)[1-9]\d{1,4}\s?\d{1,12}$') // Deutsche Telefonnummer .RegisterRegex( 4, '^https?://(?:[-\w.])+(?::\d+)?(?:/(?:[\w/_.])*)?(?:\?(?:[\w&=%.])*)?(?:#(?:\w*))?$'); // URL EmailInput := 'test@example.com'; case LCaser.Match( EmailInput ) of 1: Log_Memo('✓ Valid E-Mail-: ', EmailInput); 2: Log_Memo('✓ Valid SSN: ', EmailInput); 3: Log_Memo('✓ Valid German Phone no.: ', EmailInput); 4: Log_Memo('✓ Valid URL: ', EmailInput); else Log_Memo('✗ Unknown Format: ', EmailInput); end; EmailInput := '+491234567890'; case LCaser.Match( EmailInput ) of 1: Log_Memo('✓ Valid E-Mail-: ', EmailInput); 2: Log_Memo('✓ Valid SSN: ', EmailInput); 3: Log_Memo('✓ Valid German Phone no.: ', EmailInput); 4: Log_Memo('✓ Valid URL: ', EmailInput); else Log_Memo('✗ Unknown Format: ', EmailInput); end; Log_Memo; // RegEx with Capture Groups LCaser.Clear; LCaser.RegisterRegex( 10, '^(\d{4})-(\d{2})-(\d{2})$' ); // Date YYYY-MM-DD LIndex := LCaser.MatchWithCaptures( '2024-03-15', LCaptures ); if LIndex = 10 then begin Log_Memo('✓ Date recognized:'); Log_Memo(' Year: ', LCaptures[0]); Log_Memo(' Month: ', LCaptures[1]); Log_Memo(' Day: ', LCaptures[2]); end; Or with Wildcards too LCaser := TS4Caser_Factory.New( False, 0 ); // Case insensitive // Wildcard Pattern registrieren (* und ? Unterstützung) LCaser .RegisterWildcard( 1, '*.txt') // Alle .txt Dateien .RegisterWildcard( 2, '*.doc*') // .doc, .docx, etc. .RegisterWildcard( 3, 'temp_?.log') // temp_1.log, temp_a.log, etc. .RegisterWildcard( 4, 'backup_*.*') // backup_xyz.abc .RegisterWildcard( 5, '*.jp*g'); // .jpg, .jpeg FileName := 'document.DOCX'; case LCaser.Match( FileName ) of 1: Log_Memo('📄 Text-File: ', FileName); 2: Log_Memo('📝 Word-Document: ', FileName); 3: Log_Memo('📋 Temporal Log-File: ', FileName); 4: Log_Memo('💾 Backup-File: ', FileName); 5: Log_Memo('🖼️JPEG-Image: ', FileName); 0: Log_Memo('❓ Unknown file: ', FileName); else Log_Memo('❌ Error at file recognition: ', FileName); end; FileName := 'backup_123.456'; case LCaser.Match( FileName ) of 1: Log_Memo('📄 Text-File: ', FileName); 2: Log_Memo('📝 Word-Document: ', FileName); 3: Log_Memo('📋 Temporal Log-File: ', FileName); 4: Log_Memo('💾 Backup-File: ', FileName); 5: Log_Memo('🖼️JPEG-Image: ', FileName); 0: Log_Memo('❓ Unknown file: ', FileName); else Log_Memo('❌ Error at file recognition: ', FileName); end; FileName := 'image/folder/pic.jpg'; case LCaser.Match( FileName ) of 1: Log_Memo('📄 Text-File: ', FileName); 2: Log_Memo('📝 Word-Document: ', FileName); 3: Log_Memo('📋 Temporal Log-File: ', FileName); 4: Log_Memo('💾 Backup-File: ', FileName); 5: Log_Memo('🖼️JPEG-Image: ', FileName); 0: Log_Memo('❓ Unknown file: ', FileName); else Log_Memo('❌ Error at file recognition: ', FileName); end; Is this closer to the function you were looking to? Let me know, if you could find improvements or a easier, better solution. CaserTest.zip -
Not without carefully checking what might breakdown before and why exactly you wanna do this. The way back is made a bit hard, by Apple, better be shure if you upgrade. Avoid also the Beta-Versions, which can cause much trouble too.
-
I'm not using it with Delphi directly (yet), but still with some HTML, JS, PHP, Python, etc., to see what performance to get. Still in a phase of extended testing of different AI systems, so to speak. I'm using Claude Code and Cursor as well, and both are really impressive, but my experience ist that they worked best, if you design from ground up. Cursor has a really amazing workflow and really good outcome, IMHO, but its a little unclear to me if Claude is behind, or not. If you throw them on a larger, existing projects, it works too, but struggles more often than on new projects. I' going to switch to use it with Delphi too, in the near future, I'm curious what brings the next level of Claude.
-
suggestion for 2 new su forum: AI usage and AI coding
Rollo62 replied to Javier Tarí's topic in Community Management
I'm not sleepy, 🛌💤, but always awake, with my eyelids pinned wide open ... ☕👀🤪☕☕☕ -
The whole discussion here is only based as the technical/functional view on such system, forgetting that there is also a similar large legal view on these products (even including hardware and security requirements and whats not ...). The big problem is that the legal parts may completely destroy what your technical part has in favor, at least in the EU, so you were always forced to consider them together.
-
What new features would you like to see in Delphi 13?
Rollo62 replied to PeterPanettone's topic in Delphi IDE and APIs
Yes, very interesting thought. I would fully agree, but I have only the question "... but how ... ?". If this only means to have a full fledged HTML, JS, CSS, Markdown Editor page in the IDE, I should be realistic and must propose to better switch to VsCode instead. Or do you have other "web technology" thoughts in mind, more under the hood? And yes, at least a full fledged WYSIWYG Markdown editor page would be a great improvement in the IDE, as well as maybe accompanied Markdown access components, but there were more important topics first, IMHO. -
EU Accessibility Act (EAA) / BFSR BarrierefreiheitsGesetz - Generate PDF/UA from HTML
Rollo62 posted a topic in General Help
Hi there, I’d like to ask if anyone here has experience working with A11y (accessibility): https://www.bmas.de/DE/Service/Gesetze-und-Gesetzesvorhaben/barrierefreiheitsstaerkungsgesetz.html https://commission.europa.eu/strategy-and-policy/policies/justice-and-fundamental-rights/disability/union-equality-strategy-rights-persons-disabilities-2021-2030/european-accessibility-act_en This also concerns PDF files, such as data sheets, catalogs, EU declarations of conformity, and so on. PDFs are not accessible by default; there is PDF/UA for that, and PAC is a good testing tool. https://pac.pdf-accessibility.org I’m specifically facing the issue that I generate pages in HTML and then convert them to PDF. However, the PDF/UA-relevant entries are often lost during this conversion. Has anyone experienced similar problems with HTML-to-PDF conversion? Maybe there are good tips and/or tools for this process? Yes, I could generate PDFs directly with Delphi, but that would require a complete overhaul in so many places that I’m hoping it can also work with HTML. I’ve also cross-posted this in the DE-DelphiPraxis. https://www.delphipraxis.net/217301-bfsr-barrierefreiheitsges-eu-accessibility-act-eaa-pdf-ua-aus-html-generieren.html#post1549264 -
There have been some discussion here and in the German DP, but best of all, there is an official announcment. https://blogs.embarcadero.com/fmx-linux-for-delphi-12-3-is-now-available/ https://www.delphipraxis.net/216783-fmx-linux-kennt-jemand-den-aktuellen-stand.html#post1546803 https://en.delphipraxis.net/topic/12288-fmxlinux-missing/?tab=comments#comment-102324 It should be available in summer, as arnof reported from the 12.3 introduction.
-
Yes, thats nice and useful, you can also extend this a bit, to avoid dangling pointers. See these rough ideas ... destructor TAnonProc.Destroy; begin if (Owner is TButton) and (TMethod(TButton(Owner).OnClick).Data = Self) then begin TButton( Owner ).OnClick := nil; // Ensure to remove dangling Pointer end; inherited; end; or you could even separate the Owner from the Observer type TAnonProc = class(TComponent) private FProc: TProc<TObject>; procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure OnSender(Sender: TObject); public constructor Create(AOwner, AObserved: TComponent; AProc: TProc<TObject>); end; constructor TAnonProc.Create(AOwner, AObserved: TComponent; AProc: TProc<TObject>); begin inherited Create(AOwner); // Owner = Form FProc := AProc; AObserved.FreeNotification(Self); // register observer if AObserved is TButton then TButton(AObserved).OnClick := OnSender; end; procedure TAnonProc.Notification(AComponent: TComponent; Operation: TOperation); begin if (Operation = opRemove) and (AComponent is TButton) then begin TButton(AComponent).OnClick := nil; // Clear the Pointer end; inherited; end; procedure TAnonProc.OnSender(Sender: TObject); begin if Assigned(FProc) then FProc(Sender); end; //.......................... TAnonProc.Create(Self, Button1, procedure(Sender: TObject) begin Caption := 'Click!'; end);
-
Perhaps Uses KillLSP is still the way to go? https://www.delphipraxis.net/1512626-post2.html
-
Delphi Developer Job Offer (Germany) / Delphi entwickler
Rollo62 replied to NR2024's topic in Job Opportunities / Coder for Hire
I just noticed this, maybe its interesting https://www.delphipraxis.net/217543-embarcadero-jobportal.html#post1550400 -
Just try with GELATO to find out if its defined somewhere
-
Never say never. There are also a lot of local, free AI models around nowadays, keeping stuff private ....
-
Set font size automatically depending on display size
Rollo62 replied to stewag64's topic in Cross-platform
Interesting approach. 👍 Don't you get then varying font sizes for each control, by differing MaxWidths? How do you control that there is a unique look-and-feel, do you use always the same width spaces for all components? Maybe you have some screenshots available, to get a better idea. -
As explained above, define work top-down as compiletime, pretty much as the "defines" in C/C++. This is very useful since you can switch between certain code behaviour parts, include or not to compile, depending on a compiletime defined condition. //Can be used with DEFINED() in a more speaking, checkbox-like version {$DEFINE ___USE_THE_BO_VARIANT } {$DEFINE _X_USE_THE_MO_VARIANT } {$DEFINE ___USE_THE_ZO_VARIANT } FUNCTION DOTHERPORT; BEGIN {$ifDEF _X_USE_THE_BO_VARIANT} result :=DoCharges(true,-1,false,False,false,lg('CLOSE CHARGES'),'1',dm2.sysdate.fieldbyname('date').asdatetime) {$else} result := DoCharges(sender=Nil,-1,False,False,FALSE,lg(TDsFancyButton(Sender).Caption),'',0,dm2.sysdate.fieldbyname('date').asdatetime); {$endif} END; //Or maybe in mode complex scenarios, as switch/case-like option, like this FUNCTION DOTHERPORT2; BEGIN {$if DEFINED( _X_USE_THE_BO_VARIANT ) } result :=DoCharges(true,-1,false,False,false,lg('CLOSE CHARGES'),'1',dm2.sysdate.fieldbyname('date').asdatetime) {$elseif DEFINED( _X_USE_THE_MO_VARIANT ) } result := DoCharges(sender=Nil,-1,False,False,FALSE,lg(TDsFancyButton(Sender).Caption),'',0,dm2.sysdate.fieldbyname('date').asdatetime); {$elseif DEFINED( _X_USE_THE_ZO_VARIANT ) } result :=DoCharges(true,-1,false,False,false,lg('ZOOOO'),'1',dm2.sysdate.fieldbyname('date').asdatetime) {$else } result :=DoCharges(true,-1,false,False,false,lg('NOTHING ELSE MATTERS'),'1',dm2.sysdate.fieldbyname('date').asdatetime) {$endif} END;
-
RESTDebugger fails where Postman succeeds
Rollo62 replied to dcroghan's topic in Network, Cloud and Web
I was curious how far you can get with the newer System.Net.HttpClient, System.Net.HttpClientComponent, System.Net.URLClient. It seems quite limited, perhaps the good old Indy might have more tricks up its sleeve. TNetHTTPClient TRESTClient and friends are not so verbose in regards of internal stream data. Perhaps a combination of both can get more insights about the underlying data streams? T526_RestDebug_002.zip -
RESTDebugger fails where Postman succeeds
Rollo62 replied to dcroghan's topic in Network, Cloud and Web
Have seen it, but never checked it out before. Its on my ToDo list now -
RESTDebugger fails where Postman succeeds
Rollo62 replied to dcroghan's topic in Network, Cloud and Web
Not that it solves your RestDebugger but, but there is also a nice tool Bruno, which might help to dig deeper. https://www.usebruno.com/ -
How to Use ONNX Runtime in Delphi for Object Detection
Rollo62 replied to Serge Pilko's topic in Tips / Blogs / Tutorials / Videos
Nice demo. 👍 Perhaps you forgot to mention that its available on GetIt https://getitnow.embarcadero.com/delphi-yolo-onnx-runtime-wrapper/ and on GitHub https://github.com/SoftacomCompany/Delphi-YOLO-ONNX-RuntimeWrapper and Medium https://medium.com/@softacom.com/object-detection-in-delphi-with-onnx-runtime-2b1e28b0e1b3