<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://labviewwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wevanarsdale</id>
	<title>LabVIEW Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://labviewwiki.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wevanarsdale"/>
	<link rel="alternate" type="text/html" href="https://labviewwiki.org/wiki/Special:Contributions/Wevanarsdale"/>
	<updated>2026-05-09T12:01:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=4014</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=4014"/>
		<updated>2009-04-16T14:28:14Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster  ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order. Any cluster with this structure is treated as an error cluster in LabVIEW. The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control. &lt;br /&gt;
&lt;br /&gt;
[[Image:Error cluster control and terminal.JPG|frame|center|Figure 1:  3D error cluster control and terminal‎]] &lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in LabVIEW 8.2 ([http://www.ni.com/pdf/manuals/371780b.pdf upgrade notes] p. 35). The “status” is true if an error has occurred but remains false for warnings. The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range -8999 to -8000 (LabVIEW 8.2)&amp;amp;nbsp;and&amp;amp;nbsp;5000 to 9999 reserved for user defined error codes. The “source” identifies a VI and possibly its call chain as the origin of an error. Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;). This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
[[Image:Explain Error tool.jpg|frame|center|Figure 2:  Explain Error tool]] &lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters. For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;). You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;amp;lt;labview\user.lib\ errors&amp;amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;). This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”. This information can also be displayed using several different types of dialogs. This feature is commonly employed to identify errors in user interface applications. &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig 3-VI connectors.JPG|frame|center|Figure 3:  connectors for Error Cluster from Error Code.vi and General Error Handler.vi]] &lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
[[Image:Fig 3-error cluster examples.JPG|frame|center|Figure 4:  structures, comparison and array functions involving error cluster inputs]] &lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes. The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison function indicators.JPG|frame|center|Figure 5:  typical indicators for both modes of a comparison function]] &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster. While the &#039;&#039;&#039;Max &amp;amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default). The &#039;&#039;&#039;Array Max &amp;amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output. The primary sort is performed on “status”, with secondary ordering by “code” and then “source”. Strings are sorted by ASCII code starting with the leading character. Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;. &amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection  ==&lt;br /&gt;
&lt;br /&gt;
A common programming issue in LabVIEW involves selecting between two or more error clusters. This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true. The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters. This subVI is relatively fast with large error arrays. However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;amp;lt;10 elements) typical in most applications. This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array. The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;). &lt;br /&gt;
&lt;br /&gt;
[[Image:Simple error selector diagram.JPG|frame|center|Figure 6:  diagram for a simple error selector that does not detect warnings]] &lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs. Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful. While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero). &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest). &lt;br /&gt;
&lt;br /&gt;
[[Image:Error selector diagram A.JPG|frame|center]][[Image:Error selector diagrams B.JPG|frame|center|Figure 7:  possible diagrams for an error selector that detects warnings]] &lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.) Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown. Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true. The last approach uses the Max &amp;amp;amp; Min function in Compare Aggregates mode to order inputs. If just one of these clusters has “status” true, that input will be the “max” output since true &amp;amp;gt; false. However, this output must be checked for “status” true or “code” nonzero to determine selection. &amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier  ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases. &lt;br /&gt;
&lt;br /&gt;
== See also  ==&lt;br /&gt;
&lt;br /&gt;
*[[Error handling]] &lt;br /&gt;
*[[Error Case Structure]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Data_types]]&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Aspects_of_error_handling&amp;diff=3123</id>
		<title>Aspects of error handling</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Aspects_of_error_handling&amp;diff=3123"/>
		<updated>2007-10-14T14:38:41Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:ActiveDiscuss}}&lt;br /&gt;
&lt;br /&gt;
This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
&lt;br /&gt;
[[category:LabVIEW fundamentals]]&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1228</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1228"/>
		<updated>2007-05-08T03:20:09Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in LabVIEW 8.2 ([http://www.ni.com/pdf/manuals/371780b.pdf upgrade notes] p. 35).  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You could extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.  The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1227</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1227"/>
		<updated>2007-05-08T03:18:13Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in LabVIEW 8.2 (see[http://www.ni.com/pdf/manuals/371780b.pdf upgrade notes] p. 35).  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You could extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.  The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1226</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1226"/>
		<updated>2007-05-08T03:16:34Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in LabVIEW 8.2 ([http://www.ni.com/pdf/manuals/371780b.pdf page 35]).  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You could extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.  The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1225</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1225"/>
		<updated>2007-05-08T03:14:13Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in [http://www.ni.com/pdf/manuals/371780b.pdf LabVIEW 8.2].  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You could extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.  The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1224</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1224"/>
		<updated>2007-05-08T03:11:32Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in [http://www.ni.com/pdf/manuals/371780b.pdf LabVIEW 8.2].  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You could extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.  The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1223</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1223"/>
		<updated>2007-05-08T03:10:20Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in [http://www.ni.com/pdf/manuals/371780b.pdf LabVIEW 8.2].  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You could extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.  The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1214</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1214"/>
		<updated>2007-05-08T02:55:48Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_cluster_control_and_terminal.JPG‎|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
Note that the default terminal and wire color was changed from pink to dark yellow in [http://www.ni.com/pdf/manuals/371780b.pdf LabVIEW 8.2].  The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes.&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Cluster as Execution Order Specifier ==&lt;br /&gt;
&lt;br /&gt;
LabVIEW is a dataflow language and as such preferred way to specify execution order of block diagram items is to connect output of a block diagram item to an input of another block diagram item. There are situations when some certain execution order is required but the outputs of the items to be executed earlier cannot be connected to the inputs of the items to be executed later. In these situations error cluster is a preferred way to specify the execution order of the items. It&#039;s preferred over sequence structures in almost all use cases.&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Error_cluster_control_and_terminal.JPG&amp;diff=1211</id>
		<title>File:Error cluster control and terminal.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Error_cluster_control_and_terminal.JPG&amp;diff=1211"/>
		<updated>2007-05-08T02:47:09Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: 3D error cluster control and terminal (LabVIEW 8.2 and 7.1)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;3D error cluster control and terminal (LabVIEW 8.2 and 7.1)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1051</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1051"/>
		<updated>2007-05-06T22:52:24Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes.&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1050</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1050"/>
		<updated>2007-05-06T22:25:11Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes. (referenced earlier)&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:17, 3 May 2007 (CDT) --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1049</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1049"/>
		<updated>2007-05-06T22:24:21Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Selection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes. (referenced earlier)&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1048</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1048"/>
		<updated>2007-05-06T22:23:23Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
&amp;lt;!-- Bill VanArsdale, 21:18, 3 May 2007 (CDT) --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes. (referenced earlier)&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1036</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1036"/>
		<updated>2007-05-05T22:10:46Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes. (referenced earlier)&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1035</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1035"/>
		<updated>2007-05-05T21:59:35Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 &#039;&#039;&#039;and&#039;&#039;&#039; the range -9999 to -5000 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]] &lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  &amp;lt;s&amp;gt;You would have to extend this database to handle user defined error codes and provide some type of error log.&amp;lt;/s&amp;gt; &#039;&#039;See General Error Handler.vi online help for two different ways of providing error descriptions for user defined error codes.&#039;&#039;  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
|This entire section of WIKI about &amp;quot;Error Handling&amp;quot; could benefit from a deep reading of the online help for the General Error Handler.vi. That VI has more facilities than folks typically know. FOR EXAMPLE: &lt;br /&gt;
&lt;br /&gt;
The General Error Handler.vi includes an input parameter for the type of dialog, one option is &amp;quot;no dialog.&amp;quot; I would STRONGLY recommended instead of calling &amp;quot;Error Code Database.vi&amp;quot;. The primary reason for the recommendation is that the translation of error code cluster into human readable strings involves much more than just looking up text in the database. The &#039;&#039;&#039;source&#039;&#039;&#039; string itself may include information to override or extend the database, and the text in either the &#039;&#039;&#039;source&#039;&#039;&#039; string or the database may include formatting commands, such as HTML tags for bold face. Encoding information in the &#039;&#039;&#039;source&#039;&#039;&#039; string is a technique that will become more common in the future. &lt;br /&gt;
&lt;br /&gt;
You may desire to display the text, fully formatted, in a string indicator of your own instead of in any dialog. Use the function of General Error Handler CORE.vi (found on the block diagram of General Error Handler.vi) to do this. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [http://forums.lavag.org/downloads.html&amp;amp;showfile=86 log event error] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; should available soon.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1004</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1004"/>
		<updated>2007-05-05T05:25:35Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI [[log event error]] for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; should available soon.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1003</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=1003"/>
		<updated>2007-05-05T05:22:46Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available [[log event error]].&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=972</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=972"/>
		<updated>2007-05-04T17:43:44Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Selection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG|frame|center|&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal‎]]&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg|frame|center|&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool]]&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG|frame|center|&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG|frame|center|&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs]]&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG|frame|center|&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG|frame|center|&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings]]&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG|frame|center|]][[Image:Error_selector_diagrams_B.JPG|frame|center|&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings]]&lt;br /&gt;
 &lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG|center|thumb|600px|&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop]]&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg|frame|center|&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;]]&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039; and &#039;&#039;&#039;Figure 11&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG|frame|center|&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; in Windows]]&lt;br /&gt;
[[Image:Event_properties.jpg|frame|center|&#039;&#039;&#039;Figure 11&#039;&#039;&#039;:&#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows]]&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=965</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=965"/>
		<updated>2007-05-04T03:50:08Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039; in Windows&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=964</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=964"/>
		<updated>2007-05-04T03:45:44Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=963</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=963"/>
		<updated>2007-05-04T03:45:12Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 3&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=962</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=962"/>
		<updated>2007-05-04T03:28:07Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Selection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal zero if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal zero).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=961</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=961"/>
		<updated>2007-05-04T03:24:54Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the &#039;&#039;&#039;Compare Aggregates&#039;&#039;&#039; mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the &#039;&#039;&#039;Compare Elements&#039;&#039;&#039; mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=960</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=960"/>
		<updated>2007-05-04T03:21:26Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the &#039;&#039;&#039;Help&#039;&#039;&#039; menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=959</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=959"/>
		<updated>2007-05-04T03:19:27Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Producer-consumer.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Producer-consumer.PNG&amp;diff=958</id>
		<title>File:Producer-consumer.PNG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Producer-consumer.PNG&amp;diff=958"/>
		<updated>2007-05-04T03:17:46Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: producer-consumer diagram with error handling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;producer-consumer diagram with error handling&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=957</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=957"/>
		<updated>2007-05-04T03:11:48Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Event_viewer.JPG]]&lt;br /&gt;
[[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=956</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=956"/>
		<updated>2007-05-04T03:10:32Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Event_viewer.JPG]]&lt;br /&gt;
 [[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=955</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=955"/>
		<updated>2007-05-04T03:10:01Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Selection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
[[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Event_viewer.JPG]]&lt;br /&gt;
 [[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=954</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=954"/>
		<updated>2007-05-04T03:07:24Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Event_viewer.JPG]]&lt;br /&gt;
 [[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;eventcreate&#039;&#039;&#039; command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=953</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=953"/>
		<updated>2007-05-04T03:05:39Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
 &lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Event_viewer.JPG]]&lt;br /&gt;
 [[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=952</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=952"/>
		<updated>2007-05-04T03:04:10Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_code_database_connector.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Event_viewer.JPG]][[Image:Event_properties.jpg]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Event_properties.jpg&amp;diff=951</id>
		<title>File:Event properties.jpg</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Event_properties.jpg&amp;diff=951"/>
		<updated>2007-05-04T03:03:16Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: Windows Event Properties&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Windows Event Properties&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Event_viewer.JPG&amp;diff=950</id>
		<title>File:Event viewer.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Event_viewer.JPG&amp;diff=950"/>
		<updated>2007-05-04T03:02:03Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: Windows Event Viewer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Windows Event Viewer&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Error_code_database_connector.jpg&amp;diff=949</id>
		<title>File:Error code database connector.jpg</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Error_code_database_connector.jpg&amp;diff=949"/>
		<updated>2007-05-04T03:00:07Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: connector for the Error Code Database.vi&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;connector for the Error Code Database.vi&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=948</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=948"/>
		<updated>2007-05-04T02:58:04Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 [[Image:Download high resolution version (804x499, 209 KB)]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Producer-consumer_diagram.JPG&amp;diff=947</id>
		<title>File:Producer-consumer diagram.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Producer-consumer_diagram.JPG&amp;diff=947"/>
		<updated>2007-05-04T02:56:47Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: producer-consumer diagram with error handling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;producer-consumer diagram with error handling&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=946</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=946"/>
		<updated>2007-05-04T02:54:17Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=945</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=945"/>
		<updated>2007-05-04T02:53:52Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=944</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=944"/>
		<updated>2007-05-04T02:52:55Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=943</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=943"/>
		<updated>2007-05-04T02:52:14Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Selection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the &#039;&#039;&#039;Or&#039;&#039;&#039; function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the &#039;&#039;&#039;And&#039;&#039;&#039; function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]][[Image:Error_selector_diagrams_B.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:wevanarsdale|wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Error_selector_diagrams_B.JPG&amp;diff=942</id>
		<title>File:Error selector diagrams B.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Error_selector_diagrams_B.JPG&amp;diff=942"/>
		<updated>2007-05-04T02:51:00Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: diagrams for slower error selectors that detect warnings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;diagrams for slower error selectors that detect warnings&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=941</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=941"/>
		<updated>2007-05-04T02:46:38Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Selection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Simple_error_selector_diagram.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the Or function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the And function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Error_selector_diagram_A.JPG]]&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Error_selector_diagram_A.JPG&amp;diff=940</id>
		<title>File:Error selector diagram A.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Error_selector_diagram_A.JPG&amp;diff=940"/>
		<updated>2007-05-04T02:45:50Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: diagram for a fast error selector that detects warnings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;diagram for a fast error selector that detects warnings&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Simple_error_selector_diagram.JPG&amp;diff=939</id>
		<title>File:Simple error selector diagram.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Simple_error_selector_diagram.JPG&amp;diff=939"/>
		<updated>2007-05-04T02:42:45Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: simple error selector based on the Select function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;simple error selector based on the Select function&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=938</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=938"/>
		<updated>2007-05-04T02:40:54Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 [[Image:Comparison_function_indicators.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the Or function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the And function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Comparison_function_indicators.JPG&amp;diff=937</id>
		<title>File:Comparison function indicators.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Comparison_function_indicators.JPG&amp;diff=937"/>
		<updated>2007-05-04T02:40:10Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: typical indicators for both compare elements and compare aggregates modes of a comparison function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;typical indicators for both compare elements and compare aggregates modes of a comparison function&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=936</id>
		<title>Error Cluster data type</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=Error_Cluster_data_type&amp;diff=936"/>
		<updated>2007-05-04T02:37:30Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: /* Error Cluster */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Error Cluster ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An error cluster contains a Boolean “status”, an I32 numerical “code” and a “source” string in that order.  Any cluster with this structure is treated as an error cluster in LabVIEW.  The default value, “status” = false, “code” = 0 and “source” empty, is shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; for a typical control.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_1-error_cluster_control_and_terminal.JPG‎]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 1&#039;&#039;&#039;:  3D error cluster control and terminal&lt;br /&gt;
&lt;br /&gt;
The “status” is true if an error has occurred but remains false for warnings.  The “code” assumes positive and negative values (see “error codes, ranges of” in &#039;&#039;LabVIEW Help&#039;&#039;), with the range 5000 through 9999 reserved for user defined error codes.  The “source” identifies a VI and possibly its call chain as the origin of an error.  Possible reasons for an error can be obtained from the &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool (see &#039;&#039;&#039;Figure 2&#039;&#039;&#039;).  This tool is activated by selecting the &#039;&#039;&#039;Explain Error…&#039;&#039;&#039; item under the Help menu in LabVIEW or by right-clicking on any element of an error cluster with “status” true and selecting &#039;&#039;&#039;Explain Error&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Image:Explain_Error_tool.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 2&#039;&#039;&#039;:  &#039;&#039;&#039;Explain Error&#039;&#039;&#039; tool&lt;br /&gt;
&lt;br /&gt;
LabVIEW provides several VIs for working with error clusters.  For example, the &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; generates an error cluster based on a specified “code” (see &#039;&#039;&#039;Figure 3&#039;&#039;&#039;).  You can also define custom codes using the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; or by creating an XML-based text file in the &amp;lt;labview\user.lib\ errors&amp;gt; directory (see “error codes, defining custom” and “error codes, defining custom in text files” in &#039;&#039;LabVIEW Help&#039;&#039;).  This VI outputs a “message”, like the “Explanation” from &#039;&#039;&#039;Explain Error&#039;&#039;&#039;, which identifies the “source” and describes possible causes associated with the “code”.  This information can also be displayed using several different types of dialogs.  This feature is commonly employed to identify errors in user interface applications.&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-VI_connectors.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 3&#039;&#039;&#039;:  connectors for &#039;&#039;&#039;Error Cluster from Error Code.vi&#039;&#039;&#039; and &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Error clusters are also valid inputs to some comparison and array functions and can be used to control case structures and while loops (see &#039;&#039;&#039;Figure 4&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[Image:Fig_3-error_cluster_examples.JPG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Figure 4&#039;&#039;&#039;:  structures, comparison and array functions involving error cluster inputs&lt;br /&gt;
&lt;br /&gt;
The comparison functions &#039;&#039;&#039;Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Not Equal?&#039;&#039;&#039;, &#039;&#039;&#039;Greater?&#039;&#039;&#039;, &#039;&#039;&#039;Less?&#039;&#039;&#039;, &#039;&#039;&#039;Greater Or Equal?&#039;&#039;&#039; and &#039;&#039;&#039;Less Or Equal?&#039;&#039;&#039; can operate in two modes.  The output is Boolean in the Compare Aggregates mode, while a cluster of three Booleans corresponding to each component of the error cluster is generated in the Compare Elements mode (see &#039;&#039;&#039;Figure 5&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 5&#039;&#039;&#039;:  typical indicators for both modes of a comparison function&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Select&#039;&#039;&#039;, &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; and &#039;&#039;&#039;In Range and Coerce&#039;&#039;&#039; functions can output an error cluster.  While the &#039;&#039;&#039;Max &amp;amp; Min&#039;&#039;&#039; function returns ordered inputs in the Compare Aggregates mode, an output may not correspond to either error cluster if Compare Elements is selected (default).  The &#039;&#039;&#039;Array Max &amp;amp; Min&#039;&#039;&#039; function always returns ordered inputs corresponding to the first and last elements of the &#039;&#039;&#039;Sort 1D Array&#039;&#039;&#039; output.  The primary sort is performed on “status”, with secondary ordering by “code” and then “source”.  Strings are sorted by ASCII code starting with the leading character.  Note that error clusters behave like their Boolean “status” value when connected to the selector terminal of a &#039;&#039;&#039;Select&#039;&#039;&#039; function and &#039;&#039;&#039;Case Structure&#039;&#039;&#039; or the conditional terminal of a &#039;&#039;&#039;While Loop&#039;&#039;&#039;.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Selection ==&lt;br /&gt;
&lt;br /&gt;
	A common programming issue in LabVIEW involves selecting between two or more error clusters.  This process involves finding the cluster with “status” true or “code” not equal 0 if no “status” is true.  The &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 4&#039;&#039;&#039; implements this search for up to three error clusters and an array of such clusters.  This subVI is relatively fast with large error arrays.  However, a significant portion of the execution time involves concatenation of inputs for the small arrays (&amp;lt;10 elements) typical in most applications.  This result suggests that time critical applications should be built around the immediate selection between two error clusters rather than their concatenation into an array.  The simplest method of comparing the “status” of two error clusters involves the Select function (see &#039;&#039;&#039;Figure 6&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 6&#039;&#039;&#039;:  diagram for a simple error selector that does not detect warnings&lt;br /&gt;
&lt;br /&gt;
This function selects the first error cluster with “status” true, much like the Or function operating on Boolean inputs.  Connecting “error 2” instead of “error 1” to the selector terminal is more analogous to the And function, which is typically less useful.  While about 30 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), the &#039;&#039;&#039;Select&#039;&#039;&#039; function does not detect a warning (“status” false and “code” not equal 0).  &lt;br /&gt;
&lt;br /&gt;
	Diagrams for several VIs that compare error clusters and detect warnings are shown below (fastest to slowest).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 7&#039;&#039;&#039;:  possible diagrams for an error selector that detects warnings&lt;br /&gt;
&lt;br /&gt;
These VIs execute about 5 times faster than the &#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; (LabVIEW 7.0), even with normal priority execution. (&#039;&#039;&#039;Merge Errors.vi&#039;&#039;&#039; uses the “subroutine” priority.)  Inputs to selector terminals in the first and second diagrams are passed to “error” for the cases not shown.  Otherwise, “error 1” is checked for nonzero “code” since neither cluster has “status” true.  The last approach uses the Max &amp;amp; Min function in Compare Aggregates mode to order inputs.  If just one of these clusters has “status” true, that input will be the “max” output since true &amp;gt; false.  However, this output must be checked for “status” true or “code” nonzero to determine selection.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:18, 3 May 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
== Error Handling ==&lt;br /&gt;
&lt;br /&gt;
	Every LabVIEW programmer has their own approach to handling errors.  In fact, those with multiple personalities probably have several different approaches to handling errors.  As an example, consider the producer-consumer diagram shown in &#039;&#039;&#039;Figure 8&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 8&#039;&#039;&#039;:  producer-consumer diagram with error handling in the top loop&lt;br /&gt;
&lt;br /&gt;
The “event loop” (bottom) produces enumerated commands that are processed by the “cmd loop” (top).  The outer case structure in the top loop traps for errors that are placed on the lower shift register.  The corresponding error case (not shown) allows error handling by “code” with different methods of notification.  For example, a user interface application based on this design pattern might employ the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039; shown in &#039;&#039;&#039;Figure 1&#039;&#039;&#039; to display a dialog for particular errors.  However, this method would not work for applications that run continuously without user interaction.&lt;br /&gt;
&lt;br /&gt;
	For continuously running applications, an error dialog (or any other kind of dialog for that matter) would disrupt execution, causing data loss or some other event you are being paid to avoid.  Logging error information to file is a useful notification method for such applications.  This approach requires an error description, which is provided by the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039; (see &#039;&#039;&#039;Figure 9&#039;&#039;&#039;) for specified error codes in LabVIEW.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 9&#039;&#039;&#039;:  connector for the &#039;&#039;&#039;Error Code Database.vi&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This locked VI, located in the library &amp;lt;labview\vi.lib\Utility\error.llb&amp;gt;, is easily found as a subVI of the &#039;&#039;&#039;General Error Handler.vi&#039;&#039;&#039;.  You would have to extend this database to handle user defined error codes and provide some type of error log.  For example, some Windows applications log errors to the &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; (right-click on &#039;&#039;&#039;My Computer&#039;&#039;&#039; and select &#039;&#039;&#039;Manage&#039;&#039;&#039; from the popup menu) shown in &#039;&#039;&#039;Figure 10&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Figure 10&#039;&#039;&#039;:  &#039;&#039;&#039;Event Viewer&#039;&#039;&#039; and &#039;&#039;&#039;Event Properties&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The eventcreate command can be used in Windows to log events to this application.  A VI for logging errors to the Event Viewer is available here.&lt;br /&gt;
--[[User:Wevanarsdale|Wevanarsdale]] 21:17, 3 May 2007 (CDT)&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
	<entry>
		<id>https://labviewwiki.org/w/index.php?title=File:Fig_3-error_cluster_examples.JPG&amp;diff=935</id>
		<title>File:Fig 3-error cluster examples.JPG</title>
		<link rel="alternate" type="text/html" href="https://labviewwiki.org/w/index.php?title=File:Fig_3-error_cluster_examples.JPG&amp;diff=935"/>
		<updated>2007-05-04T02:36:30Z</updated>

		<summary type="html">&lt;p&gt;Wevanarsdale: structures, comparison and array functions involving error cluster inputs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;structures, comparison and array functions involving error cluster inputs&lt;/div&gt;</summary>
		<author><name>Wevanarsdale</name></author>
	</entry>
</feed>