06-13-2017 04:33 AM
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
Solved! Go to Solution.
06-13-2017 04:35 AM
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
06-13-2017 04:37 AM
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
06-13-2017 04:44 AM
@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.
06-13-2017 04:58 AM
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
06-13-2017 06:13 AM
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.
06-13-2017 06:17 AM
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