LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible For loop bug (LV2016)

Solved!
Go to solution

@Frozen wrote:

 

Now that I know of this feature, I will have to think about ways to use it, and guard against it, in the future.


A better idea would be to leverage it to your advantage. 😄

 

You might have to ask yourself why the incoming empty array has some dimensions that have nonzero size. Maybe there is problematic code upstream (e.g. that weird "build array" of height=1 in your original example) that can easily be fixed instead of having to carry that thing around just to work around the problem with a band-aid solution far downstream.

0 Kudos
Message 21 of 25
(610 Views)

Yes,  I will be looking for ways to use it Smiley Happy (and make sure to put comments about expected behavior so someone doesn't "fix" it. Smiley Surprised )

 

If it was just my code, "fixing" the up-stream code would be an option. Unfortunately,  I am not the only developer in my company.

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 22 of 25
(602 Views)

What's the problem with notifying the "upstream" devs of bugs in their software?  Easy!  Doing it without hurting their feelings?  Difficult!  😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 23 of 25
(595 Views)

Well, the problem is it is not a "bug" to have an empty, non-zero array. Smiley Surprised

Good programming practice is to check your inputs. As rolfk rightly pointed out, if the code will "break" when the for-loop executes on an empty array, then you need to protect against it. Awareness is the key.

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 24 of 25
(592 Views)

@Frozen wrote:

Well, the problem is it is not a "bug" to have an empty, non-zero array. Smiley Surprised

Good programming practice is to check your inputs. As rolfk rightly pointed out, if the code will "break" when the for-loop executes on an empty array, then you need to protect against it. Awareness is the key.


That's defensive programming. Design by contract is also valid and basically means "don't give me bad inputs".

0 Kudos
Message 25 of 25
(569 Views)