02-26-2013 05:53 PM
Hello everyone. I have a script that finds all instances of a specific sub vi. All instances of this sub vi will be contained in a case structure. Using VI scripting, I want to be able to traverse backwards and determine the name of the case that the sub vi is in. Attached is an image of the code that I currently have, however it errors out in the part where I cast the reference to a case structure. Does anyone know what I am doing wrong? Thanks.
Solved! Go to Solution.
02-26-2013 06:32 PM
Here is what I would do in this situation:
For a given SubVI reference I would find the Owner Property and cast it to class 'Diagram'
If there is no error (ie. feed the error out of the To More Specific Class to a Case structure), then I would find the owner of the Diagram and Cast it to 'CaseStructure'
Again if there is no error then you know you have the reference for the Case Structure which holds your SubVI. Find the Frames property of the Case Structure.
Using Search 1D array, search the Frames array for the Diagram reference you found earlier, this will give you the Frame Index.
Using the index, index the FrameNames property to find the name of the frame.
02-26-2013 06:50 PM
I just tried out what you suggested however, it errors on the FrameNames method. Error 1055. Object Reference is invalid. Any clue what might wrong?
02-26-2013 07:23 PM - edited 02-26-2013 07:32 PM
The Owner of the Terminal should be cast to a Diagram, not the Terminal reference itself. Although I would probably use the SubVI reference instead of the Terminal reference.
Edit: Here is a quick example which finds a function buried inside a case structure.
02-26-2013 07:35 PM
You mean like this? This still errors.
02-26-2013 08:07 PM
Don't close your SubVI reference so soon.
02-26-2013 08:09 PM
Ok yeah. Removed that. Still errors though.
02-26-2013 08:18 PM
It looks like you are using the subVI reference rather than the owner reference as Darin did. You do not have anything wired to the owner output of the Property Node.
Lynn
02-26-2013 08:20 PM
I actually fixed that I just haven't uploaded a new picture.
02-26-2013 08:21 PM