Jump to content

What's the difference between a Functional Global Variance and a general Sub-vi with same function


Recommended Posts

From some books and documents, these two seem don't have much difference, the result of using a Functional Global Variance is the same as that of calling a sub-vi with same function, then why does LabVIEW develop the concept of Functional Global Variance? Is there any good reasons to use the Functional Global Variance instead of a sub-vi?

Thanks a lot!

Link to comment

From some books and documents, these two seem don't have much difference, the result of using a Functional Global Variance is the same as that of calling a sub-vi with same function, then why does LabVIEW develop the concept of Functional Global Variance? Is there any good reasons to use the Functional Global Variance instead of a sub-vi?

Thanks a lot!

I'm not sure I know what you are talking about. Do you mean "Functional Global Variable"? More info here.

Link to comment

I'm not sure I know what you are talking about. Do you mean "Functional Global Variable"? More info here.

Sorry, I made a incorrect spell for "Variable".

Yes, I mean Functional Global Variable, and I wonder why and when we should use a Functional Global Variable instead of implementing it as a geneal sub-vi, Or simply speaking, why do we call the function part as Functional Global Variable, not as a sub-vi.

Thank you for your quick and kind reply.

Link to comment

A functional global *is* a subVI with an unitialised shift register that stores data. You can do more with it than just that (hence the "functional" part of its' title), but all functional globals have the unitialized shift register as their basis.

Link to comment

A functional global *is* a subVI with an unitialised shift register that stores data. You can do more with it than just that (hence the "functional" part of its' title), but all functional globals have the unitialized shift register as their basis.

I have seen two exceptions to that rule, one good one bad...

The FG could be wrapping up a single element queue to stor the data (good)

The FG could be using off-icon-connector controls to store the data (bad and down right cruel to expose a young G-babe too. I still wince thinking about it).

Ben

Edited by neBulus
Link to comment
  • 3 weeks later...

From some books and documents, these two seem don't have much difference, the result of using a Functional Global Variance is the same as that of calling a sub-vi with same function, then why does LabVIEW develop the concept of Functional Global Variance? Is there any good reasons to use the Functional Global Variance instead of a sub-vi?

Thanks a lot!

One thing to note about a simple subVI (statically defined default when you define one) it acts as a semaphore.

The locking is implied by the fact that only one call to a static subVI can proceed at a time.

This makes default data inside the subVI 'safe' in that only one access at a time is permitted to the subVI however,

using default data in controls always has a way of causing strange bugs so it is critical to initialize a subVI on the first iteration of it.

That said Functional Globals are excellent way to initialize data and retain values between calls.

Use FG's whenever you need to initialize data and then safely maintain the data in that subVI.

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
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.