Jump to content

Rollo62

Members
  • Content Count

    1971
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by Rollo62

  1. Rollo62

    A smart case statement in Delphi?

    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
  2. 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.
  3. Rollo62

    XCode with Delphi 12.3

    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.
  4. Rollo62

    Using "Claude Code" with Delphi

    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.
  5. I'm not sleepy, 🛌💤, but always awake, with my eyelids pinned wide open ... ☕👀🤪☕☕☕
  6. Rollo62

    Minimum Viable Product (MVP)

    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.
  7. 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.
  8. 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
  9. Rollo62

    FMX Linux - the product and the company

    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.
  10. Rollo62

    Anonymous instance methods

    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);
  11. Rollo62

    IDE freezes (DelphiLSP.exe)

    Perhaps Uses KillLSP is still the way to go? https://www.delphipraxis.net/1512626-post2.html
  12. I just noticed this, maybe its interesting https://www.delphipraxis.net/217543-embarcadero-jobportal.html#post1550400
  13. Rollo62

    {$IFNDEF broken?

    Just try with GELATO to find out if its defined somewhere
  14. Rollo62

    What is the best AI at Delphi

    Never say never. There are also a lot of local, free AI models around nowadays, keeping stuff private ....
  15. 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.
  16. Rollo62

    $DEFINE: how does it work?

    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;
  17. 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
  18. Have seen it, but never checked it out before. Its on my ToDo list now
  19. 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/
  20. 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
  21. I could think of maybe parsing and replacing somehow, or edit manually at least in an easier editing system than InDesign. Im not an InDesign user, but my impression is that using InDesign as-is is a pain-in-the-.... in the first place. Maybe I'm wrong, but its not something I would love to use on a daily base.
  22. But thats not always what it is. It may be a signal word, it may be a warning sign, which is crucial to the user in user manuals. https://www.kothes.com/en/blog/creating-safety-and-warning-notices-with-the-safe-method Ok, those can be maybe set in their local language, but sometimes these icons were not repeated in each language. Thats hard to keep on track, if you have 8000 of those entries in hundrets of files. Our artwork department will be working on that alone for half a year, updating the current/older documents. I think the best way is to keep as-is and to provide a second channel of those documents, e.g. by HTML, where it will be possible to somehow auto-translate and fill those elements.
  23. Rollo62

    Can't change icons in my app

    Yes, that is some messy stuff, the icons. What I do, to avoid getting even more messy: - I made a 1:1 copy of the original Embarcadero artwork from /bin/artwork/... into a local folder to my project - This ensure that I use the same filenames as Embarcadero did, if I forget one or some changes in new versions, there is always the fallback to the Emba Icon - Then I redirect the folders ( not the filenames ) of the Icons dialog, to link to my local folder ( this can be done by search/replace in *.dproj too, if you do carefully ). - Then you might change the icons accordingly to your design, keep all dimensions, file-names, file-formats, etc., just relace the image to your design - After that, your app takes the new images (perhaps you have to de-install/re-install) the app, to make it happen. That way you don't have to fumble around with deployment at all, if its only about the original Embarcadero App Icons. You just trick the IDE to replace the original artwork by your, without even add more and more messy filenames.
  24. Even worse than that, I ask myself what happens with internationalizations? We have PDF with 27 languages in one file. How is internationalization regulated there, are there certain regulations and best practices? What I mean is, for example, an alternative text for images, for screen readers. https://www.w3.org/TR/WCAG20-TECHS/PDF1.html We sometimes have documents in 27 languages, usually with one image per language, which could be tagged internationally, which is an enourmous workload. However, there are always many images that apply directly to many languages, in the worst case for 27 languages, what measures should the alternative texts and tags be given there? It makes no sense at all to put 27 translations in one tag. Alternatively, it would be conceivable to only ever add EN as a fallback, but this would also contradict the fact that all documents should be available in all national languages in each EU country. Such EN fallback would not be OK according to WCAG 3.1.2 or EN 301 549. How could such cases be handled sensibly? Yes, the right answer is, re-structure the whole document, which also would blow up the size tremendously. Since the files are also for printed user manuals, it would mean we have to have much more size and paper waste. No matter what you do, you cannot meet all the EU regulations, because they were highly contradicing in so many single topics, best method, close your eyes and wait until you get sued Of course, the more you try to regulate, the more it gets into over-complexity and finally the opposite of the original intention. At least HTML has maybe solutions to that, even though not very easy to use: <picture><source srcset="banner-de.svg" lang="de"> … <img alt="Standort Berlin" …></picture> or you denfine, thats its a language neutral role, which would work in the least of all cases, IMHO. html <img src="check.svg" alt="" role="presentation"> My conclusion: You cannnot meet all requirements: A11y, L18n, EcoDesign( saving Paper), EUDR (do not de-forest), GPSR, User manual design (warning icons), etc. etc., but you can freely choose which regulation you would like to violate the most. Are there any other fresh ideas about these topics? I cannot believe that we are the only ones looking into this mess.
  25. Rollo62

    How do I assert a single ?

    What I wanted to say is, that even for SameValue(Value), you have to consider the Epsilon. Only because its some kind of default, it doesn't make it better, you should better know it and deal with it. https://docwiki.embarcadero.com/Libraries/Athens/en/System.Math.SameValue What exactly is reasonable and whats not, depends on the use case, like you perfectly said. Thats why I would argue, that you always shall consider it (and better set it to make it visible to the outside too). I prefer to pre-set Epsilon always by myself, to the desired value, instead of any automatic and maybe unexpectedly changing behaviour from internal structures. This is only calling for unwanted sideeffects. All this might be true, but is very scientific. Unless I cannot see a real benefit, I will stay with my decimal Epsilon, perhaps only in deeper Physics we would need different perspectives than 10^-3, ... 10^-15 or so.
×