<?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: Database output into Parameters in Libraries &amp; objects</title>
    <link>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292917#M5740</link>
    <description>Hi Matt,&lt;BR /&gt;
sometimes the data types are different&lt;BR /&gt;
VARTYPE(expression) will identify the variable type&lt;BR /&gt;
1 for number, 2 for string&lt;BR /&gt;
&lt;BR /&gt;
I use this to trouble shoot at early stages of coding, plus text2 outputs to make sure the read process works before going to the next stage.&lt;BR /&gt;
&lt;BR /&gt;
(assuming param1 is a number, param2 is a number, paramN is text)&lt;BR /&gt;
note, if the input record is only numbers and a single decimal point, it gets turned into a number, if it contains other characters, it changes to text.&lt;BR /&gt;
using a text file in the loaded library called textfileA.txt&lt;BR /&gt;
i.e. &lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Open Channel&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
ch3 = OPEN ("text", "textfileA.txt","SEPARATOR = '\t', MODE = RO, LIBRARY")&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Read and Assign Values to Temp Variables&lt;BR /&gt;
! CHECKINPUT is the number of records retrived&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
CHECKINPUT = INPUT (ch3, 0, 0, param_1, param_2, param_N)&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Check Variables in 2d output&lt;BR /&gt;
! Can remove this stage after it works&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
IF CHECKINPUT &amp;gt; 0 THEN&lt;BR /&gt;
   text2 0,0, param_1&lt;BR /&gt;
   text2 0,1, VARTYPE(param_1)&lt;BR /&gt;
ENDIF&lt;BR /&gt;
&lt;BR /&gt;
IF CHECKINPUT &amp;gt; 1 THEN&lt;BR /&gt;
      text2 1,0, param_2&lt;BR /&gt;
      text2 1,1, VARTYPE(param_2)&lt;BR /&gt;
ENDIF&lt;BR /&gt;
&lt;BR /&gt;
IF CHECKINPUT &amp;gt; 2 THEN&lt;BR /&gt;
         text2 2,0, param_N&lt;BR /&gt;
         text2 2,1, VARTYPE(param_N)&lt;BR /&gt;
ENDIF&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Close Channel&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
close ch3 &lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Checks Temp Variables are correct type&lt;BR /&gt;
! and assigns temp variable to Parameters&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
if VARTYPE(param_1) = 1 and CHECKINPUT &amp;gt; 0 then !for a number&lt;BR /&gt;
	a = param_1&lt;BR /&gt;
	param1 = param_1&lt;BR /&gt;
	parameters a = param_1&lt;BR /&gt;
   parameters param1 = param_1&lt;BR /&gt;
endif&lt;BR /&gt;
&lt;BR /&gt;
if VARTYPE(param_2) = 1 and CHECKINPUT &amp;gt; 1 then !for a number&lt;BR /&gt;
	b = param_2&lt;BR /&gt;
	param2 = param_2&lt;BR /&gt;
	parameters b = param_2&lt;BR /&gt;
   parameters param2 = param_2&lt;BR /&gt;
endif&lt;BR /&gt;
&lt;BR /&gt;
if VARTYPE(param_N) =  2 and CHECKINPUT &amp;gt; 2 then !for text&lt;BR /&gt;
	paramN = param_N&lt;BR /&gt;
   parameters paramN = param_N&lt;BR /&gt;
endif&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Can remove this stage after it works&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
text2 0,2, param1&lt;BR /&gt;
&lt;BR /&gt;
text2 1,2, param2&lt;BR /&gt;
&lt;BR /&gt;
text2 2,2, paramN&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! End of Variable assigning&lt;BR /&gt;
! ------------------------------------------</description>
    <pubDate>Fri, 23 Jun 2017 05:50:20 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-06-23T05:50:20Z</dc:date>
    <item>
      <title>Database output into Parameters</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292916#M5739</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;&lt;R&gt;Hi,&lt;BR /&gt;
&lt;BR /&gt;
The problem I have encountered is how to pull multiple variables from a database AND modify the user-defined Parameters of the receiving object, let's call them param1, param2 and paramN. This should happen automatically without user action, so I figured that Master script would be the place to place it. Normally, I'd do that in Parameter script.&lt;BR /&gt;
&lt;BR /&gt;
After I have succesfully opened a channel and defined my input fields
&lt;PRE&gt;INPUT (channel, 0, 0, param1, param2, paramN)&lt;/PRE&gt;
I'm trying to do the following:
&lt;PRE&gt;parameters param1 = param1, param2 = param2, paramN = paramN&lt;/PRE&gt;

After I modify the source .txt file and reload libraries, "something" happens, namely param1 is successfully updated and the value changed; however, it ends with param1. &lt;BR /&gt;
&lt;A href="http://gdl.graphisoft.com/reference-guide/the-parameter-script" target="_blank"&gt;Here&lt;/A&gt; the manual says
&lt;BLOCKQUOTE&gt;"If the parameter is a value list, the value chosen will be either an existing value, the custom value, or the first value from the value list."&lt;/BLOCKQUOTE&gt;
Not sure if this applies to my situation. Do I need to try to modify them one-by one in some sort of a loop? What's the best approach?&lt;BR /&gt;
&lt;BR /&gt;
Thank you!&lt;/R&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 23 Jun 2017 02:06:58 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292916#M5739</guid>
      <dc:creator>matjashka</dc:creator>
      <dc:date>2017-06-23T02:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: Database output into Parameters</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292917#M5740</link>
      <description>Hi Matt,&lt;BR /&gt;
sometimes the data types are different&lt;BR /&gt;
VARTYPE(expression) will identify the variable type&lt;BR /&gt;
1 for number, 2 for string&lt;BR /&gt;
&lt;BR /&gt;
I use this to trouble shoot at early stages of coding, plus text2 outputs to make sure the read process works before going to the next stage.&lt;BR /&gt;
&lt;BR /&gt;
(assuming param1 is a number, param2 is a number, paramN is text)&lt;BR /&gt;
note, if the input record is only numbers and a single decimal point, it gets turned into a number, if it contains other characters, it changes to text.&lt;BR /&gt;
using a text file in the loaded library called textfileA.txt&lt;BR /&gt;
i.e. &lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Open Channel&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
ch3 = OPEN ("text", "textfileA.txt","SEPARATOR = '\t', MODE = RO, LIBRARY")&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Read and Assign Values to Temp Variables&lt;BR /&gt;
! CHECKINPUT is the number of records retrived&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
CHECKINPUT = INPUT (ch3, 0, 0, param_1, param_2, param_N)&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Check Variables in 2d output&lt;BR /&gt;
! Can remove this stage after it works&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
IF CHECKINPUT &amp;gt; 0 THEN&lt;BR /&gt;
   text2 0,0, param_1&lt;BR /&gt;
   text2 0,1, VARTYPE(param_1)&lt;BR /&gt;
ENDIF&lt;BR /&gt;
&lt;BR /&gt;
IF CHECKINPUT &amp;gt; 1 THEN&lt;BR /&gt;
      text2 1,0, param_2&lt;BR /&gt;
      text2 1,1, VARTYPE(param_2)&lt;BR /&gt;
ENDIF&lt;BR /&gt;
&lt;BR /&gt;
IF CHECKINPUT &amp;gt; 2 THEN&lt;BR /&gt;
         text2 2,0, param_N&lt;BR /&gt;
         text2 2,1, VARTYPE(param_N)&lt;BR /&gt;
ENDIF&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Close Channel&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
close ch3 &lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Checks Temp Variables are correct type&lt;BR /&gt;
! and assigns temp variable to Parameters&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
if VARTYPE(param_1) = 1 and CHECKINPUT &amp;gt; 0 then !for a number&lt;BR /&gt;
	a = param_1&lt;BR /&gt;
	param1 = param_1&lt;BR /&gt;
	parameters a = param_1&lt;BR /&gt;
   parameters param1 = param_1&lt;BR /&gt;
endif&lt;BR /&gt;
&lt;BR /&gt;
if VARTYPE(param_2) = 1 and CHECKINPUT &amp;gt; 1 then !for a number&lt;BR /&gt;
	b = param_2&lt;BR /&gt;
	param2 = param_2&lt;BR /&gt;
	parameters b = param_2&lt;BR /&gt;
   parameters param2 = param_2&lt;BR /&gt;
endif&lt;BR /&gt;
&lt;BR /&gt;
if VARTYPE(param_N) =  2 and CHECKINPUT &amp;gt; 2 then !for text&lt;BR /&gt;
	paramN = param_N&lt;BR /&gt;
   parameters paramN = param_N&lt;BR /&gt;
endif&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! Can remove this stage after it works&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
text2 0,2, param1&lt;BR /&gt;
&lt;BR /&gt;
text2 1,2, param2&lt;BR /&gt;
&lt;BR /&gt;
text2 2,2, paramN&lt;BR /&gt;
&lt;BR /&gt;
! ------------------------------------------&lt;BR /&gt;
! End of Variable assigning&lt;BR /&gt;
! ------------------------------------------</description>
      <pubDate>Fri, 23 Jun 2017 05:50:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292917#M5740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-23T05:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Database output into Parameters</title>
      <link>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292918#M5741</link>
      <description>Thanks much, mate!&lt;BR /&gt;
&lt;BR /&gt;
Your response helped me fix it. Turns out, I skipped one variable from the list and the script got confused. I used the text2 object to list the variables and they seemed to be interpreted correctly as Numeric vs String. Because I needed to input almost 20 different parameters, I stuffed them in an array and called out later.&lt;BR /&gt;
NOTE that the script below does NOT check if variable type is Numeric vs String. If that were the case, I'd have to have an additional array to check against.&lt;BR /&gt;
&lt;BR /&gt;
This is what I placed in the Master script and it's executed in case the object is on the "receiving end" of things (a child type of instance):
&lt;PRE&gt;_numSettings = 19 !this must correspond with the amount of variables received
dim _recvdSettings[]

_dataSource2 = open("text", settingsFile, "separator='\n', mode=ro, Library")

for r=1 to _numSettings step 1
	_readValues = input(_dataSource2, r, 1, _param)
	_recvdSettings&lt;R&gt; = _param
next r

parameters 	rbegin = _recvdSettings[1],
			rstop = _recvdSettings[2],
			naListing = _recvdSettings[3],
(...)
			col3wd = _recvdSettings[18],
			rowh = _recvdSettings[19]
rbegin = _recvdSettings[1]
rstop = _recvdSettings[2]
naListing = _recvdSettings[3]
(...)
col3wd = _recvdSettings[18]
rowh = _recvdSettings[19]

close _dataSource2&lt;/R&gt;&lt;/PRE&gt;
Best regards</description>
      <pubDate>Fri, 23 Jun 2017 19:13:09 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Libraries-objects/Database-output-into-Parameters/m-p/292918#M5741</guid>
      <dc:creator>matjashka</dc:creator>
      <dc:date>2017-06-23T19:13:09Z</dc:date>
    </item>
  </channel>
</rss>

