<?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 save an info from external text to a parameter? in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284679#M3474</link>
    <description>It is a quite complex chain of GDL quirks that leads to this behaviour.&lt;BR /&gt;
&lt;BR /&gt;
The text add-on uses a fixed logic to determine the type of the variables it sets, disregarding what it was initialized to. If it looks like a number it is a number, otherwise a string. Decimal separators are . not , So in your file some entries will be read as numbers, some as strings.&lt;BR /&gt;
&lt;BR /&gt;
GDL array variables can hold mixed types (integer and string), but parameter arrays can't.&lt;BR /&gt;
It is quite possible to use a variable with the same name as a parameter. By writing dim x[][] you define a variable that shadows the parameter, not redefine the parameter.&lt;BR /&gt;
Using parameters x = x the variable x with mixed types is assigned to the parameter x.&lt;BR /&gt;
&lt;BR /&gt;
An error is given if the type of variable x doesn't match the parameter's type. When you are initializing x[1][1] with "a b c" you match the types.&lt;BR /&gt;
The type check tries to make a general check independent of the parameters and input files, so it reports an error even if the current state of the file and the parameters would run without error. But it doesn't run the code, so the actual input doesn't happen, and it doesn't complain about the type mismatch at x[1][2].&lt;BR /&gt;
&lt;BR /&gt;
The missing array elements are missing because they don't match the type, and they aren't converted like in some other languages.</description>
    <pubDate>Wed, 28 Jul 2021 15:04:47 GMT</pubDate>
    <dc:creator>Peter Baksa</dc:creator>
    <dc:date>2021-07-28T15:04:47Z</dc:date>
    <item>
      <title>How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284669#M3464</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;AC22&lt;BR /&gt;I was trying to save text (numbers in text files are string type) to parameter. I've created parameter "x" - text array. Didn't change it, so x[1] = ""&lt;BR /&gt;&lt;BR /&gt;Master script
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;dim x[5][5]
for i=1 to 5
	for j=1 to 5
		x&lt;I&gt;=""
	next j
next i


ch=OPEN("text",”voda.txt”,"separator='\t', mode=ro, Library")
	iLine=1
	nr=INPUT(ch, iLine, 1, v1, v2, v3, v4, v5)
	WHILE nr&amp;gt;-1 DO	!just to limit, original text filex has &amp;gt;50 rows
			if nr then
				x[iLine][1] = v1
				x[iLine][2] = v2	
				x[iLine][3] = v3	
				x[iLine][4] = v4	
				x[iLine][5] = v5
			else
				add2 0, -1	!empty row
			endif
			iLine=iLine+1
			nr=INPUT(ch, iLine, 1, v1, v2, v3, v4, v5)
	ENDWHILE
CLOSE ch

for iLine=1 to 5
	for j=1 to 5
		text2 5*(j-1),1-iLine,x[iLine]
	next j
next iLine

x[1][1]="a b c"	!without it X_array stays empty; with it x[1][1] is overwritten and first column and row stays empty, BUT rest values are correct. why ?!!
parameters x=x
&lt;/I&gt;&lt;/PRE&gt;
but idk why "parameters x=x" has no effect. I mean when I check "x" parameter it remains empty (if comment x[1][1]='abc'). Because after closing reading the file text2 cycles show proper values in 2D view (without it I'd think that code is wrong and it even didn't read the file). So array should have correct values, I guess.
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;-----&amp;gt;”voda.txt”&amp;lt;---------
0	4	6	8	10
1	0,22	0,28	0,33	0,39
2	0,23	0,29	0,34	0,40
3	0,25	0,30	0,36	0,42
4	0,26	0,32	0,38	0,44
&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 06:59:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284669#M3464</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2021-09-14T06:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284670#M3465</link>
      <description>I think I know why. Because when text add-on reads txt file, it interpreters somehow zero as nothing. That means 0 in txt file will not be converted into '0' string but into ''.&lt;BR /&gt;
I faced to that problem several years ago (this why I don't remember all details of it). Was something like if I save 0 into txt - this value was skipped and in total I received less fields and couldn't read from txt these values back. The solution was to detect zero and record instead 'null'.</description>
      <pubDate>Thu, 15 Jul 2021 19:30:06 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284670#M3465</guid>
      <dc:creator>Podolsky</dc:creator>
      <dc:date>2021-07-15T19:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284671#M3466</link>
      <description>I'm afraid not Zero causes the problem. After editing text file (instead of 0  -&amp;gt; 10), nothing has changed. I still can't save all data, just part of it - without 1st column and row.&lt;BR /&gt;
For simplisity I've reduced size of text file to share here. The original one has [54][21]. And turns out if the text file has "0", array saves it indeed as empty string. If it has "0,00" array will has "0,00" also. In this case it's not a problem that array has some cells with empty strings, but that I can't save 1st column and 1st row. Of course, I can add redundant column and row to text file and I'll get data I want, but that's bad solution.</description>
      <pubDate>Fri, 16 Jul 2021 06:42:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284671#M3466</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2021-07-16T06:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284672#M3467</link>
      <description>What kind of types are "0,22", "0,28" etc. ? Are they strings or numbers?&lt;BR /&gt;
If they are numbers, they must be "0.22", "0.28", etc.</description>
      <pubDate>Fri, 16 Jul 2021 07:24:31 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284672#M3467</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2021-07-16T07:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284673#M3468</link>
      <description>Well, they should be numbers. But I assume for Add-on it's all strings, because it's text file. Though I haven't thought about how I'll convert them into numbers. This task would appear after I successfully save all data  &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_biggrin.gif" style="display : inline;" /&gt;</description>
      <pubDate>Fri, 16 Jul 2021 07:46:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284673#M3468</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2021-07-16T07:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284674#M3469</link>
      <description>another strange thing - if I put "print x[1][1]" at the end, I get warining "a b c". But all others cells of array are empty, at least print doensn't create warnings. Same as if I put  print"" (empty string). Thouth in parameter X,  I see other values. But print function doens't work or says other values are empty strings... &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_question.gif" style="display : inline;" /&gt;</description>
      <pubDate>Fri, 16 Jul 2021 08:01:21 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284674#M3469</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2021-07-16T08:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284675#M3470</link>
      <description>Strange that it's not working properly.&lt;BR /&gt;
Is it your first try of using txt Add-On?&lt;BR /&gt;
I wrote some tools based on txt database - and it actually worked. Several years on different platforms, computers and versions.&lt;BR /&gt;
&lt;BR /&gt;
Another question - what you shared here it's all you have got or just fragment of bigger object / system - anything you are developing? Maybe, if you are saving in txt only numbers, try to read them as numbers? Just set your x array as numbers. This is also annihilating the problem with zero, I mentioned before, because this problem exist only with string variables. In case of integer zero will be zero.</description>
      <pubDate>Fri, 16 Jul 2021 08:41:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284675#M3470</guid>
      <dc:creator>Podolsky</dc:creator>
      <dc:date>2021-07-16T08:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284676#M3471</link>
      <description>If ArchiCAD detects both strings and numbers in the text import, it stops the import.&lt;BR /&gt;
Please try the following: replace all fields with strings, e.g. #1 insted of 1.&lt;BR /&gt;
After the import you can split #1 to 1 again.&lt;BR /&gt;
For some reason the TEXT Addon cannot handle mixed Vartypes.</description>
      <pubDate>Fri, 16 Jul 2021 10:32:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284676#M3471</guid>
      <dc:creator>Jochen Suehlo</dc:creator>
      <dc:date>2021-07-16T10:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284677#M3472</link>
      <description>&lt;BLOCKQUOTE&gt;Podolsky wrote:&lt;BR /&gt;
Strange that it's not working properly.&lt;BR /&gt;
Is it your first try of using txt Add-On?&lt;BR /&gt;
I wrote some tools based on txt database - and it actually worked. Several years on different platforms, computers and versions.&lt;BR /&gt;
&lt;BR /&gt;
Another question - what you shared here it's all you have got or just fragment of bigger object / system - anything you are developing? Maybe, if you are saving in txt only numbers, try to read them as numbers? Just set your x array as numbers. This is also annihilating the problem with zero, I mentioned before, because this problem exist only with string variables. In case of integer zero will be zero.
&lt;/BLOCKQUOTE&gt;

It's my first try of text Add-On. So, unfortunately, it could be anything...  &lt;A href="https://drive.google.com/file/d/12JXjOtvu_wVPmhsaLosQNjVpPIAF5AiH/view?usp=sharing" target="_blank"&gt;here is 7z archieve&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Now I made 2 text files - one is original (with commas instead of dots) and another with dots. And I've created 2 different arrays: one has string values, other real numbers. And for some reason "trick" with overwritting first cell of array effecting only text array, not with numbers. Plus if you look at 2D view all numbers are zero - left side, big one, is string array (with different values) and right side is number array with zeroed values</description>
      <pubDate>Fri, 16 Jul 2021 11:20:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284677#M3472</guid>
      <dc:creator>A_ Smith</dc:creator>
      <dc:date>2021-07-16T11:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284678#M3473</link>
      <description>Not sure I understand your problem, but to me it seems to work: the object shows the values from the files and the arrays in settings as well. Tested:&lt;BR /&gt;
Win 10 AC23 7000 AUT&lt;BR /&gt;
Win 10 AC22 6021 AUT&lt;BR /&gt;
&lt;BR /&gt;
However I had also some problems with getting the input right: the add-on actually interprets numbers as numbers directly, you don't have to convert them. In order for this to work correctly, you have to set the variable right though, so:&lt;BR /&gt;
&lt;BR /&gt;
Text file: 123,1
&lt;PRE&gt;A = ""
nr=INPUT(ch, 1, 1, A)&lt;/PRE&gt;
causes weird issues, while&lt;BR /&gt;

&lt;PRE&gt;A =0
nr=INPUT(ch, 1, 1, A)&lt;/PRE&gt;
works.&lt;BR /&gt;
&lt;BR /&gt;
You can convert strings to numbers with the split command.</description>
      <pubDate>Fri, 23 Jul 2021 08:46:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284678#M3473</guid>
      <dc:creator>jan_filipec</dc:creator>
      <dc:date>2021-07-23T08:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to save an info from external text to a parameter?</title>
      <link>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284679#M3474</link>
      <description>It is a quite complex chain of GDL quirks that leads to this behaviour.&lt;BR /&gt;
&lt;BR /&gt;
The text add-on uses a fixed logic to determine the type of the variables it sets, disregarding what it was initialized to. If it looks like a number it is a number, otherwise a string. Decimal separators are . not , So in your file some entries will be read as numbers, some as strings.&lt;BR /&gt;
&lt;BR /&gt;
GDL array variables can hold mixed types (integer and string), but parameter arrays can't.&lt;BR /&gt;
It is quite possible to use a variable with the same name as a parameter. By writing dim x[][] you define a variable that shadows the parameter, not redefine the parameter.&lt;BR /&gt;
Using parameters x = x the variable x with mixed types is assigned to the parameter x.&lt;BR /&gt;
&lt;BR /&gt;
An error is given if the type of variable x doesn't match the parameter's type. When you are initializing x[1][1] with "a b c" you match the types.&lt;BR /&gt;
The type check tries to make a general check independent of the parameters and input files, so it reports an error even if the current state of the file and the parameters would run without error. But it doesn't run the code, so the actual input doesn't happen, and it doesn't complain about the type mismatch at x[1][2].&lt;BR /&gt;
&lt;BR /&gt;
The missing array elements are missing because they don't match the type, and they aren't converted like in some other languages.</description>
      <pubDate>Wed, 28 Jul 2021 15:04:47 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/How-to-save-an-info-from-external-text-to-a-parameter/m-p/284679#M3474</guid>
      <dc:creator>Peter Baksa</dc:creator>
      <dc:date>2021-07-28T15:04:47Z</dc:date>
    </item>
  </channel>
</rss>

