LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access name of case from indicator inside case using VI Scripting

Solved!
Go to solution

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.

 

 

0 Kudos
Message 1 of 14
(3,871 Views)

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.

Message 2 of 14
(3,865 Views)

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?

 

Untitled.png

0 Kudos
Message 3 of 14
(3,861 Views)

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.

 

FindCase.png

Message 4 of 14
(3,853 Views)

You mean like this? This still errors.

 

Untitled.png

0 Kudos
Message 5 of 14
(3,846 Views)

Don't close your SubVI reference so soon.

Message 6 of 14
(3,839 Views)

Ok yeah. Removed that. Still errors though.

0 Kudos
Message 7 of 14
(3,837 Views)

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

Message 8 of 14
(3,831 Views)

I actually fixed that I just haven't uploaded a new picture.

 

Untitled.png

0 Kudos
Message 9 of 14
(3,827 Views)
Yup. Use the owner reference.
Message 10 of 14
(3,826 Views)