From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Load Sub VI into Memory and Add Control to that Sub VI during Run Time?

Solved!
Go to solution

As the title suggests, my question has two parts:

1. How to load sub VI into memory when I call the main VI?

2. How to add control to that sub VI during run time?

 

 

I attach the code to add the control to the sub VI. This works in in project environment and NOT during run-time. Even so, I need to manually open "Untitled 7.vi" for it to work, otherwise an error will show telling me that the sub VI is not in the memory

 

Error 1004 occurred at Open VI Reference in Main.vi

Possible reason(s):

LabVIEW: The VI is not in memory.

To load a VI into memory with the Open VI Reference function, a path must be wired for the VI Path input.

VI Name: Untitled Library 1.lvlib:Untitled 7.vi

 

 

What I want to achieve is to load the sub VI into memory and add a control on the front panel and call the open the sub VI front panel. All this is required to be done during run time.

 

I truly appreciate any help I can get on this forum. Thank you.

 

HK

0 Kudos
Message 1 of 7
(3,976 Views)
Solution
Accepted by topic author HK-RKS

1. A static call to a subVI (default settings) already makes sure that a subVI is loaded with its caller

2. VI Scripting is a tool for automating development tasks. You cannot use VI Scripting on running VIs

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 7
(3,972 Views)

In Build Specification -> Source files, any dynamically called vi must be in Always Included. The compiler only includes statically linked vi's by default (which makes sense).

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 3 of 7
(3,969 Views)

@HK-RKS wrote:
[...]

What I want to achieve is to load the sub VI into memory and add a control on the front panel and call the open the sub VI front panel. All this is required to be done during run time.

[...]

HK


You can use the visible properties of controls and display only the controls you need in that specific situation. Other controls are hidden (visible = false).

The controls have to be placed during development of course.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 7
(3,959 Views)


You can use the visible properties of controls and display only the controls you need in that specific situation. Other controls are hidden (visible = false).

The controls have to be placed during development of course.



Thanks for the reply, Norbert.

 

Yes, I am aware that I can add the controls during development time and hide/show them during run time. I am exploring if there's a better way of doing that, because the program would dynamically require hundreds of controls (and could be different type of controls) and I just don't think it's an elegant way to create the controls during development time and hide/show them in run-time.

 

I think it's also feasible to create an array of controls (or array of cluster of controls) and size the array according to the number of elements in it? But that would mean I have limited options to play around with the positions or visuals of the controls as they are contained in an array, so I didn't attempt that.

 

Anyway, thanks once again for the helpful reply!

 

HK

 

 

0 Kudos
Message 5 of 7
(3,955 Views)

HK-RKS wrote:
[...]

I think it's also feasible to create an array of controls (or array of cluster of controls) and size the array according to the number of elements in it?  [...]


An array is in many cases a suitable approach. You can resize an array by setting the Number of Columns or Number of Rows property.

However, all elements in an array share all properties (e.g. size, color, ...) except the VALUE. So for graphical highlighting, arrays are very difficult.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 7
(3,930 Views)

In a compiled file you can't add or remove controls dynamically, only show/hide. It sounds like you're looking for the Sub Panel, with those you can have a decent number on one panel and change them as needed. Tab controls allows much of the same abilities, but are more static.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(3,929 Views)