LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass arguments to Insert VI in a subpanel

I have inherited some code that now has to accepts arguments from the command line, so that it changes behavior depending on the arguments. The problem is that the VI that actually needs to change behavior is run in a subpanel via the "Insert VI" method, and is compiled into the executable. A Static Reference is used to obtain the reference to the VI, and then the VI is inserted into a subpanel on the front panel of the main VI (please see attached illustration). It's easy to get the command-line arguments (the User Input string), but how do I pass those to the VI that is invoked via Insert VI?

VI_Ref.jpg

 

0 Kudos
Message 1 of 10
(2,076 Views)

"Insert VI" doesn't actually run the VI, it just sticks it in the panel.

 

Either:

  • The VI is called somewhere else in the program already, and its arguments are passed in there, or
  • You need to call the VI to run at the same time you insert it.

 

If you just need to run it "normally" then all you need to do is call the subVI itself in the usual way you would call it.

 

If that's not the case, then you probably need to do something more complicated, such as a "call by reference" node.

0 Kudos
Message 2 of 10
(2,062 Views)

Hi gmand,

 

inserting a VI in a subpanel does not execute it, there needs to be another place where the VI is actually called...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 10
(2,059 Views)

You need to provide significantly more detail because your description is too ambiguous and the image makes no sense at all.

 

Can you attach a simplified example?

There are plenty of ways to change certain values in a VI, why does it have to be command-line arguments?

0 Kudos
Message 4 of 10
(2,057 Views)

Yes, that's correct, further in the code that same VI Ref (obtained from the Static VI Ref) is used in an Invoke Node with Run VI method. But I can't see how that helps.

 

Ultimately the user arguments have to affect the behavior of the VI that's run, but the user arguments are only available to the main VI. The only thing that the main VI passes on to Insert VI is the VI reference, and that same reference is passed onto Run VI (see attached). All that is very clever and works smoothly.

 

RunVI.jpg

0 Kudos
Message 5 of 10
(2,041 Views)

Hi altenbach, it doesn't have to be command line arguments, but to me it's the simplest way. I need to know who is running the program, and depending on that, modify the appearance/behaviour of the VI that runs in the subpanel. The list of users can be stored, e.g. into a .ini file.

 

Main VI knows that user John is using it (by, say, supplying "John" as command line argument), it looks up user John's parameters in the .ini file, and tells the VI in the subpanel to act accordingly. At least that's my initial approach.

0 Kudos
Message 6 of 10
(2,038 Views)

So the set control value by name method should work.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 10
(2,028 Views)

Thanks, JÞB, I'll look into it.

0 Kudos
Message 8 of 10
(2,021 Views)

Many thanks to all who suggested solutions. I wanted to wrap this up as I found a way to make it work. I used a Functional Global Variable that stores the relevant cluster with parameters when the main VI starts, and then the VI that runs in the subpanel just reads those from the FGV and customizes the FP according to the parameters for that user.

0 Kudos
Message 9 of 10
(1,974 Views)

@gmand wrote:

Many thanks to all who suggested solutions. I wanted to wrap this up as I found a way to make it work. I used a Functional Global Variable that stores the relevant cluster with parameters when the main VI starts, and then the VI that runs in the subpanel just reads those from the FGV and customizes the FP according to the parameters for that user.


That sounds like a lot of trouble to pass parameters.

 

Why not run the VI as a normal subVI, and pass the subpanel reference too. Then, make the VI put itself in the subpanel.

 

This eliminates VI server completely. A big advantage...

0 Kudos
Message 10 of 10
(1,938 Views)