LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

variables don't change at the first time

i often work with variables. sometimes i read from a varibale at the beginning of the aplication, and save from a variable at the end of the appplication.
the problem is that the values aren't right at the first time.the values only changes at the second call.
0 Kudos
Message 1 of 4
(2,616 Views)
Hi WeberM

You have to acertain that LabVIEW reads and writes the variables in the order you want.

The best way for this is to use sequences which forces execution timing in the order you program.
Doc-Doc
http://www.machinevision.ch
http://visionindustrielle.ch
Please take time to rate this answer
0 Kudos
Message 2 of 4
(2,616 Views)
Hi,

I think by variables you mean controls that are updated with locals?

If so, they are updated the first time you write them. But perhaps you read
them before the are written (race condition). Try to debug the program (with
the light bulb) to see what happens. To aviod race conditioning, you have to
force the sequence of execution with structures (loops, cases or (preferably
flat) sequence structures.

If this is not it, cuold you send an example?

Regards,

Wiebe.

"WeberM" wrote in message
news:5065000000080000008CEC0000-1079395200000@exchange.ni.com...
> i often work with variables. sometimes i read from a varibale at the
> beginning of the aplication, and save from a variable at the end of
> the appplication.
> the problem is that the values
aren't right at the first time.the
> values only changes at the second call.
0 Kudos
Message 3 of 4
(2,616 Views)
It's not entirely clear what you mean when you say variables. Are you talking about global variables, local variables, or something else (i.e., controls)? If the answer is global variables or local variables then perhaps you should evaluate whether you really need these as they are often sources of race conditions. You may be better off using shift registers to pass the data.

One simple way to force an initialization state is to use a case structure set up with an initialization state when the iteration terminal is zero (i=0). This becomes sort of a quasi state machine structure and is a much better solution than a sequence structure. In some instances a FLAT sequence structure may be OK, but I would encourage you to avoid the use of sequence structures in
general as they disrupt the left to right flow of data which is the accepted practice of LabVIEW programming.

If this doesn't answer your question then if you will post an image or a copy of an example of your code (I am on LV 6.1) then I would be happy to take a look at it.
0 Kudos
Message 4 of 4
(2,616 Views)