Jump to content

Kas Ob.

  • Content Count

  • Joined

  • Last visited

  • Days Won


Kas Ob. last won the day on July 26

Kas Ob. had the most liked content!

Community Reputation

298 Excellent

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Kas Ob.

    Sql-Add Number begining of an INT field

    Both solution are not complete as they will fail after the new year of 22. @Henry Olive You didn't mention what DB server you are using as there is no one unified date functions for SQL across SQL DB providers. For MS SQL Server you can use YEAR(GETDATE()) for MySql this will work YEAR(CURDATE()) for SQLite it does need to be formatted, please refer to this detailed page https://www.sqlite.org/lang_datefunc.html ... after getting the year, either calculate the mod of it with 100 or take the last two digits (chars).
  2. Kas Ob.

    Prevent from closing when....

    Well, lets discuss your application behaviour This could be better, will be clear in few lines, but this is the root of your problem, i am talking about closing message vs closing request ! Sure and right way to do it, but you are deciding this within the form or (a form) not from the application as one whole creature. There is many approaches, the easiest and simplest one is to have a controller for exiting the application, by controller i mean any logic to define your application relation with its forms and messages, a controller can be a class or a hidden form (not visible) or few global functions with few global vars. The idea is to lets say have a class that will live as long as the application is not terminated, when a form like B show in modal it will register with that controller as opened and will unregister when it close, on other hand A will consult with the controller when execute CloseQuery to see if there is B or any B's like, the last thing is to change the bahaviour mentioned here "another part of the program posts a close message to form A and it closes." to "another part of the program posts close request to the controller." here the controller will have its logic on how to terminate the application and what forms need to be closed and if there is background threads working need to be waited for or terminated or.... In other word redesign your program exit code to have its own messages/events and respond according to logic your define, this will simplify your code as it will be Controller.RequestAppClose and it will close in orderly fashion, also "Controller.IsClosing : Boolean" will be nice addition if needed, the controller does know the main form and will keep track of dialogs and modal dialogs, while B doesn't need to have to handle A and A doesn't need to keep track of B.
  3. Well, i don't know about that but i remember i saw many articles a year ago mentioning some suspicious behaviour from all kinds of apps violating privacy and reading clipboard for unknown and unexplained reason. I searched now for published articles after Apple made its iOS preview version with this behaviour, but found only one https://arstechnica.com/gadgets/2020/06/tiktok-and-53-other-ios-apps-still-snoop-your-sensitive-clipboard-data/ I remember Twitter and Facebook were mentioned also, but not in the above link. Anyway, i completely agree with such behaviour and like to see it in every device including Android and even Windows it will be nice optional security feature to know who is doing what.
  4. Well, i don't have the Bundle License, it is nice to know. Also i want to point to the fact that the page for "HTML Report Library" is mentioning script engine and "designed to generate reports using databases and XML" But doesn't mention SQL explicitly.
  5. Well, in my many written filters and search expression were mostly math expression to isolate ranges, means i was for some criteria's with defined values while including/excluding ranges (>,<, <= ...) so lists was essential here as they some search statements explicitly required medians ( also deviations...) like values from ranges, so building lists was the fastest approach. Also there is cache usage which in some cases i had to choose this based on my benchmarks, anyway i don't think extreme speed is essential in your case because you need result and that what you care about, were in my case i want to repeat this many times and render many details visually, so 50ms is my upper tolerated limit, when i have millions of records. No !, far from that, this is what you is the only approach, function Search(const Text:string; const List:TSomeList):TSomeList; ... TLogicOperation = (loAND, loOR, loXOR); TFilter = class protected //FLogicOperation: TLogicOperation; function ApplyFilter(const List1, List2: TSomeList): TSomeList; virtual; abstract; public //constructor Create(Operation: TLogicOperation = loAND); function Apply(const List1, List2: TSomeList): TSomeList; //property FilterOperation: TLogicOperation read FLogicOperation write FLogicOperation; end; TFilterOR = class(TFilter) protected function ApplyFilter(const List1, List2:TSomeList): TSomeList; override; end; That is a messy salad of two or three approaches, also a helper will do ! ApplyFilter will do one thing, the real code can be very short and accurate, consider it as food for thoughts. And there should be a list of the filters and their sequence built by your parser, just don't over think it, in the imaginary code you will feed the result from ApplyFilter to another ApplyFilter as parameter. Anyway , Well, you know how to do it and it will be clear if you give it some time, just think outside the box, and relax your assumptions, again there is many approaches to handle it your way, but the questions is how to build chain of action at runtime, you know how to it, right? only the flow i mentioned it will be simple as TAnd and TOr where these are any creatures you like, record, class or even raw list of actions built with your parser, may be each action will have pointer to the next action, not much explained in this way, but try to think about it and all the pieces will fall in place, (trust me it is easy) I can't remember if it was you or not, who asked about JIT in this forum, see when you finished resolving this, you already built a JIT !, this is off-topic but extreme JIT will replace these line of logic with may be assembly optimized code and run them.
  6. I am not sure i do understand your quest completely, but will guess a little ! First, the records you listed look like a DB columns, so, is SQL approach is on the table ? By using SQL you do need nothing else, SQL in fact built to such search and much more complex syntaxes, but again i am guessing here, and to add to this, to my knowledge the most comprehensive SQL parser for pascal is the one by NexusDB, there is one file called nxSQLParse.pas and it is freaking scary ! Also there is many Pascal/Delphi scripters engine that do similar things, most of them are insightful, From the powerful TMS Scripter, to RTC, or Delphi HTML, ... the list is long and browsing the code is valuable knowledge. But again, guessing you did not miss the SQL choice, so let me explain how i did many similar filtering on big data with complex syntaxes, although in my case it wasn't text at all. I will try to explain with an example from your sample syntax, and hoping you will get the idea. Your syntax is ("test phrase" OR testing) AND text OR "anything else" First lets dissect syntax into pieces, we will solve this by the most simple and least complex way, divide and conquer ! 1) Separate by the logic operators, means we will be left with a list of searchable text "test phrase" testing text "anything else" 2) Build logic flow accordingly to brackets, here a little knowledge in how mathematical expression being parsed will be a great help, see we brackets and logic operators are similar to brackets, +, -, *,/ , after building the flow which almost modified version of the list in (1) with which one comes first then applied to which, there is many Pascal/Delphi mathematical expression parsing code out there. 3) Search for each item in (1) and build a new list (an array) for it, yes this seem expensive, but let it be for now. 4) Apply the Flow you built in (2) on the lists generated from (3), with each step you will be building a new list, this might be easier from adding or removing from/into (aka changing) a list, the last list is the search result. Simple, Right ? 🙂 Later, and after making this work, you can go after eliminating unneeded lists, like the case with ("test phrase" OR testing), these can be handled as one list, but again make it work first in the simplest way you can, only after that you can refactor and redesign it with more complex but faster and less memory usage. May be others will suggest different approaches, but now this what i can thing of, which i see can fit your need, and it will be elegant.
  7. Found this https://developer.android.com/reference/android/app/ActivityManager#clearApplicationUserData()
  8. Not exactly what i was talking about, i was pointing to force app data delete if that is possible, something like this https://stackoverflow.com/questions/6134103/clear-applications-data-programmatically I think but not sure because i don't have newer Android, what if you cleared app data and cache, it might clear user permission choices along with it, if a full reset can be performed then the OS might ask again for permission on the next run, that is my point.
  9. I have this question Is it possible to clear app data and cache to force resetting user permissions setting ? Not sure if resetting/deleting app data and clearing it would remove permission as i am still Android 4.4.4 user, but i think you can test this, the only thing might be lost is app data (confusedface.png) but these could be stored somewhere on local storage or even sent over wire somewhere. By searching the internet i found it might be doable. That on one hand, on other if a permission is essential for app functionality then detecting the user choice of permanent denying might be essential to notify the user of this doing, searching the internet i think this https://github.com/googlesamples/easypermissions might help So may be combining the above two approaches might enhance the user experience a little. Hope i am not wasting your time, but really love you read your comment on this.
  10. Kas Ob.

    Persist data in a stream

    Well, now we need someone has the tools to help ! I don't have the latest versions of Delphi, and never used i used FireDac, so i am sorry i am not a help here, but i can un-notice this this in the code which looks wrong, (still i might be wrong) .... dtAnsiString, dtWideString:begin ns:= 3; wr.Write(ns); ns:= iData.DataView.Table.Columns[c].Size; // <- This is is undefied value for Tipo wr.Write(ns); end; dtBlob :begin ns:= 4; wr.Write(ns); end; ... end; FieldData[c].Tipo:= ns; // <- !!!??
  11. Kas Ob.

    Persist data in a stream

    Don't have an answer, but some thoughts here 1) You control these two devices, so why not log the problem input then compare, just log i,c and bd , this should give you a great insight. 2) Where did the data come from ? is it same DB or by mistake you have two different DB, compare the source. 3) "bd value is not the same in Delphi 10.3 as in Delphi 10.4" is not enough, does bd have meaningful data or something unreadable ? are bd value is from different fields ? Hope that helps.
  12. Nice !, and i like how you combined all the padding in one place, but i have to point a thing about this padding function at https://github.com/halilhanbadem/AES-256-CBCEncryptionDelphi_PHP/blob/master/delphiAESDemo/lib/AESEncDec.pas Zero padding and Random padding should not be here, i mean for encryption, as they can and most likely will cause data corruption, zero padding is essential for hashing calculation but very dangerous or even wrong with encryption/decryption, and as you designed it for only encryption then they both should not be here or at least warn the user about there dangerous when decryption, there is no way to check length of the data, unless you include the data length within the data itself, in this case you are better with the other padding methods as they handle this right.
  13. Kas Ob.

    TListView first and last item visible

    Ops is not quite enough, i have to visit a doctor for eyes check or brain damage, i am sorry i missed the FMX part !
  14. Kas Ob.

    TListView first and last item visible

    There is many ways to this, but ! Now we have a problem, and i am sorry for this long post, lets fix the problem at its core 1) TListView is Windows system class, and it does manage the item on itself. 2) The system can and will manage it in best way, a way you will waste time and put error prone code to do the things the system is doing better. 3) ListView will not ask you to draw invisible items or items out side of the viewing port !!!!!!!!, it doesn't ask to draw them all , but will notify for all, see the difference, it might as for any item, under moving the mouse, or on resizing.... the is the problem that you think you have to solve. 4) The problem is understanding how it does work with its notification and Delphi documentation is not much of help on this matter, this is the core of the problem. I didn't google for resources to explain this or just add extra info, but i will demonstrate how to debug your assumption of something when you feel it is wrong, just investigate it ! Here my way to get confirmation of what i remember also i do that for what so ever i think it can be better, so lets get information. I dropped a list view and a memo on a form like this And only used two events procedure TForm12.FormCreate(Sender: TObject); var I: Integer; begin ListView1.Items.BeginUpdate; try for I := 0 to 500 - 1 do with ListView1.Items.Add do Caption := IntToStr(I); finally ListView1.Items.EndUpdate; end; end; procedure TForm12.ListView1CustomDrawItem(Sender: TCustomListView; Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean); var Rect: TRect; begin Rect := Item.DisplayRect(drBounds); //if (Rect.Top <> Rect.Bottom) and (Rect.Bottom >= 0) then Memo1.Lines.Add(IntToStr(Item.Index) + ' Top: ' + IntToStr(Rect.Top) + ' Bottom: ' + IntToStr(Rect.Bottom)); end; Now to the result we have when we move the mouse over items, only these items under the mouse cursor will be notified to redraw. I moved the mouse over the item 44, yet the system asked for redraw far stuff like 6 and 7... By scrolling to the end, everything will be clear Scrolling down gave negative coordinates also draw them all, (backward may be, this is irrelevant), we don't care but we started to understand how it works, right ? Now lets go back to the top of what we recorded and we will notice this So the system issued draw notification on all items with zero size rectangle then after that issued draw event on the visible items with dimensions. I hope by now you see the use of the commented line, and how it decreased the draw event to only the visible items, literally the bare minimum of draw code will be executed now. My last thought on your approach, try to not draw anything out of the according event, in most cases (almost always) issue an invalidate (on the listview as whole or a part of it like an item), and your draw will do it fast and right. You might need to rethink your OnUpdateObjects usage accordingly! Hope that help.
  15. WinLicense https://www.oreans.com/WinLicense.php In my opinion it is the best what money can buy, also the most powerful protection and hardest mechanism to crack (or analysis) in public sector, one feature not listed on the site is that they provide unique custom private VM's for extra peace of mind, while doesn't need much to do it right, while Oreans support are always there for you, very professional and on top of their game. ps: I got my private VM's for free years back and they still compatible with newer versions, i don't know if this is a free service for every client they have or not, you can ask the support about their policy about this.