LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting Help - Library locked when trying to add file to it

Solved!
Go to solution

Hi there,

 

I'm just making a simple script I can run with my action engines, so if I add new enum values I can create new wrappers quickly. I'm able to create a new VI on disk, but when I try to add the the VI to the library, I get "Error 1562: The specified project or library is locked." Just before adding the item, I tried setting the library state to "Not Locked", but that didn't do the trick.

 

Directions to see error: 

Open attached zip file

Open "Action Engine.lvlib"

Run "Script - Create Wrapper.vi"

 

Please let me know how to get around this, thank you,

Gregory

0 Kudos
Message 1 of 14
(4,561 Views)

I don't know about you but when I run it the Owned Items that are returned from the library is empty, so the search 1D array returns -1, and it tries performing operations on a Not a Refnum.

0 Kudos
Message 2 of 14
(4,556 Views)

Interesting... I'm running with LV 2012 and the OwnedItems has the 2 virtual folders in it. The For Loop runs twice and the array of Names has the two virtual folder names in it.

0 Kudos
Message 3 of 14
(4,551 Views)

Oh...that's because the save function generated an error for me, which fed into a property node that didn't return the library.  This error didn't get propigated because the for loop for me runs 0 times, so the error coming out of the for loop is cleared.  You should use a shift register on the errors for the for loop, or index and merge errors. BTW the error the save returned for me was error 1357.  This is cause I was running it with the enum on init sorry.

 

Spoiler
A LabVIEW file from that path already exists in memory, or exists within a project library already in memory.

 

0 Kudos
Message 4 of 14
(4,543 Views)

Oh I see, thank you I've taken your instruction. I should have included the enum value in the directions.

0 Kudos
Message 5 of 14
(4,537 Views)

By the way I just remembered I already created this function for creating wrappers.  I originally posted it on our user group discussion here.

 

https://decibel.ni.com/content/thread/32307?tstart=0

 

This then went into LAVA where development continued, and eventually was able to make a polymorphic VI, that containsed each of the VIG states, and even deleted the controls not used in that state from the front panel, and created a new library setting the VIG to private.

 

https://lavag.org/topic/19114-create-fgv-wrappers/

 

The original code posted on the user group worked on your VIG, the newer one on LAVA died with errors from something.  It made the files but had issues.

 

The code isn't perfect but could be used as a starting point if you can't figure out why your code does weird things (I couldn't)

 

EDIT:  It seems the reason the code died is because a case didn't exist for every unique value of the enum.

Message 6 of 14
(4,531 Views)

Thanks for sharing that code! I was also looking at ways to customize the icon, they don't seem to make it easy... The DQMH does a great job with them though.

 

 

Message 7 of 14
(4,517 Views)
Solution
Accepted by topic author Gregory

There is at least two reasons a library locks:  1) something it owns is running, 2) it is open in two or more application instances.  (This goes for classes too.)

 

I started a project and took your scripts out of the library (to avoid #1) and then opened your library's reference by path in your script, making sure to include the application reference (to avoid #2).

 

Works now.  (Except for the Init.vi but you stated earlier that you knew about that. But Item 1 and Item 2 work fine.)

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



Message 8 of 14
(4,469 Views)

Hi TheQ, I am using LV 2012, so I could not view your attachment. Can you explain how to open a library reference by path?

0 Kudos
Message 9 of 14
(4,435 Views)

Yes, I will post the code saved to LV2012 later, its not here with me.

 

However, to open a Library reference by path:

1. Drop an invoke node

2. Write a application reference into it (not usually necessary but when trying to avoid case #2 as I mentioned earlier)

3. In the invoke node, click and select Library --> Open

4. Wire as input the path to your Library, the output will be the reference to your library. 

 

Because the Script VI was saved in the same folder as the library, I created the path by getting the Script VI's Path, stripping the VI filename off  and building the library's filename onto the path.

 

The only other edits I made was to make sure the same application instance was wired to New VI Scripting Function and to move all the script files out of your library.

 

Again, I'll repost the code when I can.  Hope this helps.

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



Message 10 of 14
(4,428 Views)