Ir al contenido principal

Release current directory

This is not mine, it's a tip I found years ago in a LabVIEW forum and still works like a charm (thanks to the genious that got it!).

When the user selects a file to work with (signal data you want to analyze, for example) your LabVIEW application "grabs" its path, so you can't delete it or its directory, or unmount the unit if you're using an external drive, even if you are not reading that file anymore and you clear any path controls. But we can use Kernel32.dll method SetCurrentDirectoryA to release it (obviously, this only works in Windows systems).

No downloadable code today, it's better if you link the call library function node by yourself, so you're sure it finds the dll. You can find more info about this method here: SetCurrentDirectory function at MSDN.


Entradas populares de este blog

Required Outputs Wizard

It's an old LabVIEW programmer's dream to be able to make VI outputs required, just as can be done with inputs. Some years ago I discovered a way of achieving it, through a deprecated scripting method. I checked with NI staff and they said it was clever but could cause unexpected problems, so I set it aside.But the time goes by and the functionality is still not available, so here we go, the Required Outputs Wizard is yours. I've been using it on and off for a long time and no errors have arisen, even when applying it to connectors with modern data types, such as classes (OOP). But I guess the risk is still there, so be cautious and test it first with unimportant VIs.Download (LLB for LabVIEW 2016)The bowels of the codeSo, how it works? Launch the top VI in the LLB, you can leave it there running. When a connected front panel indicator is selected, the "REQUIRED" button will be available. Just press it. Yeah, that's all, now your indicator connection is requi…

CIDR to netmask

To begin with, something basic but useful, a LabVIEW VI for converting CIDR suffix to a standard IP mask. As you know, in CIDR format the number after the IP indicates the bits that address uses. If you need to convert to a traditional subnet mask, this VI comes handy.So, a CIDR of 24 will return a mask, 28 is, etc. Pretty simple, but a lot of applications demand netmasks in this format.Download (VI for LabVIEW 2016)LabVIEW still only supports IPv4, so I haven't delved into the complexities of IPv6 (we'd need a U128 data type for that).

Variant to XML

Converting to XML format is a good way of exporting data in a standard, human-readable way. I have used it to pass and receive data from other languages, for example, or if you need to dump data to a log file.As you may know, LabVIEW includes its own functions for converting to and from XML, called Flatten To XML and Unflatten From XML. Unfortunately, it's a raw conversion that just gives a node with the data type and two child nodes, name and value. So, to find a field you must recover first all the name nodes, locate the one you need and then find its value sibling. Too crude for a lot of scenarios:So I developed my own library to do this conversion in a more convenient way. Check the differences in the next image:As you can see the field names are now used as tag names, resulting in a shorter and cleaner XML text. The reverse conversion (from XML to LabVIEW data) is shown in the bottom of the image, and works the same.In the block diagram, these functions are used directly, jus…