<?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: How to set a string for a cell in array values of GDL object? in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570849#M8714</link>
    <description>&lt;P&gt;In GDL land an array may only contain one data type e.g. number or string, they can't be mixed. Not sure if that is what you are trying to do?&lt;/P&gt;</description>
    <pubDate>Sat, 14 Oct 2023 16:55:37 GMT</pubDate>
    <dc:creator>DGSketcher</dc:creator>
    <dc:date>2023-10-14T16:55:37Z</dc:date>
    <item>
      <title>How to set a string for a cell in array values of GDL object?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570842#M8713</link>
      <description>&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;
&lt;P&gt;I get and set a value in array values like this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;if ((*memo.params)[i].name == (GS::UniString)"matrix_area")
		{
			API_AddParType* pAddPar = &amp;amp;(*memo.params)[i];

			GS::uchar_t** arrHdl = reinterpret_cast&amp;lt;GS::uchar_t**&amp;gt;(pAddPar-&amp;gt;value.array);

			(*arrHdl)[0] = 'f';
		}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I can only set it to the uchar_t value. Can I set it a string value?&lt;BR /&gt;Can you answer for me? Thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 12:27:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570842#M8713</guid>
      <dc:creator>Tran Thanh Lo</dc:creator>
      <dc:date>2024-09-16T12:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a string for a cell in array values of GDL object?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570849#M8714</link>
      <description>&lt;P&gt;In GDL land an array may only contain one data type e.g. number or string, they can't be mixed. Not sure if that is what you are trying to do?&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 16:55:37 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570849#M8714</guid>
      <dc:creator>DGSketcher</dc:creator>
      <dc:date>2023-10-14T16:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a string for a cell in array values of GDL object?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570860#M8716</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/11396"&gt;@DGSketcher&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;In GDL land an array may only contain one data type e.g. number or string, they can't be mixed. Not sure if that is what you are trying to do?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, I see. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Oct 2023 04:36:18 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570860#M8716</guid>
      <dc:creator>Tran Thanh Lo</dc:creator>
      <dc:date>2023-10-15T04:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to set a string for a cell in array values of GDL object?</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570900#M8723</link>
      <description>&lt;P&gt;You need to use something like &lt;CODE&gt;GS::ucscpy&lt;/CODE&gt; to copy a whole string (instead of a single character) into a &lt;CODE&gt;uchar_t&lt;/CODE&gt; pointer. And the handle needs to be appropriately sized!&lt;BR /&gt;&lt;BR /&gt;Here's some (untested) sample code:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;GS::Array&amp;lt;GS::UniString&amp;gt; stringsToCopy{ "foo", "barbar" };

// assuming we have a one dimensional parameter array of strings
auto&amp;amp; currentParam = (*memo.params)[i];
if (currentParam.dim1 != 1) { return; }

currentParam.dim1 = usedZoneCats.GetSize ();
currentParam.dim2 = 1;

GS::USize totalLength = 0;
for (const auto str : stringsToCopy) {
	// +1 because the "\0" string delimiter is not counted in GetLength () function
	totalLength += str.GetLength () + 1;
}

currentParam.value.array = BMReallocHandle (currentParam.value.array,
	totalLength * sizeof (GS::uchar_t), REALLOC_FULLCLEAR, 0);
auto attrArray = reinterpret_cast&amp;lt;GS::uchar_t*&amp;gt;(*currentParam.value.array);
GS::USize strStart = 0;
for (Int32 j = 0; j &amp;lt; currentParam.dim1; ++j) {
	GS::ucscpy (attrArray + strStart, stringsToCopy[j].ToUStr ());
	strStart += stringsToCopy[j].GetLength () + 1;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 15 Oct 2023 22:21:15 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/How-to-set-a-string-for-a-cell-in-array-values-of-GDL-object/m-p/570900#M8723</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2023-10-15T22:21:15Z</dc:date>
    </item>
  </channel>
</rss>

