LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO FIX THIS CODE LABVIEW


@abimkeren. wrote:

abimkeren_0-1716218489970.png

 

 


you mant to OR a boolean scalar with an input array of booleans, which is resultiung in an output array of booleans, but the stopp-while-loop terminal only accepts scalars.

e.g.

 

   
alexderjuengere_0-1716475638766.png alexderjuengere_0-1716475869304.png

 

i haven't tested in detail, but it looks like "merge errors" is in this context equivalent to "and array elements", using two errors

 

f and f = true

f and t = false

t and f = false

t and t = true

 

 

0 Kudos
Message 11 of 21
(371 Views)

@alexderjuengere wrote:

i haven't tested in detail, but it looks like "merge errors" is in this context equivalent to "and array elements", using two errors

 

f and f = true

f and t = false

t and f = false

t and t = true

 

 


Sorry, could you explain this more? Merge Errors acts like an Or, not an And.

 

Two error constants with "status" set to False run through a Merge Errors gives False.

Either one, or both, with "status" set to True will return True.

Message 12 of 21
(357 Views)

@BertMcMahan wrote:
Sorry, could you explain this more? Merge Errors acts like an Or, not an And.

 

Two error constants with "status" set to False run through a Merge Errors gives False.

Either one, or both, with "status" set to True will return True.


As explained in the help, it checks the error in order and finds the first one and that will be reported in the other fields of the output cluster (error number, description, etc.)

 

QUOTE: "By default, this function looks for errors beginning with the error in 0 parameter and reports the first error found. If the function finds no errors, it looks for warnings and returns the first warning found. If the function finds no warnings, it returns no error. Use exception control to treat what is normally an error as no error or to treat a warning as an error."

0 Kudos
Message 13 of 21
(319 Views)

@niravdesai wrote:

Use unbundle by name and use error status of each error and do logical OR of each error status then stop if true condition works ok and broken error will be removed 


Don't overcomplicate things. Nobody needs to unbundle anymore. (Decades ago was different)

Nowadays, Boolean operations and conditional loop terminals accept error clusters directly. Mix & Match!

 

These examples all work as expected:

 

altenbach_1-1716564081426.png

 

 

0 Kudos
Message 14 of 21
(316 Views)

@altenbach wrote:

@BertMcMahan wrote:
Sorry, could you explain this more? Merge Errors acts like an Or, not an And.

 

Two error constants with "status" set to False run through a Merge Errors gives False.

Either one, or both, with "status" set to True will return True.


As explained in the help, it checks the error in order and finds the first one and that will be reported in the other fields of the output cluster (error number, description, etc.)

 

QUOTE: "By default, this function looks for errors beginning with the error in 0 parameter and reports the first error found. If the function finds no errors, it looks for warnings and returns the first warning found. If the function finds no warnings, it returns no error. Use exception control to treat what is normally an error as no error or to treat a warning as an error."


I understand, I was referring to @alexderjuengere's comment that it acted like an And, with F and F returning True. That made no sense to me so I was trying to understand what he was talking about. In the context of this application, Merge Errors acts as an Or.

 

(Specifically referring to whether or not the Stop terminal would trigger. Obviously Or'ing the array would strip out all warnings, error codes, etc.)

 

Also, we have the option now to keep *all* of the errors with a right-click selection to "Retain All Errors" since about 2021 or so. I haven't played with it much but it seems promising. This too doesn't make a bit of difference to the OP's question, so I digress.

0 Kudos
Message 15 of 21
(311 Views)

@BertMcMahan wrote:
Merge Errors acts as an Or.

 

Yes, if we only focus on the booleans, as e.g. the only way the stop terminal understands.

 

As a quick exotic diversion for the weekend, let's remember that  "AND array elements" of an empty boolean array is TRUE. Intuitive once you think a bit... 😄

 

altenbach_0-1716572597600.png

 

0 Kudos
Message 16 of 21
(291 Views)

@altenbach wrote:

@BertMcMahan wrote:
Merge Errors acts as an Or.

 

Yes, if we only focus on the booleans, as e.g. the only way the stop terminal understands.

 

As a quick exotic diversion for the weekend, let's remember that  "AND array elements" of an empty boolean array is TRUE. Intuitive once you think a bit... 😄

 

altenbach_0-1716572597600.png

 


An excellent post by Kevin Price describing why this is the case:

 

https://forums.ni.com/t5/LabVIEW/Anding-of-Empty-Boolean-Array-Results-in-True/m-p/3337867/highlight...

0 Kudos
Message 17 of 21
(276 Views)

@altenbach wrote:

@BertMcMahan wrote:
Merge Errors acts as an Or.

 

Yes, if we only focus on the booleans, as e.g. the only way the stop terminal understands.

 

As a quick exotic diversion for the weekend, let's remember that  "AND array elements" of an empty boolean array is TRUE. Intuitive once you think a bit... 😄

 

altenbach_0-1716572597600.png

 


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.

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 18 of 21
(263 Views)

@alexderjuengere wrote:

@abimkeren. wrote:

abimkeren_0-1716218489970.png

 

 


you mant to OR a boolean scalar with an input array of booleans, which is resultiung in an output array of booleans, but the stopp-while-loop terminal only accepts scalars.

e.g.

 

   
alexderjuengere_0-1716475638766.png alexderjuengere_0-1716475869304.png

 

i haven't tested in detail, but it looks like "merge errors" is in this context equivalent to "and array elements", using two errors

 

f and f = true

f and t = false

t and f = false

t and t = true


That logic table looks like an EXOR NOT! That is even another thing than OR or AND. And the merge error definitely works as OR. It returns the first error in the list that is TRUE or no error if none is TRUE.

Rolf Kalbermatter
My Blog
0 Kudos
Message 19 of 21
(233 Views)

@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:

 

altenbach_0-1716648500767.png

 

0 Kudos
Message 20 of 21
(217 Views)