<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re : Sorting list problems in 2013 in LabWindows/CVI</title>
    <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2931846#M67775</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I met the same problem with ListFindItem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.ni.com/t5/LabWindows-CVI/ListFindItem-with-StartingPosition-out-of-range-BUG/m-p/2881358" target="_blank"&gt;ListFindIt​em with StartingPo​sition out of range&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are not alone &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.ni.com/i/smilies/16x16_smiley-wink.gif" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most CVI functions returned error codes except the List functions, most CVI functions are 0 based except the List functions. The List functions don't respect the CVI "rules", unfortunatly for us !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jul 2014 12:19:41 GMT</pubDate>
    <dc:creator>jm73</dc:creator>
    <dc:date>2014-07-24T12:19:41Z</dc:date>
    <item>
      <title>Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928394#M67736</link>
      <description>&lt;P&gt;I'm programming&amp;nbsp;by CVI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I encounter a critical problem - the list sort built-in library does not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In both of console and real-time application, the sort result is wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I solve this problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;=================================================================&lt;/P&gt;
&lt;P&gt;int main (int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;double value1 = 3.0;&lt;BR /&gt;&amp;nbsp;double value2 = 4.0;&lt;BR /&gt;&amp;nbsp;double value3 = 1.0;&lt;BR /&gt;&amp;nbsp;double value4 = 2.0;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;double test;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;int i;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;ListType newList;&lt;/P&gt;
&lt;P&gt;//&amp;nbsp;if (argc &amp;lt; 2 || argc &amp;gt; 3)&lt;BR /&gt;//&amp;nbsp;&amp;nbsp;usage (argv[0]);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;printf("This is built-in List type test program!\n");&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;newList = ListCreate(sizeof(double));&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;if (newList == VI_NULL)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;return -1;&lt;BR /&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;ListInsertItem(newList, &amp;amp;value1, END_OF_LIST);&lt;BR /&gt;&amp;nbsp;ListInsertItem(newList, &amp;amp;value2, END_OF_LIST); &lt;BR /&gt;&amp;nbsp;ListInsertItem(newList, &amp;amp;value3, END_OF_LIST);&lt;BR /&gt;&amp;nbsp;ListInsertItem(newList, &amp;amp;value4, END_OF_LIST);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;printf("&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; The original list\n");&lt;BR /&gt;&amp;nbsp;for (i=0; i&amp;lt;ListNumItems(newList); i++)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;ListGetItem(newList, &amp;amp;test, i);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;printf("[%d] %f\n", i, test);&lt;BR /&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;ListInsertionSort(newList, DoubleCompare);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;printf("&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; The sorted list\n");&lt;BR /&gt;&amp;nbsp;for (i=0; i&amp;lt;ListNumItems(newList); i++)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;ListGetItem(newList, &amp;amp;test, i);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;printf("[%d] %f\n", i, test);&lt;BR /&gt;&amp;nbsp;}&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;if (newList)&lt;BR /&gt;&amp;nbsp;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;ListDispose(newList);&lt;BR /&gt;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;=================================================================&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is built-in List type test program!&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; The original list&lt;BR /&gt;[0] 2.000000&lt;BR /&gt;[1] 3.000000&lt;BR /&gt;[2] 4.000000&lt;BR /&gt;[3] 1.000000&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; The sorted list&lt;BR /&gt;[0] 4.000000&lt;BR /&gt;[1] 1.000000&lt;BR /&gt;[2] 2.000000&lt;BR /&gt;[3] 3.000000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 04:15:35 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928394#M67736</guid>
      <dc:creator>just4u78</dc:creator>
      <dc:date>2014-07-22T04:15:35Z</dc:date>
    </item>
    <item>
      <title>RE: Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928446#M67738</link>
      <description>&lt;P&gt;ListInsertItem function is not correctly&amp;nbsp;working, too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Who's duty about&amp;nbsp;modification of&amp;nbsp;this wrong library?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 06:08:17 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928446#M67738</guid>
      <dc:creator>just4u78</dc:creator>
      <dc:date>2014-07-22T06:08:17Z</dc:date>
    </item>
    <item>
      <title>Rif.: Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928478#M67739</link>
      <description>&lt;P&gt;There is nothing wrong in those function, it's really that you haven't read the help for&amp;nbsp;&lt;A href="http://zone.ni.com/reference/en-XX/help/370051Y-01/toolslib/functionreference/cvilistgetitem/" target="_blank"&gt;ListGetItem&lt;/A&gt;, which clearly states that&amp;nbsp;&lt;SPAN&gt;positionOfItemToGet parameter must vary from 1 to the number of items in the list. With your for loops starting at 0, you are really reading the last element in the list first (END_OF_LIST has the value of 0), next all other elements &lt;EM&gt;except the last one&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 06:31:58 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928478#M67739</guid>
      <dc:creator>RobertoBozzolo</dc:creator>
      <dc:date>2014-07-22T06:31:58Z</dc:date>
    </item>
    <item>
      <title>Rif.: Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928518#M67742</link>
      <description>&lt;P&gt;Thanks for your attention.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just know about the index.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2014 06:54:20 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2928518#M67742</guid>
      <dc:creator>just4u78</dc:creator>
      <dc:date>2014-07-22T06:54:20Z</dc:date>
    </item>
    <item>
      <title>Re : Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2931846#M67775</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I met the same problem with ListFindItem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.ni.com/t5/LabWindows-CVI/ListFindItem-with-StartingPosition-out-of-range-BUG/m-p/2881358" target="_blank"&gt;ListFindIt​em with StartingPo​sition out of range&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are not alone &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.ni.com/i/smilies/16x16_smiley-wink.gif" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Most CVI functions returned error codes except the List functions, most CVI functions are 0 based except the List functions. The List functions don't respect the CVI "rules", unfortunatly for us !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2014 12:19:41 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2931846#M67775</guid>
      <dc:creator>jm73</dc:creator>
      <dc:date>2014-07-24T12:19:41Z</dc:date>
    </item>
    <item>
      <title>Re : Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2932128#M67779</link>
      <description>&lt;P&gt;Well, as Daniel and Luis explained in the thread you linked, this is not actually a bug, even though I agree that it's not obvious.&lt;/P&gt;
&lt;P&gt;Neither it's true that list functions are the only 1-based ones: just as an example,&amp;nbsp;when you work with tables, row and column indexes are 1-based, working with a database the first record is 1 and there may be other cases.&lt;/P&gt;
&lt;P&gt;The true fact is that when you use a function that requires an index you must double-check whether it is 1-based or 0-based.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2014 14:46:39 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2932128#M67779</guid>
      <dc:creator>RobertoBozzolo</dc:creator>
      <dc:date>2014-07-24T14:46:39Z</dc:date>
    </item>
    <item>
      <title>Re : Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2933110#M67789</link>
      <description>&lt;P&gt;Hello Roberto,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with you, it's not a bug and we must be careful when using index.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1°) I think the documentation is "ambiguous". The parameter startingPosition for ListFindItem function is defined like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The position of the item in the list to start the search from. The position may be a number from 1 to the number of items in the list.&lt;BR /&gt;To start searching from the first item in a list, the constant &lt;SPAN&gt;FRONT_OF_LIST&lt;/SPAN&gt; may be passed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you read "&lt;EM&gt;&amp;nbsp;The position may be a number &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;from&lt;/STRONG&gt;&lt;/SPAN&gt; 1 to the number of items in the list&lt;/EM&gt;"&amp;nbsp; you mind automatically eliminates values &amp;lt;1 (you&amp;nbsp;never remember that FRONT_OF_LIST = -1 ! ) and END_OF_LIST is not mentionned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you write the help like below&amp;nbsp;with the possible values, perhaps there will be less confusion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The position of the item in the list to start the search from. The possible values are:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;-1&lt;/STRONG&gt; (FRONT_OF_LIST) to start searching from the first item in a list.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;0&lt;/STRONG&gt; (END_OF_LIST) to start searching from the last item in a list.&lt;/LI&gt;
&lt;LI&gt;a number &lt;SPAN style="text-decoration: underline;"&gt;between&lt;/SPAN&gt; 1 and the number of items in the list.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2°) I think it's was a bad idea to define END_OF_LIST = 0 because 0 is a "special" value.&lt;/P&gt;
&lt;P&gt;END_OF_LIST = -2 would have been a better choice. So ListGetXXX would return NULL with an index = 0 and the index mistake would&amp;nbsp; be easier to detect .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bye.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2014 08:23:23 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2933110#M67789</guid>
      <dc:creator>jm73</dc:creator>
      <dc:date>2014-07-25T08:23:23Z</dc:date>
    </item>
    <item>
      <title>Re : Sorting list problems in 2013</title>
      <link>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2933136#M67790</link>
      <description>&lt;P&gt;Yes, you're right, that choice of constant value is odd and may lead to confusion, even&amp;nbsp;more if you consider for example that VAL_TO_EDGE (the constant used to set&amp;nbsp;Rect structures up to the end of valid range in tables) is defined as -1!&lt;/P&gt;
&lt;P&gt;That note of passing FRONT_OF_LIST to start searching from the beginning is too weak&amp;nbsp;compared to END_OF_LIST being set as 0, so I agree that an improvement in the function help may be needed.&lt;/P&gt;
&lt;P&gt;I have as a golden rule to carefully read the help and use system-defined constant whenever possible: this example encourages&amp;nbsp;me to continue this way!&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.ni.com/i/smilies/16x16_smiley-wink.gif" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2014 08:48:15 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabWindows-CVI/Sorting-list-problems-in-2013/m-p/2933136#M67790</guid>
      <dc:creator>RobertoBozzolo</dc:creator>
      <dc:date>2014-07-25T08:48:15Z</dc:date>
    </item>
  </channel>
</rss>

