bessire Posted June 30 Report Posted June 30 Is there any way to create a strictly typed VI refnum to some regular labview code without having that code saved as it's own file? I'm okay with even the hackiest solutions/ideas that are not likely to break with every new release. Ideally, I'd be using this in an XNode to have a resizable structure, define the code in the lambda, and capture variables as well. One thing I thought about is getting LabVIEW to compile a temporary VI at edit time, storing the compiled code in a buffer on the block diagram, and finding some method to load VI's from memory if one exists. That way it can be used in an executable. Unfortunately, I don't know of any such methods. For context, I am trying to create anonymous functions in LabVIEW to facilitate some basic functional programming concepts. I already have malleable VIs made using Call By Reference for things like map, filter, and reduce that accept a strict VI ref and an iterable (map, array, set, etc.). I also have a quick drop plugin that automates stuffing code selected from a block diagram into a new, automatically generated VI with an obfuscated name, replacing the code on the original block diagram with a strict SVR to the new VI, and saving the new VI in a top level virtual folder called "lambdas" out of the way. My current goal is to eliminate the need to have the VI saved on disk and still be able to build executables and define the referenced code on the block diagram of the VI that will use it. I recently learned about XNodes and thought I could make a working version of the closure structure with them, but they appear to be just like vim's with VI scripting. Ultimately, they seem no better than my quick drop plugin for this. Quote
Rolf Kalbermatter Posted July 2 Report Posted July 2 (edited) On 7/1/2025 at 1:43 AM, bessire said: One thing I thought about is getting LabVIEW to compile a temporary VI at edit time, storing the compiled code in a buffer on the block diagram, and finding some method to load VI's from memory if one exists. That way it can be used in an executable. Unfortunately, I don't know of any such methods. I'm pretty sure that exists, at least the loading of a VI from a memory buffer, if my memory doesn't completely fail me. How to build a VI (or control) into a memory buffer might be more tricky. Most likely the VI server methods for that would be hidden behind one of the SuperSecretPrivateSpecialStuff ini tokens. Edit: It appears it's just the opposite of what I thought. There is a Private VI method Save:To Buffer that seems to write the binary data into a string buffer. But I wasn't able to find any method that could turn that back into a VI reference. Edited July 2 by Rolf Kalbermatter Quote
bessire Posted 14 hours ago Author Report Posted 14 hours ago I did see that "Save:To Buffer" method. I also haven't seen a method for loading the output of that. All of the VI server methods I've seen so far have required a file path. I have only briefly looked at the ones visible on an invoke node with a lot of extra ini tokens, so there are probably some deprecated or hidden ones to go through still. I looked through all of the Call Library Function Nodes in code shipping with LabVIEW 2025 and a few extra modules, but nothing seemed promising. The Application Builder code has some interesting calls but I think they only work with a built application, which I haven't tried. There are some other methods in various DLLs that do seem promising such as "NormalVILoadProc", "NormalVIInitProc", and "NormalVIDisposeProc", I just don't know how to call them yet. I'll take a look at all of the property and invoke nodes next, but I doubt there's anything exposed there that doesn't involve passing in a file path. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.