04-27-2022 03:56 PM - edited 04-27-2022 04:01 PM
Hello everyone,
i attatched a simple VI which does the following: it gives the mouse position in pixels when i click the mouse in an image.
My question is: I need to continuously save the last position was clicked in a variable, and then subtract the new position (when a new click occurs) from the old position. can anyone please help how to do this?
I would be very thankful for any help 🙂
Thank you in advance
Solved! Go to Solution.
04-27-2022 04:20 PM
If you need to keep a record of what happened in the last iteration of a loop, you should use a shift register. There was a really good example called Draw Graph with Events or something similar that would help you understand this. NI took it out of the example finder though. If I find my old copy I will post it for you.
04-27-2022 04:41 PM
Thank you for your reply.
i tried it with a shift register but somehow im not getting the result i need, which is to subtract the new value when another click occurs from the old value 😕
04-27-2022 05:53 PM
I managed to solve it by using shift registers and saving the values to an array.
thanks again
04-28-2022 08:25 AM
Great! Glad you figured it out. I did find that old example. Guess what? It builds an array of coordinates that hold all the points in the graph just like you did. Check it out...
NOTE: The example is old (2010?) but it opened in my 2019 so I saved it for that. Let me know if you can't open it. I used this example to start many programs where I needed to draw in an XY graph (like thermal profiles, etc.). It's got some useful ideas in it even though it's a small program. I don't know why NI dropped it from the examples.