Jump to content

storing a value


Recommended Posts

Hello :rolleyes:

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 :)

Link to comment

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.

Link to comment

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.

Link to comment

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

Link to comment

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.

Link to comment

:)

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.

Link to comment

Hi, I wanted to clarify:

  1. How do you get the string, "x23y45z3"? Does the user type it into a text box?
  2. 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 :unsure:

Why?

Link to comment

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.

Link to comment

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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.