12-21-2010 08:37 AM
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
Solved! Go to Solution.
12-21-2010 08:43 AM
How long is your array of Mark? I suspect shorter than 86. 🙂
/Y
12-21-2010 08:58 AM
Not is it only less than 86 it is probably empty
12-21-2010 08:59 AM
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.
12-21-2010 09:10 AM
There is really nothing at all correct about that VI. Wiring to the count terminal and autoindexing, using locals, using the replace array subset.
12-21-2010 09:24 AM
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.
12-21-2010 10:25 AM
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.
12-21-2010 10:55 AM
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.
12-21-2010 11:28 AM
@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.
12-21-2010 11:32 AM
@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