Jump to content

Get Access Scope


Recommended Posts

I need to get the access scope of a VI programmatically - I'm creating a tool to produce documentation for my classes and I want to know whether or not a VI is public or private. If it's private, then I don't need to add it to the documentation since the developer will never use it directly (If someone already has a tool to do this sort of thing, I'd love to see it!) I searched the forum and found this thread

http://lavag.org/top...__fromsearch__1

where AQ says

"Asking a VI "are you a private VI" is easy enough -- use the VI ref to get the lib item ref and then ask for scope, which will take care of checking virtual folder settings. "

Except that the Get Source Scope method also wants a source ref (type is ProjectItem). How do I get this ref? Do I need to open a project and find this particular item? Or is it exposed somewhere else?

Thanks,

Mark

I'm using LV 8.6.1

Link to comment

The children of a LVClass library are Project Items.

Sorry I don't have 8.6 available at the moment. Here's a screenshot (LV2009 snippet).

post-10515-125735572414_thumb.png

I was being lousy... there's another computer right next to me with LV 8.6... :shifty:

AccessScope_LV86.vi

Thank you ... LAVA to the rescue! This will let me do what I need. I'm still interested to know if could get the access scope directly from a VI ref to a class member.

Mark

Link to comment

Hi Mark,

You can do it even if the class is not loaded. If your VI is not part of a library (lvclass, lvlib, xcontrol, ...) then it's scope will be "invalid". Otherwise, it's about the same thing except you start from the VI reference and check it's owning library reference. If it exists, then it's part of a library for which you can find a match by using the ProjectItem's VI reference. The VI reference is not always valid (because all library members are not automatically VIs) but if you can sort out the errors and invalid references, then you can match the correct ProjectItem with it's associated VI reference.

Note that this works for any libraries, not just lvclasses. If your VI is a private member of a lvlib, then it's gonna return the correct access scope too.

AccessScopeFromVI.vi

post-10515-125738399588_thumb.png

  • Like 1
Link to comment

Hi Mark,

You can do it even if the class is not loaded. If your VI is not part of a library (lvclass, lvlib, xcontrol, ...) then it's scope will be "invalid". Otherwise, it's about the same thing except you start from the VI reference and check it's owning library reference. If it exists, then it's part of a library for which you can find a match by using the ProjectItem's VI reference. The VI reference is not always valid (because all library members are not automatically VIs) but if you can sort out the errors and invalid references, then you can match the correct ProjectItem with it's associated VI reference.

Note that this works for any libraries, not just lvclasses. If your VI is a private member of a lvlib, then it's gonna return the correct access scope too.

AccessScopeFromVI.vi

post-10515-125738399588_thumb.png

Thanks once again. This does explain what is actually happening. The VI knows it's part of a library but it appears that only the library knows the VI's scope. I thought from that original snippet from AQ (from the linked thread) that the VI also would know and might be able to report its scope, but apparently my interpretation was incorrect.

Mark

Link to comment

Thanks once again. This does explain what is actually happening. The VI knows it's part of a library but it appears that only the library knows the VI's scope. I thought from that original snippet from AQ (from the linked thread) that the VI also would know and might be able to report its scope, but apparently my interpretation was incorrect.

Mark

Indeed. A VI by itself doesn't have a scope. You can disconnect a VI from its library and it's gonna be a plain ol' VI.

This can be useful to remember if you've got a corrupted library. It never happened to me in a lvclass, but it did (in 8.2 if I'm not mistaken) for lvlibs. I had to disconnect the VIs from their corrupted library, otherwise I couldn't access it. Deleting the library file is not enough because the VI knows it is linked to it.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.