Jump to content

Lars Fosdal

Administrators
  • Content Count

    3416
  • Joined

  • Last visited

  • Days Won

    113

Everything posted by Lars Fosdal

  1. Lars Fosdal

    Writing DLL functions unit

    Without documentation about the parameters of these functions and their types, you will be unlikely to succeed.
  2. Lars Fosdal

    Squint and read: CreateFormFromStings

    Mine too, especially when I've written the semantically correct word, but the compiler barfs because the actual word in the code is misspelled.
  3. https://larsfosdal.blog/2019/08/06/generic-command-line-parser-for-delphi-10-3-x/ I wrote an open source command line parser for Delphi. https://gist.github.com/LarsFosdal/f8a3e2a7caa5e541e4c04f10dfdfcfff Feedback appreciated.
  4. Lars Fosdal

    Generic Command Line Parser for Delphi 10.3.x

    The parser only deals with the parsing of a basic syntax. The interpretations of the validity of variations of switches, flags and arguments still has to be built on top of the base parser. I decided not to write those parts, as there are so many (potentially conflicting) ways to write it. It should be easy to add that layer yourself, though.
  5. Lars Fosdal

    Generic Command Line Parser for Delphi 10.3.x

    Double (or multiple) switch chars work. But - as mentioned: the syntax for multiple arguments to an option is (arg1, arg2, ..., arg n) If you need the separator as part of a string, you quote the string. (art1, "this , is in arg2", 'this has a " in it') Parse(' --strings="String A, StringB,StringC, String D and E"') 1 Switch[--] Option[strings] Flag[=] Values["String A, StringB,StringC, String D and E"] AsString('strings'): String A, StringB,StringC, String D and E
  6. What about breaking down the menu into groups? Yes, it is convenient to have everything on top level ... until it isn't. Since I don't use GExperts, my grouping suggestion is only based on menu names, not on actual functionality - so some placements may be totally wrong. File Code Librarian Code Proofreader ... Favorites Open Project Backup ... Class Browser Dependencies Source Export Component Copy Names Find Reference Grid ... Hide / Show Non.-Visual Rename Replace Select Set FocusControl Set Tab Order ... To Code Editor Bookmarks Comment Empty Code Blocks Clipboard History Experts Focus Go to Grep Next Item Previous Item Results Search ... Macro Library Playback Record Start/Stop Tools Ascii Chart IDE Menu Shortcuts... Keyboard Shortcuts Message Dialog PE Information To Do List -- Configuration About Window Add Dock Window Reselect Desktop
  7. Lars Fosdal

    Squint and read: CreateFormFromStings

    For some reason, many of the programmers I know have various degrees of dyslexia - which leads me to mentally auto-correct the misspellings I find, and in many cases, leave them as is. Usually, changing the spelling leads to something unpleasant happening, such as a mismatch between stream content and object property, DB field names, etc.
  8. Lars Fosdal

    Open Url From Current Line

    Early return benefits: The contract clauses of the method are clearly defined at the top of the method code. If you made it past the contract clauses, your code is safe to run You can easily add or remove contract clauses without breaking the code (or having to add yet another layer of indentation) I used to be a nester, but I evolved.
  9. Lars Fosdal

    Generic Command Line Parser for Delphi 10.3.x

    @Mike Torrettinni I updated the gist at https://gist.github.com/LarsFosdal/f8a3e2a7caa5e541e4c04f10dfdfcfff with an extra Analyze function that writes a clearer breakdown of the parsing. and added your example and a modified version of it to the test app. As far as I can tell, it works as expected? Your example: /strings="String A, StringB,StringC, String D and E"' is a single string param. The test output: Parse(' /strings="String A, StringB,StringC, String D and E"') 1 Switch[/] Option[strings] Flag[=] Values["String A, StringB,StringC, String D and E"] AsString('strings'): String A, StringB,StringC, String D and E ClientIdentifier = My modification of your example: /strings=(String A, StringB,StringC, String D and E) is an array of strings. Note the use of parenthesis to indicate multiple arguments. Parse(' /strings=(String A, StringB,StringC, String D and E)') 1 Switch[/] Option[strings] Flag[=] Values[("String A";StringB;StringC;"String D and E")] AsString('strings'): String A ClientIdentifier =
  10. Every request needs evaluation to understand WHY the request is being raised, and if the request actually is what the customer needs - or if he is just attempting to scratch an itch instead of curing the cause of the itch.
  11. TList<T>.Pack( function (const L, R: T): Boolean begin Result := (L.Condition); end);
  12. Did the refactor solve your "always same I" problem?
  13. Nope. F5 or Ctrl-R and the visual error remains, and I still can't edit the post again.
  14. Is it about the pitfalls of variable captures? The simplest solution to that is to simply divide and conquer. Also - the queuing code you wrote, will only do five scrapings since you never descrement nCount when a task completes, nor do you retry the loop until there are no lines not containing 'done'. procedure TForm1.QueueScraping(I, Q: Integer); Async( procedure begin Memo1.lines.add('I=' + I.ToString() + ' Q=' + Q.ToString()); GetWebContent(I); end ).Await( procedure begin Memo1.lines.add('Done I=' + I.ToString() + ' Q=' + Q.ToString()); end); end; procedure TForm1.BitBtn1Click(Sender: TObject); var I, nCount : Integer; begin I := 0; nCount := 0; for I := 1 to StringGrid.RowCount-1 do begin if StringGrid.Cells[0, I] <> 'done' then begin inc(nCount); if nCount > 5 then Break; QueueScraping(I, nCount) end; end; end;
  15. Lars Fosdal

    BLE cannot get service

    Did you call BluetoothLE1.DiscoverServices before calling GetService? http://docwiki.embarcadero.com/Libraries/Rio/en/System.Bluetooth.TBluetoothLEDevice.GetService http://docwiki.embarcadero.com/Libraries/Rio/en/System.Bluetooth.TBluetoothLEDevice.DiscoverServices
  16. Lars Fosdal

    Blogged : Introducing DPM - a Package Manager for Delphi

    Pessimist = Experienced optimist 😛
  17. @rvk - My question was due to the comment in the docwiki link that explicitly mentions Firebird and Interbase. Likewise, in http://docwiki.embarcadero.com/Libraries/Rio/en/FireDAC.Comp.Client.TFDCustomConnection.Transaction - it says "Note: At the moment, this behavior applies only for InterBase and Firebird connections."
  18. Note to @Daniel - See the above comment. The quote gets wonky after an edit, and once it is wonky, it can't be edited again.
  19. Is it correct that the custom transactions only apply to Interbase and Firebird? I.e. for f.x. SQL Server, transaction handling would have to be in the query itself?
  20. I prefer individually named methods instead of overloads. Optional parameters can work in some cases, but when things get really complex with a lot of variations, I use variations on the theme that @Der schöne Günther introduced. A record, an object, or an anonymous method.
  21. Lars Fosdal

    Closing an external App.

    Are you trying to prevent running the same app twice? https://lonewolfonline.net/prevent-multiple-instances-delphi-application-running/ https://stackoverflow.com/questions/8688078/preventing-multiple-instances-but-also-handle-the-command-line-parameters As mentioned above, FindWindow need window class names or window titles. https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-findwindowa Unless you want to enumerate processes to find the main window(s), calling taskkill could be an alternative. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill
  22. Lars Fosdal

    Combining several applications into one

    We are trying to make a habit of assigning events / config in code, and not rely on dfm / unit event handler references. Frames are indeed a great way to plugin/unplug code. Although - I have been told that Frames are not quite as desirable in FMX? Can anyone offer their experience with FMX and dynamic creation of frames?
  23. Lars Fosdal

    Combining several applications into one

    We partly use the same model as Rollo62 does. Functionality that is shared across apps, is implemented as frames. The amount of work required to create a frame from a regular form, depends on the complexity - but quite often it is more or less just a cut and paste.
  24. Lars Fosdal

    [Fmx, Android] TBluetoothLE device disconnect

    It could be BLE version / chipset dependent. That out-of-range issue is a killer, really. Not being able to do a proper recovery there is pretty darn hopeless.
  25. Lars Fosdal

    [Fmx, Android] TBluetoothLE device disconnect

    Have you collected a list of devices / OS versions that have particular behaviours?
×