01-18-2024 02:16 AM
Hi,
i have a formula node and if the condition is met, individual elements should be written to an array. Is a for loop and a shift register needed for this? My problem is that the array size has to be adjusted again and again when the condition of the formula node is met.
Best regards,
Tim
01-18-2024 02:44 AM - edited 01-18-2024 02:46 AM
Hallo Tim,
@Tim970 wrote:
i have a formula node and if the condition is met, individual elements should be written to an array.
Why do you need a formula node for such simple code?
Do you want to append elements to an array or overwrite existing elements? The term "written to an array" is ambiguous…
@Tim970 wrote:
Is a for loop and a shift register needed for this?
A shift register, hold on a loop border, would be fine. You can also use while loops instead of FOR loops…
@Tim970 wrote:
My problem is that the array size has to be adjusted again and again when the condition of the formula node is met.
Array sizes are handled by LabVIEW automatically, you don't need to worry about this.
(As long as you use G code and don't rely on C code inside a formula node…)
01-18-2024 03:14 AM
Hi GerdW,
i want to append elements to an array. Can you show me how the while loop with the shift register will look like?
Best regards.
Tim
01-18-2024 04:02 AM - edited 01-18-2024 04:06 AM
@Tim970 wrote:
Hi GerdW,
i want to append elements to an array. Can you show me how the while loop with the shift register will look like?
Best regards.
Tim
If you are not sure on the size of the array you can use Build array with shift register and append the values within the Loop.
01-18-2024 04:49 AM - edited 01-18-2024 04:49 AM
Hi Tim,
@Tim970 wrote:
Can you show me how the while loop with the shift register will look like?
Like this:
01-18-2024 05:03 AM - edited 01-18-2024 05:06 AM
Hello Tim,
please open the "Find Examples"- Window from the Help menu. In the Search- Tab (left side) type "shift-register" (or "Schieberegister") and Doubleclick on the appearing entry in the list below. Then have a look at the example. Do the same with "Build Array"
The "Find Examples" dialog is always a good starting point.
P.S. Execute the VI with the Light Bulb on an watch the block diagram. This will teach you the principles of LabVIEW- primitives.