LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a function

Hi

 

Can anyone help me in creating a function in Labview. This function also contains while loop.

 

int function(int a, intb)

{

   while(1)

   {

           int c ;

           c=a+b;

           cout<< a+b;

    }

}

 

I need to know the method and how to call this funcion in Labview.

0 Kudos
Message 1 of 14
(5,528 Views)

I think you are looking to make a sub-vi with two inputs (inta and intb)

 

That said, there is nothing telling that function to ever stop. Why do you even have variable C? You don't print or return it.

 

What are you trying to do? 

Message Edited by ctardi on 03-17-2009 07:26 AM
0 Kudos
Message 2 of 14
(5,521 Views)

Looks like a homework problem to me.

 

And if it's not, have you gone through the LabVIEW tutorials?

 

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

Message Edited by smercurio_fc on 03-17-2009 09:32 AM
Message 3 of 14
(5,514 Views)

I ran across a couple good LabVIEW articles and examples that cover what you need to learn.

 

One is at:  http://zone.ni.com/devzone/cda/tut/p/id/4161

 

The other can be found by going to the Code Interface Node help in LabVIEW and opening the provided example.

 

Those two resources should help you out.

Message 4 of 14
(5,497 Views)
If you want this to be written in G and not C then it is a straightforward while loop wired False to the stop terminal with an addition function inside to add your A and B integer controls together, with an indicator on the outside of the loop labeled C.  Try wiring this up and showing us what you end up with.
Message 5 of 14
(5,491 Views)
I'm not professional on this.  Can touch me by (hyncucn@gmail.com)
0 Kudos
Message 6 of 14
(5,458 Views)

Haoyue.China wrote:
I'm not professional on this.  Can touch me by (hyncucn@gmail.com)

 

I'm sorry, but it's not clear what you're asking. Can you elaborate?

Message 7 of 14
(5,446 Views)

I believe this is what you want:

 

An infinite/process hogging loop, so be careful with it

 

 Computer Killer

Message Edited by jmcbee on 03-17-2009 12:30 PM
Message 8 of 14
(5,428 Views)

You are good at that?  I have some intrest in  that.

0 Kudos
Message 9 of 14
(5,395 Views)

Hi

 

I know how to make a sub-VI but I cant make sub-VI including while loop. Infact I am making an application which involves alot of code and I am trying to make the application small by using functions or  subvi. So can anyone guide me how to make a function containing loops (for loop or while).

0 Kudos
Message 10 of 14
(5,380 Views)