LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

select only even

Well, I just simplified your code without changing the functionality because I thought that what you wanted.
 
For better functionality, you need to increment the found position, not the old search position, of course. 😉
 



Message Edited by altenbach on 05-06-2008 07:11 PM
Download All
Message 11 of 47
(1,784 Views)

Hi krispiekr…,

here is another solution to create the example array. Smiley Happy

Mike



Message Edited by MikeS81 on 05-07-2008 08:24 AM
Message 12 of 47
(1,769 Views)

Ray,

I am curious about one of your comments, as I have seen several similar inferences in the past.  What is it that so many developers have against stacked sequence structures?  It seems to me that when you have a section of code that would fill the screen 3 times over, it makes more sense to create a stacked sequence than to make up a couple of artificial states that always operate sequentially.  Is there something that I don't understand about how LabVIEW operates that makes this not true?  I've been using LV for several years and can do alot with it, but I still have alot to learn about HOW it works.

Jim

LV 2020
0 Kudos
Message 13 of 47
(1,747 Views)
It's a style choice.  In a stacked sequence, there is always code that you cannot see, and wires coming from the left and the right, and leaving to the left and the right.  It's generally confusing to anyone else using your code.  Also, if your code would fill the screen three times over (again, code you can't see, so it's hard to get a quick understanding of it) you should probably be using SubVIs to contain it.
 
edit - To replace the stacked sequence, you could even make each state a SubVI and then place them in order in a new SubVI for a much more clear, more readable block diagram.


Message Edited by JeffOverton on 05-07-2008 08:43 AM
Message 14 of 47
(1,737 Views)

Jeff has good comments.

But whenever people use a stacked sequence structure they tend to add to them.

I have fix bugs one time too many where they hise a bloody stack sequence in a Case structure only to find out that the upper stack sequence has 55 frames, and within each frame there are stack sequences of up to 15 to 25 frames, and to top it all, they have within some of the stack sequence frames a third layer of up to 10 frames.

Ever debug such a mess?

If you design your code well, it should not go much beyond one single screen. 

Some architect System Integrators (companies) have templates that limit the size of a given VI.  They also forbit S-S-Structures & Locals.  I agree with them.  They must have had some similarly bad experience.

As with anything in life, it may be ok as long as it is not abused.  But I can't say anything positive about Stacked Sequences.  😞

Oh..  And using a Local Variable to pass data from one spot to another when they are next to one another is just not right!  They are abused way too often. 

Keep it simple, keep it clean and comment the code.  And read the Rube Goldberg thread: http://forums.ni.com/ni/board/message?board.id=BreakPoint&thread.id=2634

 

Message 15 of 47
(1,729 Views)


lmtis wrote:

What is it that so many developers have against stacked sequence structures?  It seems to me that when you have a section of code that would fill the screen 3 times over, it makes more sense to create a stacked sequence than to make up a couple of artificial states that always operate sequentially. 


Jim
 
Maybe 10 years ago in the time ot 640x480 screens there was some validity to your point and a lot of the very old examples from the example finder use stacked sequences, maybe for that reason. Unfortunately, it would be a massive task to freshen all old examples.
 
Times have changed. As other have already mentioned, stacked sequences are evil!
  1. They hide code such that is is impossible to see what a program does without flipping through endless frames keeping track of which sequence local contains what data.
  2. The very nature of sequence locals forces wires that flow from right to left.
  3. Sequences trap code. Even if the first frame contains an error, all subsequent frames are forced to execute. There is no escape.
  4. They break dataflow and thus often prevent compiler optimizations for multiple CPU cores. They force sequential execution of things that could execute in parallel.
  5. The use of stacked sequences is the result of rigid linear thinking.
  6. Sequences cause tunnel vision and prevent a view of the big picture.

There are plenty of alternatives, such as state machines and subVIs. Always think outside the sequence frame box! 😄

Here are two examples of functionally the same code. Which one is easier to debug? Which one has a higher potential of accidental wiring errors?

         

(See also: http://forums.ni.com/ni/board/message?board.id=170&view=by_date_ascending&message.id=230714)

Message 16 of 47
(1,718 Views)
Another reason that a lot of old code uses sequence frames is that in the past error clusters were not the "conventional" way to program VIs. Many of the VIs that shipped with LabVIEW (and still do), don't have error clusters. Thus, in the case where you had to enforce a specific sequence, the sequence structure was the only way to do it.
Message 17 of 47
(1,713 Views)
altenbach, i got a chance to look at your code today.
you just increment by one right?

for instant, when i am at current position  at the beginning. it is always 0.
i click on advance..
the next element that is true would be element 1?
your program goes from 0, 2, 4, 6, 8
but the positions are 1,3,5,7,9
thats where i was stuck at. i incremented by 1 at first too. knowing that thats not what i wanted..
also, ModulePosition is not always 1,3,5,7,9
it can be 1,2,3,6,7,9,10

modulepositions = devices on a board

i want to click adv to go to the next position where there is a device for instants.



Message Edited by krispiekream on 05-07-2008 10:40 AM
Best regards,
Krispiekream
0 Kudos
Message 18 of 47
(2,212 Views)
Why don't you detect the devices, and put the locations in an array?  So element zero of the array would be the first device location, element 1 would be the second device location, etc


Message Edited by JeffOverton on 05-07-2008 11:33 AM
Message 19 of 47
(2,210 Views)
yeah. i am modifiying a program have are filled with sequences and stacked quences with 10 frames or so.
its hard for me to clean it up because i am still learning labview and i all these stacked sequences i look at everyday got me used to the style.

Best regards,
Krispiekream
0 Kudos
Message 20 of 47
(2,206 Views)