LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a flag

How can I set a flag?
I tried to connect a boolean (true) to a local variable, but it didn't work since the local variable had a question mark in it!
Is there a better method to set a flag?

Many Thaanks
0 Kudos
Message 1 of 10
(7,569 Views)
You have created a local variable but not selected the Front Panel object. The way you do that is to right click the local variable you created and select the object you want to set flag.
0 Kudos
Message 2 of 10
(7,569 Views)
But I don't need a front panel object. I just wanna set a flag in the block diagram and retrieve its value at some other point in the program. So no front panel activity will be involved with it. The local variable shouldn't be linked with anything, all it should so is store a value!
0 Kudos
Message 3 of 10
(7,569 Views)
I saw you mentioning about local variables with a question mark, that is the reason for my response.
The way you can set a flag in the block diagram will be to use LabVIEW 2 style variables, where you will use a shift register to retain the flag value.

You cannot have a local variable without assigning any FP object.
0 Kudos
Message 4 of 10
(7,569 Views)
Why don't you just use a wire or shift register to pass a value? That's the prefered method in LabVIEW. A local or global (LV2 style or not) should be considered as a last resort.
0 Kudos
Message 5 of 10
(7,569 Views)
...Hello,

I'm using quite many local variables. I think that keeps the block diagram tidy, rather than having a ton of for/while loops with shift registers instead.

Cheerio
0 Kudos
Message 6 of 10
(7,569 Views)
They also use extra memory which can also dramatically slow down your app and they break dataflow with the risk of race conditions. Programs with a lot of locals are much harder to debug - trust me on this. Shift registers can be very tidy if done right and don't cause the problems that locals do. The "LabVIEW Development Guidelines" document that ships with LabVIEW has a section on locals/globals and a reference to functional global variables which can be used to replace a standard global variable but nothing in LabVIEW is as effecient as a wire.
0 Kudos
Message 7 of 10
(7,569 Views)
Totally Agree Dennis, limit the use of Local variables and take caution when using them in communicating data between parts of your code.

In your initial comment regarding local varibles, create a front panel object then set the hide property so you cant see the object.

Kind Regards


Steven Bird
Applications Engineer
National Instruments
0 Kudos
Message 8 of 10
(7,569 Views)

Hi

 

 

 

0 Kudos
Message 9 of 10
(6,371 Views)

@FLiu wrote:


Probably that a lot has changed in 11 year, and that a new thread should be made where you clearly explain your issues, posting details and example code.

 

11 years ago a 3 mega pixel camera cost about $200, and new cell phones had a 1 mega pixel camera.

0 Kudos
Message 10 of 10
(6,352 Views)