Jump to content

Darian Miller

Members
  • Content Count

    560
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by Darian Miller

  1. Darian Miller

    Organizing enums

    In your example, HTML is a field variable of the TReportEnums structure with the specific type defined to be THTMLType. You are trying to access it as an Enumeration and not as a variable. Delphi offers meta classes where you can define a variable to be a class type such as: TMySomethingClass = class of TMySomething, and you can define a variable of type TMySomethingClass, but this only works with classes. AFAIK there's no similar thing for records. Not a great solution, but if you could group your defines in one class you could get code completion from a master class like: TMasterRecordTypes = class type THTMLType = (htTemplate, htStatic, htHeader, htCustom); TSecondRecordType = (srOne, srTwo, srThree); end; vHTMLReportType := TMasterRecordTypes.THTMLType.htTemplate; Or just put all your related record types into a particular unit and use the unit name as the scope, which is how it's normally done. vHTMLReportType := MyUnitName.THTMLType.htTemplate;
  2. Issue created, status is waiting on further demand before action is taken: https://gitlab.com/gitlab-org/gitlab/-/issues/254725 GitLab offers built-in SAST support for many languages and suggest creating an issue to add support for any dev language. Issue created, just need your votes!
  3. You seem highly concerned about performance implications - so measure the performance. Simulate a million (or whatever constitutes a significant amount) receipts of randomized sample data and measure your few possible implementations. If you find very little difference, then pick the one that is easiest for your team to extend and maintain. If your original source is TBytes, and perhaps your output source is TBytes, then introducing any conversions seems wasteful, but gut feelings should only act as a general guide. You either measure or you keep guessing. If you keep guessing, you may accidently determine if it's (currently) providing acceptable performance.
  4. Darian Miller

    Double-dabble to convert binary to decimal

    Literally LOL. Thanks. I'll try to absorb it! 🙂
  5. Darian Miller

    Double-dabble to convert binary to decimal

    Thanks, that was also pointed out by others online and it will likely be in a follow-up article. I simply didn't know about the double-dabble trick and thought it was kinda cool. I don't do these number system conversions enough to be able to convert any lengthy amount in my head yet. Lately I've been attempting to spend a lot more time learning rather than just always doing. Unfortunately, I was always the work-harder and not the work-smarter type. Few could out-work me, but many could out-smart me. I want to combine the two, and maybe the next buyout will have an extra zero or two behind it. Or, I'll simply enjoy it more. Either way, it's a win.
  6. Darian Miller

    Automatically killing a service when stuck

    I like using child processes. The main windows service process starts two processes: a task launcher and a server updater. 1) Windows service process: Launcher thread simply runs the child task-launcher and optionally the server-updater processes. Main process thread waits for service stop/shutdown signal. If detected, signal its launcher thread to terminate. Terminate the windows service process once launcher thread terminates (or timeout reached and child processes are forcibly terminated.) 2) Task-launcher process: For each externally configured task worker process to be launched: Look for update of task worker executable. If update available, install (typically just a simple .exe copy) If no update, or after update is completed, launch the task worker process. Wait for task worker process to terminate. If task worker process terminates, and the service isn't shutting down, repeat. (auto-update of worker executables) If task-launcher is signalled to terminate, then signal all child applications to terminate (send a close message.) 3) Optional server-update task process: Each task-worker executable is in it's own directory. The job of server-update is to find/download any update to any task-worker executables. It simply puts the new exectuables in a predetermined newversion folder. 4) Every child process (including the task-launcher, server-update, and all custom task-worker executables) Single task launcher thread simply looks for any configured task threads and launches child threads as needed. Main thread also looks for new executable version, if found then signal task launcher thread to terminate. Automatically terminate the process once launcher thread terminates (or timeout reached and child threads forcibly terminated.) Automatically terminate process if close message received after signaling task launcher thread to terminate. These can be simple VCL applications with a main form that has a Start / Stop button (which are only used for running in debug mode within the IDE, or standalone outside of IDE and outside the Windows Service) and a timer that is looking for updates Benefits: Windows service has very minimal code and never needs to be updated, which is nice because updating service processes are much more painful. The task-launcher process also has very little code and rarely needs to be updated. The optional server-update code is isolated to a single stand-alone executable and separated from task-worker custom code. (Could also move server-updates to a centralized management server and just copy new task-worker .exe to new version folder as needed.) The much more frequently changing task-worker code is isolated to stand-alone executables and these executables have no windows service, process launching, or server-update plumbing type code (other than the knowledge of where to look for a new version is ready to be installed.) Each task-worker can be built, debugged and tested just like any standard VCL type application. So if you have a many middle-tier application Windows Server machines to manage, each machine can run identical windows-service, task-launcher, and server-update executables. You decide on which machines to run various simple to create task-worker executables as needed. You can make changes on the fly by editing external configuration files (add new task-worker executables for example) and never have to restart the windows service. This system worked great for years. The only main trick is that your worker threads should periodically check for Terminated. If you don't code worker threads in a responsive way, the worker threads can be forcibly aborted in the middle of a task if the server is being shut down and your timeout is exceeded (which is likely no different than a current problem that has to be managed somehow.) Given the stability of Windows Server these days, the only time you have to restart the machine is when a Windows Updates requires it so that's also the only time this windows service will ever need to be restarted (it's a very good day indeed when you no longer have to stop a windows service to do some sort of application update.) You can also deal with 'stuck' task-worker executables by simply putting a copy of the executable into the newversion folder and the application will self-terminate and auto-restart based on your timeout preference. (Or simply use Windows task manager to kill the custom task-worker process and it will be automatically relaunched by the task-launcher.)
  7. Darian Miller

    Workaround for binary data in strings ...

    I dispute the concept that it was always considered bad practice. Like many things, over time it was eventually agreed to be universally known as bad practice, but it's revisionist history to claim that it was always considered such. How many Delphi Informant magazine articles, website articles and blog posts, along with commercial components and enterprise wide codebases were littered with this usage and there wasn't a peep about bad practice for years?
  8. No. It's just a byte like any other single-byte character. In ASCII and UTF-8 this single byte represents a Vertical Tab, a control character rarely used today and originally used for advancing the print head when printing. This special character has seen other uses and this StackOverflow question has some history: https://stackoverflow.com/questions/3380538/what-is-a-vertical-tab Apparently this is used as an alternate line feed character in various systems. So, depending on where your data is coming from, you may want to replace each character #11 that you come across with a CRLF pair. (Look at your data and see if that decision makes any sense.) memo2.Lines.Text := StringReplace(memo1.lines.text, #11, sLineBreak, [rfReplaceAll]); Not sure when sLineBreak was introduced...if you are using an old version of Delphi: memo2.Lines.Text := StringReplace(memo1.lines.text, #11, #13#10, [rfReplaceAll]); Curious... are you getting other odd characters, or is it just #11? (0b)
  9. Just saw this recent blog post today from LinkedIn: https://developpeur-pascal.fr/p/_500e-les-pieges-de-l-encodage-lors-de-l-ouverture-de-fichiers-textes.html It simply goes to show that there isn't a real clean solution. I don't particular agree with this author's suggestion.
  10. Thanks, but I'm not the right guy for that as I still want my box drawing characters above 127 for cool looking console menus. Besides, there are some references already, including: Cary Jensen: https://www.embarcadero.com/images/dm/technical-papers/delphi-unicode-migration.pdf Marco Cantu: https://www.embarcadero.com/images/dm/technical-papers/delphi-and-unicode-marco-cantu.pdf Nick Hodge: https://www.embarcadero.com/images/dm/technical-papers/delphi-in-a-unicode-world-updated.pdf There's also a help reference: http://docwiki.embarcadero.com/RADStudio/en/Unicode_in_RAD_Studio I certainly agree that interop can be messy when dealing with third parties. Hopefully the world eventually says "Everything is now going to be UTF-8" but that will never happen. (Even if it did, there's a lot on disk that has to be converted.) I started a TextEncodingDetector unit and did think about putting it on GitHub and doing an article on it, but I'm just not the expert. A public lashing by the real experts would be a learning experience for me I suppose. If you are dealing with a stream of bytes without a BOM or external encoding reference, and need to figure out if it's UTF-8, UTF16 (LE/BE), or ANSI then it simply isn't going to be 100% foolproof and the code isn't pretty. (At least mine is not.) I think a TextEncodingDetector unit by someone like Arnaud Bouchez, François Piette, David Heffernan, Remy Lebeau, Andreas Rejbrand, etc. would be quite interesting to discuss. (Arnaud probably already has one.)
  11. What encoding is utilized to store your data within your DB? UTF-8 is typically used on any web front end, your Delphi tooling likely prefers UTF-16, while your DB may be set to they system default ANSI code page. You need to clearly define a proper strategy to obtain data (from each different source that feeds your system), properly transfer every byte received, and then store/search the textual data in a consistent format. My assumption is that you are accepting defaults on inputs/transfers/storage and there are improper conversions going on.
  12. Darian Miller

    UCS4StringToWideString broken?

    While it may be an honest statement, it comes across horribly... (maybe I'm just having a bad online day with all the garbage I've seen this morning?) But at least put in the effort to document the expected behavior.
  13. Darian Miller

    Sourcecode for BOLD published at GitHub

    "Better late than never"
  14. Darian Miller

    Any news about the Delphi Roadmap

    We got an August 2020 Update from the GM: https://blogs.embarcadero.com/august-2020-gm-blog/ But unlike his August 2019 update, he failed to provide any plans this time. I really thought that a new roadmap would come out along with the 10.4.1 release, but it didn't happen. I can't imagine they'll wait too much longer....get some patches out for 10.4.1 and also release the updated roadmap. It should happen before the end of the month. We did get a separate update on C++ recently: https://blogs.embarcadero.com/c-gm-update-focus-on-c-quality-in-10-4-and-10-4-1/ but no long term plans there either.
  15. Darian Miller

    is the site infected?

    I would assume your system has been compromised.
  16. Look for more traffic here soon as they are discontinuing their public forums. (Their current forums are horrid to use...maybe they should replace the forum software instead...) https://blogs.embarcadero.com/august-2020-gm-blog/
  17. Darian Miller

    Delphi 10.4 (.1) Welcome Page

    +1. I use a manual batch file or an automated script. Part of the batch file: echo add LiveBinding set of packages to list of globally disabled packages as they slow down form editing and am currently not using reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Disabled Packages" /v "$(BDSBIN)\dclbindcomp270.bpl" /t REG_SZ /d "Embarcadero LiveBindings Components" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Disabled Packages" /v "$(BDSBIN)\dclbindcompfmx270.bpl" /t REG_SZ /d "Embarcadero LiveBindings Components FireMonkey" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Disabled Packages" /v "$(BDSBIN)\dclbindcompvcl270.bpl" /t REG_SZ /d "Embarcadero LiveBindings Components VCL" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Disabled Packages" /v "$(BDSBIN)\dclbindcompdbx270.bpl" /t REG_SZ /d "LiveBindings Expression Components DbExpress" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Disabled Packages" /v "$(BDSBIN)\dclbindcompfiredac270.bpl" /t REG_SZ /d "LiveBinding Expression Components FireDac" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Disabled Packages" /v "$(BDSBIN)\dclbindcomp270.bpl" /t REG_SZ /d "Embarcadero LiveBindings Components" /f echo Prefix description with an underscore to disable known IDE packages - added suffix signifying intentionally disabled reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Known IDE Packages" /v "$(BDS)\Bin\GuidedTour270.bpl" /t REG_SZ /d "_Embarcadero Guided Tour Package (Intentionally Disabled)" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Known IDE Packages" /v "$(BDS)\Bin\startpageide270.bpl" /t REG_SZ /d "_Start Page IDE Package (Intentionally Disabled)" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Known IDE Packages" /v "$(BDS)\Bin\TrackingSystem270.bpl" /t REG_SZ /d "_Embarcadero Tracking System Package (Intentionally Disabled)" /f pause reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Editor\Options" /v "Visible Right Margin" /t REG_SZ /d "False" /f reg add "HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0\Debugging\Embarcadero Debuggers" /v "Break On Language Exceptions" /t REG_SZ /d "0" /f
  18. Darian Miller

    Delphi 10.4.1 LIBSUFFIX AUTO

    Ah, ok. I didn't try that yet.
  19. Darian Miller

    10.4.1 Released today

    It's a common question: https://www.ideasawakened.com/post/about-binary-compatibility-on-new-versions-of-delphi
  20. Darian Miller

    Delphi 10.4.1 LIBSUFFIX AUTO

    The new drop down inserts $(Auto) Have you tried that text?
  21. Darian Miller

    10.4.1 Update

    I agree and repeated it twice in my blog - always buy the source. I've been stuck with the task of replacing a component as we didn't have the source...it's horrible. The reason you buy a component is so you don't have to write that code, and you end up having to write that code or rewrite what you have in place in order to use a different component. And, your upgrade of Delphi waits until that task is done. I haven't tried that tip on a single project group for all components. I'll have to try to start doing that, thanks! A little work up front, but then saves the big hassles later.
  22. Darian Miller

    10.4.1 Update

    I started a rambling reply here and it started to get long, so I put it up on my blog as it's a common question: https://www.ideasawakened.com/post/about-binary-compatibility-on-new-versions-of-delphi Note: if there any additions/corrections/clarifications needed, please let me know.
  23. Darian Miller

    TEdit with enhanced keyboard support?

    Related StackOverflow topic: https://stackoverflow.com/questions/10305634/ctrlbackspace-in-delphi-controls (Be aware of side effects.) Some history on the topic: https://devblogs.microsoft.com/oldnewthing/20071011-00/?p=24823
  24. Darian Miller

    how to run git commands from Delphi app

    You could research how the Delphi IDE handles GIT commands for its integration. https://sourceforge.net/p/radstudioverins/code/HEAD/tree/branches/git-hg/gitide/
  25. Darian Miller

    Amazon S3 API using BackBlaze. How?

    nsoftware.com has IPWorks S3, IPWorks Cloud component packages that would work. I'd suggest the full Red Carpet Subscription.
×