LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For Loop conundrum

Solved!
Go to solution

Hi, I have a for loop that refuses to execute. Please see below. I have NO CLUE why this is happening, no errors are being produced or anything. Am I drunk!

 

Please help!

 

Many thanks, Alec

 

WTF.png

0 Kudos
Message 1 of 16
(3,435 Views)

How long is your array of Mark? I suspect shorter than 86. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 16
(3,431 Views)

Not is it only less than 86 it is probably empty

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 16
(3,420 Views)

BTW the for loop will only execute n times when n is the less than or equal to the largest autoindexed input into the for loop.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 4 of 16
(3,419 Views)

There is really nothing at all correct about that VI. Wiring to the count terminal and autoindexing, using locals, using the replace array subset.

0 Kudos
Message 5 of 16
(3,411 Views)

Indee. You either auto-index a loop or you wire to the N terminal. You do not do both.Alec, you should review the concepts of loops in the LabVIEW Help. Have you taken the tutorials?

 

Your program screams text-based programming. LabVIEW is not a text-based programming language, so don't try to write a program that way. Those local variables should be replaced with a shift register or feedback node, depending on your version of LabVIEW.

 

To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 6 of 16
(3,402 Views)

Looks like you want to replace the first 86 elements of one array with some elements in another array.  You don't need a For Loop to do this.  Replace Array Subset will take in arrays.  The following code example replaces the elements of DirtyFlag starting at zero for the length of the Mark array.

 

Example_VI.png

- tbob

Inventor of the WORM Global
Message 7 of 16
(3,374 Views)
Solution
Accepted by topic author alecjcook

Tbob,

 

I think what problem with your solution is that it limits it to a single series of elements at the beginning of the array.  To go to mulitple elements that are disconnected and do not start a element 0 will mean more complicated programming.

 

I'm not so sure the OP's original screenshot truly reflects all he wants to do.  But if you have an 86 element array of booleans where some are true and others are false, and you have an 86 element array of booleans where some are true and are being used to change some elements in the first array to True, then the simplest thing to do would be to OR the two arrays.  Anything that was True stays True.  Anything that was False will turn to True if the corresponding element is True in the 2nd array.

0 Kudos
Message 8 of 16
(3,358 Views)

@Ravens Fan wrote:

Tbob,

 

I think what problem with your solution is that it limits it to a single series of elements at the beginning of the array...


 

Raven:  You are second guessing the OP's problem.  Maybe his code is exactly what he is trying to do.

 

According to the OP's original post, he wants to replace array elements starting at 0.  He is replacing a single series of elements starting at the beginning of the array.  Look at his code.  My code is a reflection of what he wrote, only in a more elegant way.  I am not trying to second guess what he is wanting to do.  My code does exactly what his is intended to do.  If his screenshot is not a reflection of what he wants to do, then he needs to do a better job of explaining his dilema.  I answered his question, not what I thought his question should be.

- tbob

Inventor of the WORM Global
Message 9 of 16
(3,350 Views)

@tbob wrote:

@Ravens Fan wrote:

Tbob,

 

I think what problem with your solution is that it limits it to a single series of elements at the beginning of the array...


 

 

Raven:  You are second guessing the OP's problem.  Maybe his code is exactly what he is trying to do.

 

According to the OP's original post, he wants to replace array elements starting at 0.  He is replacing a single series of elements starting at the beginning of the array.  Look at his code.  My code is a reflection of what he wrote, only in a more elegant way.  I am not trying to second guess what he is wanting to do.  My code does exactly what his is intended to do.  If his screenshot is not a reflection of what he wants to do, then he needs to do a better job of explaining his dilema.  I answered his question, not what I thought his question should be.


The dangling participal (the unwired control) COULD imply other than starting at index "0".

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 16
(3,346 Views)