05-19-2012 02:11 AM
Hi Experts,
I have created a folder of VIs it is a set of State Machine VIs. ( Global Var, Typedef Controls, VIs).
I would like to make a copy of this folder and rename the prefix of the VIs. For example: SSM - Main -> NewName -> Main.
My problem is the following. When I renamed ( VI method - Save) them, and placed into my project, The renamed VIs looking for the old name dependencies. Is there any way to make my VIs find the renamed subvis?
For example:
Any Ideas? Thank you!
Solved! Go to Solution.
05-19-2012 03:14 AM
Sorry, Solved!
Next time I will be more careful.
05-19-2012 01:09 PM
The other simpler way to do this is just to do your save-as new-name.vi starting from the bottom of your VI hierarchy and work to the top. If you rename a VI with it open, (not just rename in the operating system), then LabVIEW updates the callers, then when you rename and save them the already have the dependency reference changes for their subVIs, etc, etc til you save the topmost VI last. I'm not positive, but I think I recall seeing a couple of utility VIs either here or over on LAVA. It is pretty easy to do with VIs in the OpenG toolkit without resorting to your own scripting.
05-19-2012 02:06 PM
Thank you for your post. It really makes my life much easier. I will make some tests and write back the results!
05-20-2012 03:49 AM
Hello,
I made some tests, here are my results:
I have a Typedef.ctl referred in many VIs. Let's tha caller name is "Caller.vi" Here is my Save BD:
So, When the Caller.vi has opened Front panel, the save method do what I really want. Rename the Typedef.ctl to new name and the Caller is updated with the renamed Typedef.ctl.
Anyway, When The Caller.vi is not opened, ( not in memory ) the result is different. New Typedef.ctl is created but the caller has not been updated with the new name.
So my conclusion is the following:
If I want to achive my goals ( described in the first post) I have to start the rename procedure with the bottom of the hierarchy ( as you said ) but the caller must be in memory in order to relink its dependecies to the new name.
Please correct me if I am wrong!
So, considering this circumstances I think the scriping solution could be better, than to write a in-order tree traversal algorithm along the call chain, load parent VI into memory, and rename its childer VIs.
Any opinion?
05-20-2012 04:16 AM
That is exactly how LabVIEW has worked since the beginning. VIs (and CTLs) are linked together at load time based on their name (and path) and if you rename a VI in memory all it's callers in memory are updated to reference that new VI. And if you save them they will refer to this new VI or CTL from thereon.
05-20-2012 04:50 AM
05-20-2012 04:53 AM
Dear Albert.Geven,
Thank you for your reply. All comments are welcomed!
05-20-2012 04:55 AM
I have found this link: https://decibel.ni.com/content/message/18955#18955
Antoine Châlons first post seems very interesting,
05-20-2012 12:04 PM
Yes, the upper level VIs need to be in memory for this to work. I always started with the Top Level VI open, got a reference to it, then iterated down it's callees for "level 2", then got their callees for "level 3" and so on down the the very bottom, then worked back up.
I should have stated the requirement to be in memory, but I thought that was obvious, sorry. This technique has been around long before scripting and LabVIEW projects, at least 10 or 15 years.
Good luck on your project.