<?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: Writing to an uninitialized string array? in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252470#M1237446</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/665537"&gt;@TakeANap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You confirm the method i use. It is similar as mine. I add with &lt;EM&gt;Insert array&lt;/EM&gt; a subarray below or to the right of the last free row/col.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have also add code that detect first free row/col and use that value as xy-parameter for the new data.&amp;nbsp;I did that for fun.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For Insert Into Array, if you leave the index inputs unwired, it automatically adds the new data to the end. No need to get array size and wire the inputs.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 16:19:57 GMT</pubDate>
    <dc:creator>FireFist-Redhawk</dc:creator>
    <dc:date>2022-08-30T16:19:57Z</dc:date>
    <item>
      <title>Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252411#M1237419</link>
      <description>&lt;P&gt;If I have a 2D &lt;STRONG&gt;uninitialized&lt;/STRONG&gt; string array and want to write a str to let say cell 5.2. How should I do it?&lt;/P&gt;
&lt;P&gt;Further, let say I want to add more data into the array at cell 7,5. How should that be done?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(The empty cells can be filled with Empty String Const.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:20:28 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252411#M1237419</guid>
      <dc:creator>TakeANap</dc:creator>
      <dc:date>2022-08-30T12:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252419#M1237425</link>
      <description>&lt;P&gt;You can use the "Max &amp;amp; Min" function to determine easily the needed new array size:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Adapt 2D-Array size to new elmnt Idx.png" style="width: 686px;"&gt;&lt;img src="https://ip1.i.lithium.com/f73af664f7d5e8fe1998fa2788b86bf2907b8785/68747470733a2f2f6e692e6c69746869756d2e636f6d2f74352f696d6167652f736572766572706167652f696d6167652d69642f33303734343469444442314139313932314644323732342f696d6167652d73697a652f6c617267653f763d76322670783d393939" role="button" title="Adapt 2D-Array size to new elmnt Idx.png" alt="Adapt 2D-Array size to new elmnt Idx.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If needed, you create a new array with the needed size and copy the original part into the new larger array. Then replace the new element at the given index position.&lt;/P&gt;
&lt;DIV id="blinkextension_snap_links_box_mg_mouse_gestures" style="background-color: rgba(250, 128, 0, 0.07); border: 3px dashed blue; box-sizing: border-box; position: absolute; z-index: 2147483647; display: none; left: 267px; top: 18px;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="hit_a_link_blinkextension_container_mg_mouse_gestures" style="display: none; position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 2147483647; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:57:45 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252419#M1237425</guid>
      <dc:creator>daveTW</dc:creator>
      <dc:date>2022-08-30T12:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252420#M1237426</link>
      <description>&lt;P&gt;I believe the simple answer to your question is that you cannot manipulate "what isn't there", meaning you need to first initialize your String Array (which sets its size, and lets you define what you mean by "Cell 7, 5" (does this mean the 6th element in the 8th row, considering the initial element is at (0, 0)?).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bob Schor&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 12:58:20 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252420#M1237426</guid>
      <dc:creator>Bob_Schor</dc:creator>
      <dc:date>2022-08-30T12:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252422#M1237428</link>
      <description>&lt;P&gt;Some additional hints:&lt;/P&gt;
&lt;P&gt;if your array is of significant size and you want to insert many elements at outer ranges, it is better to initialize your array to the max assumed size, insert the new elements with the "In Place Element Structure" and shrink the array afterwards (Subarray).&lt;/P&gt;
&lt;DIV id="blinkextension_snap_links_box_mg_mouse_gestures" style="background-color: rgba(250, 128, 0, 0.07); border: 3px dashed blue; box-sizing: border-box; position: absolute; z-index: 2147483647; display: none; left: 601px; top: 65px;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="hit_a_link_blinkextension_container_mg_mouse_gestures" style="display: none; position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 2147483647; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:10:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252422#M1237428</guid>
      <dc:creator>daveTW</dc:creator>
      <dc:date>2022-08-30T13:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252429#M1237432</link>
      <description>&lt;P&gt;You confirm the method i use. It is similar as mine. I add with &lt;EM&gt;Insert array&lt;/EM&gt; a subarray below or to the right of the last free row/col.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have also add code that detect first free row/col and use that value as xy-parameter for the new data.&amp;nbsp;I did that for fun.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:48:44 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252429#M1237432</guid>
      <dc:creator>TakeANap</dc:creator>
      <dc:date>2022-08-30T13:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252431#M1237434</link>
      <description>&lt;P&gt;Me too &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;DIV id="blinkextension_snap_links_box_mg_mouse_gestures" style="background-color: rgba(250, 128, 0, 0.07); border: 3px dashed blue; box-sizing: border-box; position: absolute; z-index: 2147483647; display: none;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="hit_a_link_blinkextension_container_mg_mouse_gestures" style="display: none; position: absolute; left: 0px; top: 0px; width: 0px; height: 0px; z-index: 2147483647; background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%;"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 30 Aug 2022 13:56:07 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252431#M1237434</guid>
      <dc:creator>daveTW</dc:creator>
      <dc:date>2022-08-30T13:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252470#M1237446</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/665537"&gt;@TakeANap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You confirm the method i use. It is similar as mine. I add with &lt;EM&gt;Insert array&lt;/EM&gt; a subarray below or to the right of the last free row/col.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have also add code that detect first free row/col and use that value as xy-parameter for the new data.&amp;nbsp;I did that for fun.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For Insert Into Array, if you leave the index inputs unwired, it automatically adds the new data to the end. No need to get array size and wire the inputs.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 16:19:57 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252470#M1237446</guid>
      <dc:creator>FireFist-Redhawk</dc:creator>
      <dc:date>2022-08-30T16:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252520#M1237461</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/665537"&gt;@TakeANap&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I add with &lt;EM&gt;Insert array&lt;/EM&gt; a subarray below or to the right of the last free row/col.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have also add code that detect first free row/col and use that value as xy-parameter for the new data.&amp;nbsp;I did that for fun.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your "method" requires significantly more code because you need to determine if a subarray needs to be inserted below, to the right, or even both. I don't understand what the "fun" in that would be. A Rube Goldberg cartoon perhaps? &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; Dave's solution is significantly better and more efficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;U&gt;correct solution&lt;/U&gt; would be to decide from the beginning on a reasonable maximum size, initialize an array of empty strings at that size and keep the size fixed. Memory management is significantly better if arrays don't constantly change size.&amp;nbsp;Also the code is greatly simplified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that arrays of any dimension are stored linearly in contiguous memory, so inserting columns typically requires a complete new allocation for everything because most elements need to be moved to new positions relative to the first element (have a look at &lt;A href="https://forums.ni.com/t5/2016-Advanced-User-Track/TS9524-Code-Optimization-and-Benchmarking/td-p/3538653" target="_self"&gt;slide #11 here&lt;/A&gt;&amp;nbsp; (in part II)).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not explain the purpose of all this! For example if the 2D array is typically "sparse" (only very few elements are &lt;U&gt;not&lt;/U&gt; empty strings), you might want to use a &lt;A href="https://labviewwiki.org/wiki/NIWeek_2019/From_Variant_Attributes_to_Sets_and_Maps_(New_in_2019)" target="_blank" rel="noopener"&gt;MAP&lt;/A&gt; with an array of indices as key and a string as value. Now you can even add an element at&amp;nbsp; Index [&lt;SPAN&gt;2147483647,&amp;nbsp;2147483647] without much memory penalty and can look it op at any time later. All elements that are empty strings are default and don't need to be part of the map. It is safe to say that a 2D array of empty strings with 10^18 elements is not possible. You could even make the "key" a pair of U64 to perfectly store an string value with indices&amp;nbsp;18446744073709551615 each. &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 14:01:37 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252520#M1237461</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2022-08-31T14:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Writing to an uninitialized string array?</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252572#M1237480</link>
      <description>&lt;P&gt;Your comment was exactly what I was looking for when I posted my question. I will look into your suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VI I'm speaking about isn't used in a time-critical application. However, if I would be writing code for ha highspeed sampling engine I would have used another way of allocating memory and storing data.&amp;nbsp; I working also with embedded microcontrollers and forget that PC:s has lots of memory. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 05:36:01 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Writing-to-an-uninitialized-string-array/m-p/4252572#M1237480</guid>
      <dc:creator>TakeANap</dc:creator>
      <dc:date>2022-08-31T05:36:01Z</dc:date>
    </item>
  </channel>
</rss>

