05-26-2024 03:01 AM
@altenbach wrote:
@billko wrote:
This will bite you if you have a FOR loop iterating through an array of test data and for some reason that array is empty going into the FOR loop. The array of Booleans representing P/F status will be empty, resulting in a false PASS. So make sure to handle that possibility.Why would that be a false PASS?
Is TRUE Pass or Fail?
Conventionally, Fail=TRUE and you would use OR array elements to see if there is at least one failure. An empty array would PASS.
OTOH, if you define Pass=TRUE, you would use AND array elements to see if there is at least one failure. An empty array would PASS.
An empty array means that no failures exist and no corrective action is needed. If you want to fail if there are no results, both scenarios need a touchup as discussed elsewhere. I have the feeling that empty results should probably be caught upstream already..
Here's is equivalent code for both:
Yes, it could be handled upstream. Or it could be handled right here, too. If the empty array of data was because of instrument error, then of course error trapping is an appropriate way to handle this, but sometimes it's a UUT problem and it gets handled here.
My comments were addressed to rookie and/or hack LV programmers who don't realize things like what happens to a FOR loop autoindexing on an empty array.