Jump to content

Tommi Prami

Members
  • Content Count

    520
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Tommi Prami

  1. Tommi Prami

    Null value for T

    Thanks! I jumped through some serious hoops to get that. Have to go through that code...
  2. Did not find example for this. Basically I need some kind of methods that are UpdatePropertyIfAvaibalble(const AInterface interface; const APropertyName: string; const AValue: string); UpdatePropertyIfAvaibalble(IMyInterfaceThingy, 'Id', 'IDSTRINGVALUE'); And overloads for different data types. Datatype is known. Cool if would check the datatype of property tough, is it compatible... Why I need this is that there is XML interface which does not have inheritance, so most nodes have all the same properties but not inherited from same interface so can't use that (woulöd have been too easy :D). So using RTTI would help a ton. Never done that with interfaces so not sure where to start. -Tee-
  3. Have not done much Generics stuff, but the trivial stuff. I think this must be class of some sort, right? To get the/return T Something like : (This could be actual helper also, maybe??) TGenericListHelper<T> = class(TObject) public function Diffference(const AList1, AList2: TLIst<T>): TList<T>; end; Something like that. And then add rest. I'll try to implement that on my own but if someone has good code/ideas for that, let me know.
  4. True dat. I am interested in the values, not the order.
  5. I is too large of an library to add into our SVN for such a little use cases, at least so far, Could check for the algorithm tough.
  6. Got it. Not super good but seems to work, TGenericListHelper = class(TObject) public class function Difference<T>(const AList1, AList2: TList<T>): TList<T>; end; class function TGenericListHelper.Difference<T>(const AList1, AList2: TList<T>): TList<T>; var I: Integer; begin Result := TList<T>.Create; for I := 0 to AList1.Count - 1 do if AList2.IndexOf(AList1) = -1 then Result.Add(AList1); for I := 0 to AList2.Count - 1 do if AList1.IndexOf(AList2) = -1 then Result.Add(AList2); end; Surely with sorting etc can make this faster and most likely there is better algorithm for this. If you know how to make this better, I am all ears. -Tee-
  7. I have an code: function FindParentNodeByName(const AChildNode: IXMLDOMNode; const AParentNodeName: string): IXMLDOMNode; var LParentNode: IXMLDOMNode; begin Result := nil; if not Assigned(AChildNode) then Exit; LParentNode := AChildNode; repeat LParentNode := LParentNode.parentNode; if Assigned(LParentNode) and (LParentNode.nodeName = AParentNodeName) then Exit(LParentNode); until not Assigned(LParentNode) end; Which finds the Node OK, but if I cann it two times with same parameters are not same, meaning their pointers are not same. So if I have two random IXMLDOMNodes from same XML document, how I can be sure that they are actually same, if can't compare pointer? So if I have something like: LParent1 := FindParentNodeByName(LNode1, 'somenode'); LParent2 := FindParentNodeByName(LNode1, 'somenode'); if LParent1 = LParent2 then ShowMessage('Same); // Won't work ever So I should have some way to compare they are actually same node like if LParent1.IsExactlySameNode(LParent2) then ShowMessage('Same); -Tee- PS. not sure if this is actually right group, move if in wrong one...
  8. Tommi Prami

    How to compare msXML nodes

    How? Or where? But the actual DOM must not change because need to save it after processing. -Tee-
  9. Tommi Prami

    How to compare msXML nodes

    Not talking about equal, maybe lost in translation, I am talking of SAME node. BAsically i've got two separate processes, and I need to compare their result in third are they actually very same node or not. But I just assumed that DOM woulöd somehow know, or have some comparison to tell are these two random nodes actually same node or not. Apparently not, because there has not been any answer. And didn't find anything by googling around. I think I am not allowed to change the structure of the XML. if there is "tag" property in the nodes, most likely could walk through the DOM at beginning and initialize some counter ID. Or Actually would need only mark nodes I am interested in, while searching the nodes of interest. -Tee-
  10. Tommi Prami

    How to compare msXML nodes

    Hello, Thanks for workaround ideas. I've got an workaround/fix idea. I just really really would like to avoid it. Too much of an work at this point of time. If someone has any idea how to compare compare random nodes and tell ae they exact same nodes or not, would be really cool! -Tee-
  11. Tommi Prami

    How to compare msXML nodes

    My first suggestions was not to use msXML, and guess the answer I got... -Tee-
  12. Tommi Prami

    How to compare msXML nodes

    Here is the copy / paste style test app, thats why some extra complexity https://www.dropbox.com/s/zz3ui9kdtef9ybd/msXmlFindParent.7z?dl=0 -Tee-
  13. Tommi Prami

    How to compare msXML nodes

    The problem is that. I have two pr more nodes. I have one or nodes in the tree, same level and name, but there might be more than one. I'll try to illustrate. <?xml version="1.0" encoding="UTF-8"?> <root> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Beer this week end, please</body> <footer>and some other beverages</footer> </note> <note> <to>Big Lebowski</to> <from>Stephen King</from> <heading>FYI</heading> <body>Not on my rug</body> <footer>man</footer> </note> </root> If got list of From nodes on my hand, lets say for sport, from that XML 7 of them. lots of duplicates, sadly I am only here at this point in life (for sake of example). I need to know are they members of same node or not. Lets say I would like to throw away the duplicates, or whatever.. . To my surprise even though my code returns same node, but the pointer is not the same. I've debugged this and have unittest for it also that proves it. Is there in msXML any way to tell are two node s the same, as the variable/pointer are not same. Is this because of it's an Interface, dunno But the nodes returned haven't same value in those LNode1 and LNode2 variables in that case, I am sure the node is the same tough... XML which I was working on had only one parent node so it made me really question my mental health. But I've got code to prove it. I'll try to make runnable demo on weekend If have time. Path is not OK, because path can be same up to the root. I am not fully awake so I just can't managage to compress my thoughts into fewer words. -Tee-
  14. https://quality.embarcadero.com/browse/RSP-23466 And if someone is in Beta-program, test and try to be vocal towards Embarcadero about this.
  15. Coworker sent me this, interesting to see active development on parallel algorithms. Don't have opinion on this, what so ever. Just FYI. https://en.wikipedia.org/wiki/Bitonic_sorter
  16. Tommi Prami

    Bitonic sorter

    Maybe examples are made single threaded for simplicity? Dunno tough.
  17. let's say if I have window Handle (Delphi app form), found by some windows API like FindWindow etc. Sometimes it seems that Window is created and has an handle but not fully functional yet. Is there a way to query with windows API that Delphi form is run all OnCreate etc events amnd is fully visible and all components are ready for user. Reason I as we use AutoIT to automatically test our Apps,, and sometimes Form is not ready yet. No fully visible or still runnin initialization events (OnCreate etc). If not I've suggested to add out base form class an message handler which we could use to quety, then problem would be how the Form it self Knows everything is OK, up and running 🙂 -Tee-
  18. Tommi Prami

    IDE adds {$R} between units

    In .dpr? Yes it does and that has been going on at least few versions now
  19. Tommi Prami

    Relaxed JSON

    Seems to me that is not very smart format/standard. If some service produce it and have to use it, then for sure need an parser. But I would steer away from that format if just can. Little bit sketchy. -Tee-
  20. Tommi Prami

    Generic Command Line Parser for Delphi 10.3.x

    I like your expected Command Line syntax. -Tee-
  21. Tommi Prami

    WinAPI to query if a form is ready to Rock.

    Could you elaborate bit more? What this means in practise -Tee-
  22. Tommi Prami

    WinAPI to query if a form is ready to Rock.

    While was walking to work had couple of ideas on this, What if at FormActivate (For example) event of base form, I would do either. 1. Send message to window it self, If I've understood correctly window will not receive that message untill it has processed all the Form initializations of it self, and is able to recveive messages again. 2. Create and start timer and disable and free it on first tick. I think this is essentially same as the method 1. Some codes, me included, are not used to using windows messages too much. Delphi hides the need quite well. When the message arrives or timer fires set the flag that can be queried with other messsage from outside of the app. This should give pretty good starting point. -Tee-
  23. Tommi Prami

    WinAPI to query if a form is ready to Rock.

    It seems this can happen (On Form) quite common places. Not too many but still. Did not know any of this, Always thought that handle would be totally permanent on it's whole life time... -Tee-
  24. Tommi Prami

    WinAPI to query if a form is ready to Rock.

    Delayed initialization is an separate problem I think, and that can be handled Case by case, if needed. How, why and when Delphi will recreate the Hvnd for a Form? Never heard of this, this might explain rare weirdness. -Tee-
  25. https://en.wikipedia.org/wiki/Fast_inverse_square_root There was code samples long time ago for Delphi. With different constants, to spread error to positive , negative or +/- Also pure pascal version so routine could be inlined. It vas pretty fast Used in odl company. No need for me right now, but would be still cool to have it around and put into the Wiki and so on, also Delphi version of the code. -Tee-
×