Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/11/22 in all areas

  1. David Heffernan

    Any advice when to use FileExists?

    In what version of Delphi is this? Are you sure that it raises an exception? If it does then that is a change of behaviour from the XE days.
  2. TurboMagic

    Code coverage wizard plus

    Hello, do good and talk about... I'm currently shortly before releasing a new tool. It''s named "Delphi Code Coverage Plus" and is a completely rewritten and improved version of "Delphi Code Coverage Wizard". You can already get it on GitHub and it already works, the things before a 1.0 release I want to do are mostly cosmetic ones. Here is the link: https://github.com/MHumm/delphi-code-coverage-wizard-plus Now what can it do for me? It is a GUI tool which can generate everything needed to run the commandline Delphi Code Coverage tool that Delphi Code Coverage tool would run your unit tests and find out which lines of code your unit tests are actually run by the unit tests and which ones are never reached Why did I rewrite it and what's new/improved? The former Wizard (remember: I only reworte the wizard, not the command line tool itsself!) would generate the batch file to run the command line tool and create other necessary files, but if you changed something in your Delphi project, you would have to update these files/batch file yourself manually The new wizard got rid of JVCL components so it uses only what comes with Delphi itsself, which hopefully makes it easier for others to contribute The new wizard introduces a project format so you can load and modify an existing project, e.g. if you added more units to your project or need a different output format The new wizard can add itsself to Delphi's Tools menu if you like. The new wizard stores his position and window sze so it opens the same positionand with the same size new time it is started The new wizard should be HiDPI capable The new wizard can directly show the HTML output if you selected that one as output format What else is there to know? it was developed with 11.2, but most likely will compile and work fine with 10.4 For isntallation download the ZIP from GitHub or clone it, then open and run the project file There are plans to release it via GetIt package manager as well If you like this tool you can "star" it on GitHub 😉
  3. Anders Melander

    Sender of TAction.OnHint Event?

    When, in a few years, you or someone else comes across that code, "interesting" will not be the word used to describe it.
  4. Hans J. Ellingsgaard

    Huge memory problem

    Do you use query or table components?
  5. Since the data is streaming, there is no guarantee that the data that is available during each firing of the TIdHTTP.OnWork event will represent a complete line of data. It could be partial data. At the very least, I would not suggest using the Memo's LoadFromStream() method, which replaces the entire contents of the Memo on each call. It would be better to convert each event's data to a raw string and then append it to (not replace) the Memo's current text, which can be done efficiently using its SelStart/SelLength/SelText properties. But, more importantly, the TMemoryStream that you are having TIdHTTP write to will just keep receiving more and more data that you are never discarding from memory, so the stream's memory usage will keep growing over time, until memory runs out eventually. If you want to process the data in chunks as it is arriving, I would suggest using a TIdEventStream instead, replacing the TIdHTTP.OnWork event handler with a TIdEventStream.OnWrite event handler instead. You will be given access to the actual bytes per event as a dynamic array, which means you can simply increment the array's refcount, send the array pointer to the main thread, and then decrement the refcount.
  6. It would help if you could show the raw HTTP response data that is actually being transmitted. curl is only outputting the JSON data, not the full HTTP data (you can enable its verbose output to see that). Streaming events like you have described could be transmitted in many different formats. Depending on the format used, using Indy's TIdHTTP component, for instance, you might be able to either: - use its OnChunkReceived event - enable its hoNoReadMultipartMIME or hoNoReadChunked option and then read the lines manually from Indy's socket directly - use a TIdEventStream as the target to receive the data, using its OnWrite event to access the lines. It is hard to say for sure without more information.
  7. YES, thank You! 🙂 OFF: I think the problem was, that first we need to create an Array on that level, and we can .Add() elements only after that. Maybe you can improve the code later to add "auto-array-creation" in those cases, but it's not necessary. Some better examples can do it also. I would do it myself, but I have a nearing deadline and already working 14-16 hours pro day. Sorry.
  8. Warning : Very "quick and dirty as a "One min programming challenge ";) -> joke appart : - you can mimic the pythonic "resp.iter_line" : Just wrap in a TThread descendant all what is done in screen capture. (Put the http and idssl component in the TThread descendant) - And on each "get stream" (onWork summoning), qualify the "new line", and send it on your main thread. - Avoid use of AnonymousThread here, it was just to make it quicky'n dirty.
  9. ISuperObject documentation and examples are very poor, but it's a reliable and fast library... There is an example in the OverbyteIcsSslX509Certs.pas unit, search for SA([]) which creates an empty array, then you can add elements with a blank name to create a simple array. Angus
  10. FPiette

    ScreenSnap and real window position (D7)

    Override the form's DoShow procedure and from there post a custom message to the form. In the corresponding message handler restore the form position and size. If you want an example, look at https://github.com/fpiette/OvbImgOrganizer/blob/main/Source/OvbImgOrganizer.Main.pas
  11. Rest won't help here but there are THTTPClient, Indy, not talking about many 3rd party libs. At last you can use TNetClient and send manually crafted request
  12. Lars Fosdal

    Huge memory problem

    FireDac is not a database, but Delphi's DB Driver framework. There is no practical size limit in FireDac itself. The limits would be the limits of the underlying database. What is your actual underlying database? A good allround DB is designed to be on disk and to be manipulated on disk and use memory mostly for indexes and caching. Using a billon row DB that fills terabytes of diskspace, does not necessarily imply a performance problem. There are free DBs you can use - even commercially: Postgresql, MariaDB (Open source MySQL), Firebird, etc. Ideally, you would want to limit what you keep in memory, and instead pull in stuff on demand - but that means a redesign of your application. However, if you need/want to load and keep everything in memory, switching from 32-bit to 64-bit will offer a much larger memory space (but then you have to face the sorry state of the 64-bit debugger).
  13. Anders Melander

    Is there such a tool/functionality??

    It's built right into the IDE. The only problem is that it seldom works 😞 [Edit: This is what @Pat Foley wrote about] Right-Click and select Search for usages... or right-click and select Find, Find local references to...
  14. Ian Branch

    Grep Results dialog..

    Who'd a thought.... 😉 I thought I would air the ideas to gauge reaction before formalising them but they have been formally posted now.
  15. chkaufmann

    REST Api Key - Expiration

    I was thinking of something like that. Get the server timestamp and then keep the difference in the application. But why could it be dangerous to send the server timestamp in an API Request? Christian
  16. Brian Evans

    Is there such a tool/functionality??

    MMX Code Explorer has next/previous occurrence off right mouse button menu with hotkeys that also brings up a list. Right mouse -> MMX Commands -> Navigate and Move -> Find Next Occurrence. SHIFT-ALT-RIGHT ARROW (find next occurrence) or SHIFT-ALT-LEFT ARROW (previous occurrence) hotkeys.
  17. Remy Lebeau

    Sender of TAction.OnHint Event?

    There is another possibility. If you don't mind assigning the OnHint events in code at runtime (or at least looping through the actions at runtime to update their OnHint handlers that are assigned at design-time), then you can use the TMethod record to alter the event handler's Self pointer to point at each TAction object instead of the TForm object. Then you can just type-cast the Self pointer inside the handler. For example: procedure TForm1.FormCreate(Sender: TObject); var Evt: THintEvent; begin ... Evt := Action1.OnHint; // or: Evt := @ActionHint; TMethod(Evt).Data := Action1; // instead of Form1 Action1.OnHint := Evt; ... // repeat for all TAction objects that share ActionHint()... end; procedure TForm1.ActionHint(var HintStr: string; var CanShow: Boolean); begin // use TAction(Self) as needed... end;
  18. Remy Lebeau

    Any advice when to use FileExists?

    I don't have an up-to-date version to verify this with, but I seriously doubt what you claim is true. Up to at least XE8, FileExists() was never coded to raise any exceptions. I can't imagine Embarcadero would ever add exception handling to FileExists() in the years since that release.
  19. Fr0sT.Brutal

    MMX and (Parnassus) BookMarks

    Don't forget " Embarcadero Technologies does not currently have any additional information. "
  20. Attila Kovacs

    MMX and (Parnassus) BookMarks

    This is so beautiful, I'll take it for my signature.
  21. Uwe Raabe

    Move current entity to another unit?

    Surely I want. I just don't want to implement things that may be valuable to a single person in a special situation. There are way more things to implement that most likely bring benefit to a lot of people in several situations. My time for MMX is limited and I have to take care for what I spend it. Note that I already took this under consideration: Regarding your requests: This would only work on Forms and Datamodules. Frames and all other classes don't have such a global variable. Given that many people suggest to get rid of these global variables, it would be counterproductive to encourage their usage. Besides that this point is somewhat moot given my response to 1. Moving fields from private to public is not something that I would do without asking for consent, which will add some more user interaction to the process. It is easier to select the relevant field(s) in the class and move them to public with the available tools (like selecting public in the visibility dropdown). This all does not even tackle the fact that the resulting code shown is anything but clean.
×