LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Howto: Make Current Values Default in code

Hi,

According to the manual it should be easy to make a simple code so that when
I stop my program the paramtre values will be the sat to default so that
they are the same when I start the program next time. The online help is not
good enough to make me understand. Any idea how this can be accomplished?

Thanks
Leif H
0 Kudos
Message 1 of 14
(5,924 Views)
Hi,

Here is one way.

regards
Ray Farmer

(example is in labview 6.1)
Regards
Ray Farmer
0 Kudos
Message 2 of 14
(5,924 Views)
Once you have all your front panel objects and you have them set to the
values you want for default, go to the Edit menu and select Make All Current
Values Default, then save. You can also do this for individual front panel
controls by right-clicking on the object, select Data Operations, then Make
Current Value Default. Hope this helps.


"Leif H" wrote in message news:ail6av$b5k$3@dolly.uninett.no...
> Hi,
>
> According to the manual it should be easy to make a simple code so that
when
> I stop my program the paramtre values will be the sat to default so that
> they are the same when I start the program next time. The online help is
not
> good enough to make me understand. Any idea how this can be accomplished?
>
> Thanks
> Leif H
>
>
>
0 Kudos
Message 3 of 14
(5,924 Views)
Unless it has changed in 6.1, programmatically setting values to default is treacherous.
There is a method (right click the control to access it) to set to default. But you cannot use it in a compiled version of vi. So better right from the start use ini files or a set of constants inside the vi to preload the controls (e.g. through local variables).

Gabi
7.1 -- 2013
CLA
0 Kudos
Message 4 of 14
(5,924 Views)
Right click on the front panel control you want to set to default, select 'Create>Invoke node', then select Reinit to Dflt, which reinitializes the value of the control to the default value. Put this at the end of your program and it will reset the values to the default when your program ends.

Alternatively, what i do is wire valves to the controls through local variables, which gives a little more flexibility as i can set it to whatever i wish, and not just the default value.

Let me know if you need an example and what LV version you require it in.

Kim
0 Kudos
Message 5 of 14
(5,924 Views)
Hi,

The problem with using the Reinitialize All to Default method in an exe has been fixed in LabVIEW 6.1.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 6 of 14
(5,924 Views)
Hi Leif,

Unless I am Mistaken, you want to set the current values of controls in a Panel to Default. It is Like User Having Control when next time the Panel Opens, What Values it will have. This is especially useful if you want to store Instrument Addresse, Specifications etc.

One Method is to Use INI or Registry files to hold your Values. And Read them when Panel is Opened and Update them when Panel is Closed.

But the Challenge is to not use the file and use "Make Current Values Default" Method to do this. Keep the Following Issues in mind.

1. This Property can be Used on a vi provided the VI is not running. So if you use this Property in the Program section of VI, it will not Work because a VI cannot save itself when running. Lets call this Vi "Main.VI"

2. You have to "Dynamically Run" another Vi(Lets Call it "Save Defaults.vi") which will then save the Current Values of your Main VI. The Most Important Information for this VI is the Path of the Main.vi

3. When you Want to Pass the Value of Path you Must use Invoke Node With Flatten to String Function. Instead of Putting this in my "Main VI". I created another vi( call it "Run Save Defaults.vi") The Input to this new VI is path Information from the Main.vi.

The Advantage is I can Just use the "Run Save Defaults.vi" form any VI, by just wiring the Path to it. It will call the "Save Defaults.vi" and Perform necessary task.

All these Concepts are best illustrated using 3 VIs Attached.

The "Make Value def Example.vi" is the Main VI.
This VI Calls "Run Save Defaults.vi" with its current value of path. The "Run Save Defaults.vi" takes the Path and Dynamically calls "Save Defaults.vi" and also dynamically passes Path Information of the Main VI. It then ends and in effect ends the Main VI.

The "Save Defaults.vi" now Has the Path Information of the Main VI. It first Checks if the Main VI has ended.
It then Proceeds to Save the Default Values and Close this VI. On Success it Closes itself or Displays Error Message.

Two things to Keep in mind.

1. Make sure you save all three VIs in same Subdirectory. The two Subvi's use the reference of main VI path for acccess.

2. The Main VI "Make Values Def Example.vi" must be Top Level. It cannot be Called by another VI. If you need to Call this Vi then you have to dynamically call it using the "Run Vi" Method.


I Hope you can take it from here.

Good Luck!!

Mache
Good Luck!

Mache
Message 7 of 14
(5,926 Views)
This is the way to do it:

1. The target VI may not be in run mode. This means that you must use
another VI to open a reference to the target VI when it is not
running.
2. Use the opened reference and property nodes to "Make current values
default" and then "Save" the target VI.
3. Close the VI reference to the target VI.
0 Kudos
Message 8 of 14
(5,924 Views)
Leif:

Right mouse on the control in question, select "data operations" and
then set the default value under there. You can also explicitly write
your code to set values into your controls using local variables if
you wish.

Douglas De Clue
LabVIEW developer
ddeclue@bellsouth.net

"Leif H" wrote in message news:...
> Hi,
>
> According to the manual it should be easy to make a simple code so that when
> I stop my program the paramtre values will be the sat to default so that
> they are the same when I start the program next time. The online help is not
> good enough to make me understand. Any idea how this can be accomplished?
>
> Thanks
> Leif H
0 Kudos
Message 9 of 14
(5,924 Views)
Hi,

Thanks for your contributions.

This is what I like to do. When my program is run the user adjust the values
of the different controls. When he exit the program I want it to save the
control values so that when the user starts the program again he can
continue with the same values he had when he did exit.
The way we have done it today is by copying the control values to local
variables and saving these to a file when the Stop program button is
clicked. When the program is started the file is read into the local
variables which again set the values of the control. This is a lot of code.
What I had hoped was that this code could be replaced with a single function
call.


Leif H

PS. Why isn't there an option in LabView saying "Always Make Current Values
De
fault" when exit program?



"Douglas De Clue" wrote in message
news:6f0395b7.0208050855.656f9a82@posting.google.com...
> Leif:
>
> Right mouse on the control in question, select "data operations" and
> then set the default value under there. You can also explicitly write
> your code to set values into your controls using local variables if
> you wish.
>
> Douglas De Clue
> LabVIEW developer
> ddeclue@bellsouth.net
>
> "Leif H" wrote in message
news:...
> > Hi,
> >
> > According to the manual it should be easy to make a simple code so that
when
> > I stop my program the paramtre values will be the sat to default so that
> > they are the same when I start the program next time. The online help is
not
> > good enough to make me understand. Any idea how this can be
accomplished?
> >
> > Thanks
> > Leif H
0 Kudos
Message 10 of 14
(5,924 Views)