Guenther Posted March 9, 2006 Report Share Posted March 9, 2006 Hi folks, I want to call a VI from the same main VI one time as a standard sub-VI, later as a dynamic VI. The 2 instances do not run at the same time, but consecutively. The sub-VI call runs allright and so does the dynamic call, the VI works allright. Trouble starts, when I want to read an indicator of the dynamic instance, then I get an "invalid refnum" error. If I use 2 identical copies of the sub-VI with different names, using one as sub-VI, the other as dynamic VI, everything is allright. Is there something in LV that prevents me form doing such a thing or am I doing something wrong in the dynamic calling part? I hate the thought of having 2 identical copies of a VI clogging up memory. :thumbdown: Thanks a lot! Guenther Quote Link to comment
WMassey Posted March 9, 2006 Report Share Posted March 9, 2006 There definitely may be better ways of doing this but I believe if, in the dynamic case, you were to make the VI in question run as a subVI to another main VI that did nothing more than call the subVI, then I think it will work. Quote Link to comment
Aitor Solar Posted March 9, 2006 Report Share Posted March 9, 2006 I hate the thought of having 2 identical copies of a VI clogging up memory. :thumbdown: I'm afraid you'll have. Keep in mind that the subVI is loaded in memory under your program, so when you try con control it programmatically, you are fighting against your own code. In my experience, when you call programmatically a VI you shouldn't have it as a subVI, even if that subVI is never called or is disabled. My advice is to avoid that situation. If that's impossible, try calling it as a template (because each instance will have a different name and different memory allocation). Hope that helps. Saludos, Aitor Quote Link to comment
Guenther Posted March 9, 2006 Author Report Share Posted March 9, 2006 So, it doesn't look like there's an easy way out. Guess I'll have to live with the 2 copies. Thanks for pointing that out, Aitor! Quote Link to comment
crelf Posted March 9, 2006 Report Share Posted March 9, 2006 In my experience, when you call programmatically a VI you shouldn't have it as a subVI, even if that subVI is never called or is disabled. Is that true for a built application? I was under the impression that even dynamically called VIs had to be called as subVIs somewhere (like you said - in an area that is never called) in the built application. The way I get around this is to include a "tree" VI outside of the exe (but still part of the build) that includes all of the dynamically called VIs on it's BD - this means that if I need to update the system later and add new dynamically called VIs (ie: plugins), then I can overwrite the tree VI and include my new dynamically called VIs and they will load... Quote Link to comment
Aitor Solar Posted March 9, 2006 Report Share Posted March 9, 2006 So, it doesn't look like there's an easy way out. Guess I'll have to live with the 2 copies. Thanks for pointing that out, Aitor! You're welcome. I don't know your application, but I'm pretty sure you could find a way of not having that VI as a subVI. For example, if you launch it through VI Server (i.e., dinamically) and check to true the "Wait until done" option, the program behavior will be almost the same as if it was a normal subVI. Saludos, Aitor Quote Link to comment
i2dx Posted March 9, 2006 Report Share Posted March 9, 2006 as far as i know, this will not work. if you try to start a VI, which is NOT reentrant and which is a subvi of an other running vi, via VI server, you will get the error 1000: The VI is not in a state compatible with this operation. Quote Link to comment
Rolf Kalbermatter Posted March 22, 2006 Report Share Posted March 22, 2006 Is that true for a built application? I was under the impression that even dynamically called VIs had to be called as subVIs somewhere (like you said - in an area that is never called) in the built application. Why! Just make sure you add those dynamically called Vis as such to your build script or Project. Or as alternative if you do this for plugin VIs that should remain outside of the application make sure you compute the right path when trying to load it. Of course there is the possible problem of plugin VIs using subVIs that were getting out of sync with the same named VIs used in the main application. This can be managed a little easier by using an All Project VIs.vi that contains all the dynamically called VIs as well as the main Top level VI. For editing the project you load this All VIs VI but you do not include that in the application build at all. Rolf Kalbermatter Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.