Mike Torrettinni
Members-
Content Count
1509 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Mike Torrettinni
-
Yes, SQLite says it is using bytcode to run sql queries: https://www.sqlite.org/opcode.html
-
Very interesting! Thanks for detailed explanation and I agree, definitely above my current skill set, and I probably will never need this. Thank you, but that was very confusing to read, the whole page. I was never good in just theory, I need examples - well, in this case of topic I doubt example would help me, anyway. And if you look at the history of this wiki page, so many many corrections and additions over the years (800+ edits, 463+ editors since 2002), for a topic that mostly has 1 or 2 paragraphs per term, you can realize this was a long journey to create. How can this be for rookies like myself? 🙂
-
Accept delimited & return an object
Mike Torrettinni replied to AndrewHoward's topic in Delphi IDE and APIs
I use records like this and it's really easy to add more fields, because you simply add to the record definition. You just need to make sure you initialize result, Result := Default(TRecord), and all record fields are initialized no matter how many are defined. I define a class when parsing need more complex rules or goes beyond single function. Then you have all the flexibility of full class. -
Reading fields with different lenghts
Mike Torrettinni replied to AndrewHoward's topic in Delphi IDE and APIs
Oh, good thinking! Well if it's binary then I guess he can ignore the suggestion. Right? -
Reading fields with different lenghts
Mike Torrettinni replied to AndrewHoward's topic in Delphi IDE and APIs
I would use TStringList because it gives you plenty of features already implemented, like get value by index. I would do something like this: // Parse input string into TStringList procedure ParseInput(const aInput: string; var aData: TStringList); var i, vStartOfValue: integer; begin // loop aInput and add each value between [...] to aData for i := 1 to aInput.Length do begin if aInput[i] = cStart then vStartOfValue := i+1 else if aInput[i] = cEnd then begin aData.Add(Copy(aInput, vStartOfValue, i - vStartOfValue)); end; end; end; Then you can get field after 'STX' like this: // use GetValueAfter(Data, 'STX', 2) for 2nd field after 'STX' function GetValueAfter(aData: TStringList; const aAfter: string; aIndex: integer): string; begin Result := aData[aData.IndexOf(aAfter) + aIndex]; end; And here is example: procedure TForm2.Button1Click(Sender: TObject); var vData: TStringList; begin vData := TStringList.Create; try ParseInput('[STX][0x1C][Field1][0x1C][Field2][0x1C][Field3][Field4][0x1C][ETX][LRC]', vData); // Get 2nd field after 'STX' Memo2.Lines.Add(GetValueAfter(vData, 'STX', 2)); finally vData.Free; end; end; -
Using Delphi in Virtual machine for a month
Mike Torrettinni posted a topic in Tips / Blogs / Tutorials / Videos
Maybe this will help someone deciding on trying to use Delphi in VM: I used Delphi 10.2.3 in VMware for a month and I just reinstalled it back on my local machine, it just didn't really work for me in VM. So, specification: Desktop: Intel I7 4790K (4c/8t), 32 GB Ram and all SSDs; Windows 10. VMWare Workstation Pro 15.1 installed on local PC - I researched quite a lot on how to improve experience with VM Settings: Memory: 12GB Processors: 4 (processors: 2, cores per processor: 2) VM file is on separate SSD. Fresh Windows 10 installed in VM (+all updates + all latest drivers) To make it run a fast as possible (or to limit resources used) I disabled all non-essential services, cleaned up startup programs, no antivirus or antimalware installed. Very few other tools, just 7z, WinRar... Delphi 10.2.3 + IDEFixPack + MMX + GExperts + CNPack Disabled Start page + disabled Live binding. One of the reasons why I tried Delphi in VM is to have simple backup and grab-and-go Delphi environment. So, at first it seemed to work well, full build time was a bit slower, but not too annoying - 50% longer than compile time on local. A bit slower IDE, slower switching between Form and code. For the testing of concept it was acceptable and luckily at that time I didn't have any real development time scheduled, just some minor bug fixes. But as soon as I started really working with it, all these little things became very annoying, in a matter of few hours: - delays in mouse right-click in code to use Toggle Breakpoints or Refactor (rename variable) - delay on selecting Form controls and Object inspector to populate properties and Structure view - opening menus - even ctrl+home/end on large unit (40K loc ) was delayed - and other little delays here and there The delay I'm talking about is very minor, probably less or close to 1s, but when you use IDE a lot these delays become very apparent and annoying. For me this was too much after a few hours of real work. To summarize, I think I optimized VM as much as I could to run as fast as possible; the computer is still powerful enough even though is not brand new high-end computer; I don't have huge projects, but they do have some 100Ks loc each. If I would install all the rest of the tools I use in my daily development environment and run them as I do on local computer (memory regularly gets used 20GB+) it would slow down the whole VM experience even more. I doubt that VirtualBox or any server virtualization (Hyper-V?) would improve the experience. Maybe it's my patience (or the lack of it) that got tested really fast, but VM just isn't working for me. If anybody has different experience, please let me know if you have any advice on how to make the whole experience better - smoother IDE, like on local installation where runs really fast (very acceptable). -
How secure is your WordPress installation?
Mike Torrettinni replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
The description scares me a little bit... almost feels like it sends an assassin to anybody trying to access my website... 🙂 "Our Threat Defense Feed arms Wordfence with the newest firewall rules, malware signatures and malicious IP addresses it needs to keep your website safe. Rounded out by a suite of additional features, Wordfence is the most comprehensive security option available." -
Since I started using Frames, I'm setting up a lot of callback functions. I noticed a lot of them are getting duplicated, especially the simple ones, with simple type parameters. Of course all callbacks are defined and used within the needed scope, not global. Should I create a few common callback functions and have them defined in global scope, like: TIntFunctionWithIntParam = function(aValue: integer): integer of object; TStringFunctionWithIntParam = function(aValue: integer): string of object; TIntFunctionWithStringParam = function(const aStr: string): integer of object; TStringFunctionWithStringParam = function(const aStr: string): string of object; TIntFunction = function: integer of object; TStringFunction = function: string of object; these function can then be used in any Frame. Of course functions that are specific to each Frame, would still be defined in each Frame. Or is this the wrong approach and all callbacks should be defined exactly for the defined purpose, and within defined scope? Any advice is appreciated!
-
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Correct, well I probably didn't phrase my statement correctly, as I'm not too experienced with anonymous methods. And as @Rollo62 has shown, a few posts prior, there's a lot you can do with anonymous methods. -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Thanks, good to know. -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Well, not sure how to answer this, because my understanding is event=callback. -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
I very rarely use anonymous functions, so I assume the limitation (compared to callback) is that it can only be used within already executed code. You can't just assign it to something, because it's anonymous (not defined anywhere). Right? -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Thanks! I was thinking about this why I made such a big deal about this, the event vs callback, function vs procedure... It's simple, I can use what I need in that situation, as they both have valid use cases. -
How secure is your WordPress installation?
Mike Torrettinni replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
I'm not a WP expert, so it's nice to see a blog where the the problem is explained and solution is simple: download plugin+upload+activate. Simple, thanks! -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Yes, arguments need so to be passed in procedure and function call. That is the same. -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Oh, of course! I didn't really think about it in that way. It makes sense: assigned vs called, thanks! EDIT: Hm, well thinking about it... function is also assigned and you can use if Assigned(FOnGetSearchTextLine) then FOnGetSearchTextLine; Right? Maybe I'm proving your point, but I'm still little unsure about procedure vs function event. -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Oh, Ok, I wasn't sure what you are referring to. But you want the purple icon, right? OK, I just 'thanked you'. -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Where is the "thanks" button? -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Aha, thanks. Looking through some examples, most of them use TEvent = procedure() of object, I assume TEvent = function(): resulttype of object; is not the normal way, right? Am I just lucky it works for me? -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Maybe I over-designed it, but this is what I have: MainForm -FrameA -FrameB -FrameC -Frame..N CommonSearchForm each Frame has VirtualTreeview control to display data. CommonSearchForm has Search, SearchNext, SearchPrev, keyboard actions (Ctrl+F/N)... and these actions also control (move next/prev) searched lines in Frame's VirtualTreeView. So, each Frame creates it's own instance of CommonSearchForm and assigns local methods to events so that GetSearchTextLine gets different text from each Frame's local method that returns text line to be searched. Are you suggesting I create all Search features in each Frame? -
Common callback functions, or not?
Mike Torrettinni replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
Perhaps I'm using the callback term incorrectly... and these are events? I use these to assign local Frame method to a general Search form, like this: // definition callback/event TGetSearchTextLine = function (aDataIdx: integer) string of object; // method in Frame that returns data line to be searched within function TFrameA.PrepareDataLineForSearch(aDataIdx: integer): string; begin Result := fData[aDataIdx].ProjectName + fData[aDataIdx].ProjectDescription; end; // create Search form and assign/connect methods (callbacks/events) procedure TFrameA.StartSearch; begin ...// create fSearchForm fSearchForm.GetSearchTextLine := PrepareDataLineForSearch; end; // in Search Form I have public variable of type of callback/event public var GetSearchTextLine: TGetSearchTextLine; // and it gets called when Search is executed in Search form procedure TSearchForm.Search; begin fDataLineToSearch := GetSearchTextLine; SearchForText(fDataLineToSearch); end; When used like this, am I using a callback or event? In this case I'm not using Form/Controls methods (like OnClick and others). Do I still need Sender: Object? Is the reason for this so that I know who called the method? -
I use a lot of enums and was thinking if there is better to way to 'find' the proper enum to be used. So, I was thinking something like this for THTMLType enum: THTMLType = (htTemplate, htStatic, htHeader, htCustom); TReportEnums = record HTML: THTMLType; end; var gEnums: TReportEnums; and used like this: vHTMLReportType := gEnums.HTML.htTemplate; If I try I get error: E2018 Record, object or class type required, on HTML. . Edit: I would like to have something that could use code completion, so I don't need to remember htTemplate. I would type Enums. and I would select among options HTML. and then I would see THTMLType options... Any suggestions, or this is just not possible?
-
Adding 'Show All topics' to see all topics in selected forum
Mike Torrettinni posted a topic in Community Management
Right now there are only 25 topics per page, displayed in forums. Is it possible to add 'Show all topics' or perhaps options to show 100, 200... topics per 1 page? The forum is becoming really useful resource, but it's quite annoying to have to go page by page back to find older topics. I'm referring to this navigation on top of each forum: Show All or Show 100/200/500... per page would be very useful. If Show all is possible, I don't mind waiting to load. I appreciate even considering this request. Thanks! -
Adding 'Show All topics' to see all topics in selected forum
Mike Torrettinni replied to Mike Torrettinni's topic in Community Management
I see this is not available. There are general Topics per page and Posts per page, but for the whole site, not per user or per topic. Shame. The explanation for removing this option is 8 years old, but I guess still valid today: https://invisioncommunity.com/forums/topic/362706-number-of-posts-to-show-per-page-user-setting/?do=findComment&comment=2271715 -
Organizing enums
Mike Torrettinni replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Aha, cool. I know I can use consts in records, but never thought of this approach to replace enums. I guess this whole topic would be pointless if code completion would work as it should. But I like the different approaches and suggestion, and a little history (I assume the discussion with Niklaus wasn't last week 🙂 ).