BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Which errors?   The queue is obviously there to make sure that the bottom loop executes exactly just as often as the top loop!    As such, there's no need to actually put any data into the queue, or read it.  Smiley Very Happy

(glad you didn't put my reply to this thing here as well...    Smiley Wink )

0 Kudos
Message 191 of 2,635
(12,499 Views)


JoeLabView wrote:
Can you find at least 8 errors in my previous post? Apart from the title...

There are no errors, because the VI is presumably runnable. Maybe you are looking for mistakes?
 
Is that eight in addition to the things I pointed out in the original thread?
 
Here are a few more:
  • queue wire in shift register.
  • ToDBL does not add anything useful, except the memory footprint.
  • ...

0 Kudos
Message 192 of 2,635
(12,481 Views)

my bad..

.. at least 8 mistakes..     { including bad practices }

counting the ones you mentionned 😉



Message Edited by JoeLabView on 04-14-2008 12:15 PM
Message 193 of 2,635
(12,466 Views)


altenbach wrote:

Here are a few more:
  • queue wire in shift register.

Actually, wiring a queue reference to a shift register is sanctioned by NI as a good thing.  I took an intermediate class once, and the instructor told us to make it a habit to do this.  His reasoning was that a For Loop can execute 0 times.  If such happens and the queue reference was not wired to a shift register, the output on the queue ref wire would be NULL, causing errors on down the line.  If wired to a shift register and the For Loop ran 0 times, the output would be a valid reference because the shift register was initialized.  Of course this doesn't apply to While Loops which always execute at least once.  The instructor said it was just good practice to get into the habit of doing this always.  I've been doing so ever since.
- tbob

Inventor of the WORM Global
0 Kudos
Message 194 of 2,635
(12,466 Views)

Salut l'cousin (p'ti-bob),

Yes... I heard that as well..  However, as you mentionned, when using a while loop, it does at least one iteration, so the queue reference makes it through.  I don't know how "bad" it is to use a shift register...  the reference doesn't change..   😮  Nevertheless, when using queues, I stick with While loops.  I can't recall using a For loop with queues or notifiers..
 
As for a good habit.. I'm sure that's questionable 😉
 
Take care buddy..  🙂
 
 
0 Kudos
Message 195 of 2,635
(12,465 Views)

Hi,

There was a problem with one of the LabVIEW versions (maybe 6.0) where a reference passing throughs through a loop was getting changed, corrupted or lost ( cant remember the exact problem). Anyway, the solution was to pass it via the shift register. Therefore I tend to use shift registers regardless.Smiley Sad

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 196 of 2,635
(12,455 Views)
Some months ago I encountered this problem (for loop with 0 iteration) while working with configuration files. I first wired a code like below to read all the keys of a section. You can easily imagine what happened with an empty section...






Message Edité par JB le 04-15-2008 08:34 AM
0 Kudos
Message 197 of 2,635
(12,452 Views)

You could always put a Case Statement (around the For Loop) to handle an empty array  😉

But you'd still get an empty array for Keys... which wouldn't change much... 😞

I'm off cafeine... so the brain is now processing at half speed.



Message Edited by JoeLabView on 04-15-2008 08:28 AM
0 Kudos
Message 198 of 2,635
(12,422 Views)

Funny how this comes up...  

Today, I encountered the situation that JB dscribes...        Putting the reference into a shift register would have involved major rewiring, and far less easy to read code.    So, I indeed choose the second option, where I put a case statement around it.    (Actually, before the sub-VI got called).

In my case, it also made more sense to warn the user that he forgot to specify something, then to simply do nothing.   



Message Edited by Anthony de Vries on 04-15-2008 02:37 PM
Message 199 of 2,635
(12,415 Views)
There's this way of getting the remainder:



and then there the old-fashioned way of just using the "R" output of the function that's right there.
Message 200 of 2,635
(12,381 Views)