To download NI software, including the products shown below, visit ni.com/downloads.
Insertion sort and use of pointers for memory addressing with LabVIEW
This demo application shows the use of the LabVIEW dll library functions for creating pointers and memory addressing by implementing the insertion sort algorithm. Primitive VIs to memory allocation and deallocation as well as for reading and storing data have been implemented. Malleable VIs are also used to allow the use with different data type without changing in code.
Prepended data size provides high flexibility simplifying the use of primitives, especially with unbounded data types, at the expense of the overhead of 4 prepending bytes for the length.
Description-Separate-2
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
LabVIEW is a graphical programming language, so it doesn’t natively support pointers like C or C++. But by using DLLs and some special functions from the LabVIEW Memory Manager library, you can simulate pointer-like behavior
LabVIEW doesn’t have direct pointer syntax, but you can use the Call Library Function Node to interface with external DLLs that do.
Functions like DSNewPtr let you allocate memory and get a pointer to it.
You can use MoveBlock to read from or write to a specific memory address.
Insertion sort is a simple sorting algorithm where elements are inserted one by one into the correct position within a growing sorted portion of the array.
Nice!