<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Initialization of string in REXLANG]]></title><description><![CDATA[<p dir="auto">I got this warning in the Compiler Window but everything is working fine :</p>
<pre><code>"Warning compiling file 'WasteSrcfile.c' (line 30): variable 'stringTemp' is used without initialization"
</code></pre>
<p dir="auto">The initialization was one like this :</p>
<pre><code>char stringTemp[80];
</code></pre>
<p dir="auto">Something like this, to initialize an empty string will not work :</p>
<pre><code>char stringTemp[80] = "";
</code></pre>
]]></description><link>https://forum.rexygen.com/topic/236/initialization-of-string-in-rexlang</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 20:48:41 GMT</lastBuildDate><atom:link href="https://forum.rexygen.com/topic/236.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 14 Apr 2021 14:00:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Initialization of string in REXLANG on Thu, 15 Apr 2021 08:30:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.rexygen.com/uid/133">@reitinge</a> I did try this before but then I can't even compile due to an error.</p>
<p dir="auto"><img src="/assets/uploads/files/1618474468139-23345552-af28-4c1c-b9d1-6a4c22f5c625-image.png" alt="23345552-af28-4c1c-b9d1-6a4c22f5c625-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">But apparently it was because I did the initialization of this string inside the main routine.<br />
Bizarre that it is throwing a warning for the string 'stringTemp' and not for the long variable 'index'.<br />
Both are only used inside the main routine.</p>
<p dir="auto">This is the complete code which is now running without a warning :</p>
<pre><code>//assigning inputs to variables, these variables are READ-ONLY
double input(0) inputGLAS; 
double input(1) inputGFT; 
double input(2) inputPMD;
double input(3) inputRA;
double input(4) inputTEXT;
double input(5) inputP_K;



//assigning variables to outputs, these variables are WRITE-ONLY
string output(0) stringOUT; //value to send to y0 output
char stringTemp[80];



//the init procedure is executed once when the REXLANG function block initializes
long init(void)
{
	
	return 0;
}

//the main procedure is executed repeatedly (once in each sampling period)
long main(void)
{
	
	
	long index = 0;
	
	//char stringTemp[80];
        stringTemp="";

	strcat(stringTemp,"Vergeet+niet+volgend+vuilnis+buiten+te+zetten+:+");
	
	if (inputGLAS!=0)
	{
		strcat(stringTemp,"Glas");
		index=index+1;
	}
	
	if (inputGFT!=0)
	{
		if (index!=0)
		{
			strcat(stringTemp,",+");
		}
		strcat(stringTemp,"GFT");
		index=index+1;
	}
	
	if (inputPMD!=0)
	{
		if (index!=0)
		{
			strcat(stringTemp,",+");
		}
		strcat(stringTemp,"PMD");
		index=index+1;
	}
	
	if (inputRA!=0)
	{
		if (index!=0)
		{
			strcat(stringTemp,",+");
		}
		strcat(stringTemp,"Restafval");
		index=index+1;
	}
	
	if (inputTEXT!=0)
	{
		if (index!=0)
		{
			strcat(stringTemp,",+");
		}
		strcat(stringTemp,"Textiel");
		index=index+1;
	}
	
	if (inputP_K!=0)
	{
		if (index!=0)
		{
			strcat(stringTemp,",+");
		}
		strcat(stringTemp,"Papier+en+Karton");
	}
	

	stringOUT=stringTemp;
	return 0;
}

//the exit procedure is executed once when the task is correctly terminated
// (system shutdown, downloading new control algorithm, etc.)
long exit(void)
{
	/* PUT YOUR CODE HERE */
	return 0;
}
</code></pre>
]]></description><link>https://forum.rexygen.com/post/942</link><guid isPermaLink="true">https://forum.rexygen.com/post/942</guid><dc:creator><![CDATA[Scoobsalamander]]></dc:creator><pubDate>Thu, 15 Apr 2021 08:30:40 GMT</pubDate></item><item><title><![CDATA[Reply to Initialization of string in REXLANG on Wed, 14 Apr 2021 15:42:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.rexygen.com/uid/12">@scoobsalamander</a><br />
Hi, you can divide the initialization into two commands:</p>
<pre><code>char stringTemp[80];
stringTemp = "";
</code></pre>
<p dir="auto">if you want to be sure that the array is empty. The warning will disappear.</p>
<p dir="auto">Cheers,<br />
Jan</p>
]]></description><link>https://forum.rexygen.com/post/941</link><guid isPermaLink="true">https://forum.rexygen.com/post/941</guid><dc:creator><![CDATA[reitinge]]></dc:creator><pubDate>Wed, 14 Apr 2021 15:42:34 GMT</pubDate></item></channel></rss>