rb767 Posted February 7, 2017 Report Share Posted February 7, 2017 Hello I have a question regarding storing a value until changed. This might be confusing so ask me if you have any question. Since i can't share my program because of some adminishtrative rules i will try my best to give an example. So i have to give in 3 values say x, y, z and if these values are not given, the program has to read the previous value. For this i think i have to store the value and if it's not given read the value from the place i have stored. How do i do this? Thank you for your help Quote Link to comment
hooovahh Posted February 7, 2017 Report Share Posted February 7, 2017 There's about a dozen ways to store a value and load them later. The easiest in my opinion is to use the OpenG Write Panel to INI and Read Panel From INI, which will save and load control values to a human readable INI file. Other methods involve reading and writing to a binary file with the Read/Write binary where you can bundle all your desired values into a cluster, or turn it into an array. You could also just write it as text. Or write it as TDMS, or a database, or even the Windows registry if your user has permissions. Quote Link to comment
rb767 Posted February 7, 2017 Author Report Share Posted February 7, 2017 Thank you for your help. I know these ways but it is not really helping me. Let me explain a bit more. So there is a string where i give the value as for eg x23y45z3 then i read only the values and give it to the system. Now if I write like x45y23 then the value if z should remain unchanged (3 in this case). But with the above way the saved value for z would then be 0 which i do not want. What do i do? Hope I have made myself clear enough. Quote Link to comment
hooovahh Posted February 7, 2017 Report Share Posted February 7, 2017 Oh well that seems like a poor user interface, that is going to require all kinds of checking. Wouldn't it be a whole lot easier if you asked the user what values they want to input and then default the ones they don't? Attached is what I was thinking. By default you need to provide X, Y and Z, with their default values coming from a constant on the block diagram but could be loaded from a file. Then if you choose to not provide a value it hides that control and will use the default value. Enter XYZ Demo 2013.vi Quote Link to comment
rb767 Posted February 7, 2017 Author Report Share Posted February 7, 2017 According to my supervisor i shouldn't be asking for the individual values that's why I had to make it complicated Quote Link to comment
hooovahh Posted February 7, 2017 Report Share Posted February 7, 2017 Your supervisor is wrong. Still similar code can be used with regular expression or other string parsing tools to find the first number after an "X" and use that as the X and if it isn't found default to the other value. I'm not good at regular expressions so I'd be using things like the Search Split String to find X and get the values after. Quote Link to comment
rb767 Posted February 7, 2017 Author Report Share Posted February 7, 2017 Sorry i haven't mentioned before.. i have done the search and split stuff and read the value and now giving to the system. The problem lies only when i don't have to give 3 of the 5 values every time because they remain the same. I will have to write them when they change. Other two change more often. Quote Link to comment
JKSH Posted February 8, 2017 Report Share Posted February 8, 2017 Hi, I wanted to clarify: How do you get the string, "x23y45z3"? Does the user type it into a text box? How do you give the values back to the user? 10 hours ago, rb767 said: According to my supervisor i shouldn't be asking for the individual values Why? Quote Link to comment
rb767 Posted February 8, 2017 Author Report Share Posted February 8, 2017 yes the user types in the "string". Basically the numbers are the positions the machine has to move. So with search and split string we can get the individual numbers out and give it to the machine. And that is exactly why i can't ask the user to give in the individual values. That would take a longer time and also giving it in a string would make it easy for a layman to run the program. Quote Link to comment
rb767 Posted February 9, 2017 Author Report Share Posted February 9, 2017 Could anybody help me with this? I'm still struggling -.- Quote Link to comment
hooovahh Posted February 9, 2017 Report Share Posted February 9, 2017 A method using regular expression to find the first number after X, Y, and Z. There could be a bug if you entered something like xy10z3 because it will find the first number after x which is 10 and use that. Feel free to improve it. XYZ Example 2.vi Quote Link to comment
rb767 Posted February 9, 2017 Author Report Share Posted February 9, 2017 I am sorry, i don't think i made myself clear. My question is not separating the numbers from the string. I have to write the number in an array, which is also easy. The only problem is i don't want the array to write 0 when the value is not given. Instead of writing zero i want array to not change at all. Just an example: justanexample.vi Quote Link to comment
hooovahh Posted February 9, 2017 Report Share Posted February 9, 2017 You mean a shift register? XYZ Example 3.vi Quote Link to comment
rb767 Posted February 9, 2017 Author Report Share Posted February 9, 2017 Why didn't i think of it ? I was doing some stupid mistake but his really helped. Thanks a ton! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.