Jump to content
Sign in to follow this  
prayami

Portion of code want to execute only once

Recommended Posts

Hi..

I have made one VI. In which some portion of code I want to execute only once. For that I have made one case statement. First time case condition is true and

desire code is executed. But how can I stop executing that code second time. Means second time I want to make case condition variable false.

How can I do that?

Thanks in advance.......

Share this post


Link to post
Share on other sites

QUOTE(prayami @ Mar 26 2007, 05:39 PM)

Hi..

I have made one VI. In which some portion of code I want to execute only once. For that I have made one case statement. First time case condition is true and

desire code is executed. But how can I stop executing that code second time. Means second time I want to make case condition variable false.

How can I do that?

Thanks in advance.......

Search in the palettes for the "First call?" primitive. Wire that boolean output to your case structure. That prim will return true the first time it is called, but false thereafter. If you stop the VI running and restart, the prim resets.

Share this post


Link to post
Share on other sites

QUOTE(Aristos Queue @ Mar 26 2007, 06:22 PM)

Search in the palettes for the "First call?" primitive. Wire that boolean output to your case structure. That prim will return true the first time it is called, but false thereafter. If you stop the VI running and restart, the prim resets.

First call works well if you only want the case called only once during program execution, but if this is a subvi that needs to be initialized each time it is called you should use a shift register.

Share this post


Link to post
Share on other sites

Thanks for reply. I want to make subVI so gleichman is right. I have to make shift register. I tried to make one but as I am new to LabVIEW. I am not getting

success. I know it is very basic but don't know, why I can't make it happen?

Is there anybody who can send me simple subVI in which (may be using Shift Register) some portion of code can be called once even though the subVI is in the

while loop when that subVI will be used.

Thanks in advance.......

Share this post


Link to post
Share on other sites

QUOTE(prayami @ Mar 28 2007, 02:08 PM)

Thanks in advance.......

Check the Examples that ship with LV ( Help >> Find Examples... in the menus). Search for keyword "uninitialized". The only VI that is returned in the find results should be educational.

Share this post


Link to post
Share on other sites

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.

Sign in to follow this  

×
×
  • Create New...

Important Information

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