<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RGBA &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/rgba/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Fri, 09 Feb 2018 21:55:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Setting Constants</title>
		<link>https://blog.xojo.com/2018/02/12/setting-constants/</link>
		
		<dc:creator><![CDATA[Norman Palardy]]></dc:creator>
		<pubDate>Mon, 12 Feb 2018 07:30:43 +0000</pubDate>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Color]]></category>
		<category><![CDATA[Constant]]></category>
		<category><![CDATA[RGBA]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3869</guid>

					<description><![CDATA[A recent thread on the forums discussed why a particular bit of code would not compile he felt the error message seemed less than helpful: "CRghtColr As Color = Color.RGBA(000,061,255,208)". So, if you ever happen to see this, check to see that you are following the rules about what is allowed for the default value of a constant.]]></description>
										<content:encoded><![CDATA[<p>A <a href="https://forum.xojo.com/45837-bug-set-global-property-or-constant-to-rgba">recent thread</a> on the forums discussed why a particular bit of code would not compile he felt the error message seemed less than helpful: &#8220;CRghtColr As Color = Color.RGBA(000,061,255,208)&#8221;.</p>
<p><span id="more-3869"></span></p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-3870" src="https://blog.xojo.com/wp-content/uploads/2018/02/Screen-Shot-2018-02-03-at-4.15.25-PM.png" alt="" width="946" height="456" /></p>
<p>CRightColr is set up as a shared color property. And the person wanted the default value to be set from the Color.RGBA function. When you try this you get an error.</p>
<pre style="padding-left: 30px;">Window1.CRghtColr Declaration
Not enough arguments: got 0, expected 4.
Private Shared CRghtColr As Color = Color.RGBA(000, 061, 255, 208)</pre>
<p>It&#8217;s confusing as it&#8217;s not clear what requires more parameters. However, the <a href="http://developer.xojo.com/userguide/modules$adding-constants">User Guide</a> quite clearly states that <em>Constants can be assigned only a literal value, another constant value or the result of a constant expression.</em></p>
<p>A literal is easy &#8211; it&#8217;s something like &amp;cFF00FF00 &#8211; a color literal. A constant value would be assigning one constant to another. Say you had another constant:</p>
<pre style="padding-left: 30px;"> cColor as color = &amp;cffffff00</pre>
<p>You could then assign:</p>
<pre style="padding-left: 30px;">Private Shared CRghtColr As Color = cColor
</pre>
<p>And this would be fine.</p>
<p>A &#8220;constant expression&#8221; is a little less obvious here. It&#8217;s literally an expression made up only of constant values. This example should make it clearer:</p>
<pre style="padding-left: 30px;">Const constant1 as integer = 90
Const constant2 as integer = 100
Const constant3 as integer = constant1 + constant2 // constant1 + constant2 is a constant expression
</pre>
<p>Note that none of the allowable ways to set a constant include calling a function like Color.RGBA. Unfortunately while the compiler tries its best to make sense of what you&#8217;re trying to do, this one confuses it and you get this somewhat unhelpful error message.</p>
<p>So, if you ever happen to see this, check to see that you are following the rules about what is allowed for the default value of a constant.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
