<?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>RBDevZone &#187; Source Code</title>
	<atom:link href="http://www.rbdevzone.com/category/source-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rbdevzone.com</link>
	<description>The REALbasic Resource</description>
	<lastBuildDate>Wed, 14 Apr 2010 00:52:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>UltraUpdater 1.0 Now Available</title>
		<link>http://www.rbdevzone.com/2010/03/ultraupdater-1-0-now-available/</link>
		<comments>http://www.rbdevzone.com/2010/03/ultraupdater-1-0-now-available/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 19:50:14 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/?p=405</guid>
		<description><![CDATA[UltraUpdater adds auto-update capability to your REAL Studio applications with only 2 lines of code!
Check it out here:
http://www.rbdevzone.com/ultraupdater/
]]></description>
			<content:encoded><![CDATA[<p>UltraUpdater adds auto-update capability to your REAL Studio applications with only 2 lines of code!</p>
<p>Check it out here:</p>
<p><a href="http://www.rbdevzone.com/ultraupdater/">http://www.rbdevzone.com/ultraupdater/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2010/03/ultraupdater-1-0-now-available/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>OKCancel Control</title>
		<link>http://www.rbdevzone.com/2009/11/okcancel-control/</link>
		<comments>http://www.rbdevzone.com/2009/11/okcancel-control/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 18:18:14 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/?p=324</guid>
		<description><![CDATA[If you&#8217;re striving for a nice cross-platform UI, one of the things you need to consider is the placement of OK and Cancel buttons on your windows.
On Mac OS X, these buttons are in this order: Cancel, OK
On Windows and Linux, these buttons are: OK, Cancel
I&#8217;ve put together a quick control that handles this for [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re striving for a nice cross-platform UI, one of the things you need to consider is the placement of OK and Cancel buttons on your windows.</p>
<p>On Mac OS X, these buttons are in this order: Cancel, OK</p>
<p>On Windows and Linux, these buttons are: OK, Cancel</p>
<p>I&#8217;ve put together a quick control that handles this for you automatically.  However, it is a ContainerControl so you&#8217;ll need REALbasic Professional or REAL Studio to use it.</p>
<p>Download it here (documentation and the BSD license) are embedded as Notes in the control itself.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2009/11/OKCancelControl.rbp.zip" title="OKCancelControl.rbp.zip">OKCancelControl.rbp.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2009/11/okcancel-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CallByName Function</title>
		<link>http://www.rbdevzone.com/2009/09/callbyname-function/</link>
		<comments>http://www.rbdevzone.com/2009/09/callbyname-function/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 18:45:21 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Visual Basic]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[VisualBasic]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/?p=276</guid>
		<description><![CDATA[A post in the REAL Software forums asked if REALbasic has a CallByName function like VB has.  After reviewing my answer and the CallByName function in VB, I am presenting a more thorough solution here.
First, REALbasic does not have CallByName.  However, it does have Introspection (aka reflection) which can be used to achieve [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://forums.realsoftware.com/viewtopic.php?f=13&amp;t=29303">post</a> in the REAL Software forums asked if REALbasic has a CallByName function like VB has.  After reviewing my answer and the CallByName function in VB, I am presenting a more thorough solution here.</p>
<p>First, REALbasic does not have CallByName.  However, it does have Introspection (aka <a href="http://en.wikipedia.org/wiki/Reflection_(computer_science)">reflection</a>) which can be used to achieve this.</p>
<p>The official function definition in VB is:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">CallByName(<span style="color: #000080;">object</span> <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, procname <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, calltype <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, [args() <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>])</pre></div></div>

<p>This is a bit limited as it cannot handle return values.  I&#8217;d also prefer a more object-oriented syntax.  So our REALbasic definitions are:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Object</span>.CallByName(name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, <span style="color: #000080;">ParamArray</span> args <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>)
<span style="color: #000080;">Object</span>.CallByName(name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, <span style="color: #000080;">ParamArray</span> args <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span></pre></div></div>

<p>In order for this to be usable on any object, we&#8217;ll implement these as extension methods.  First we need to create a module to contain our methods.  Create a module called <strong>CallByNameExtension</strong>.  This self-contained module will eventually have everything we need to use CallByName in our projects.</p>
<p>Next, we need to create the CallType enumeration.  This is used to specify the type of the we want to call.  Our options are Method, PropertyGet and PropertySet.  On our module, create a CallType enumeration with those three values (Method, PropertyGet, PropertySet).</p>
<p>Now create our two method signatures for CallByName:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> CallByName(Extends obj <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, <span style="color: #000080;">ParamArray</span> args <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>)
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> CallByName(Extends obj <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, <span style="color: #000080;">ParamArray</span> args <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>Since both of these methods will actually use very similar code, we will create a private worker method to actually do the call.  Create a new private method:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Private</span> <span style="color: #000080;">Function</span> CallByNameWorker(obj <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, args() <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>Note that we&#8217;ve changed the ParamArray to just a simple array.  This is because we cannot resend the parameters as a ParamArray.</p>
<p>Let&#8217;s add the simple code to the public methods:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> CallByName(Extends obj <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, <span style="color: #000080;">ParamArray</span> args <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>)
&nbsp;
   <span style="color: #000080;">Call</span> CallByNameWorker(obj, name, nameType, args)
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> CallByName(Extends obj <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, <span style="color: #000080;">ParamArray</span> args <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
&nbsp;
  Return CallByNameWorker(obj, name, nameType, args)
&nbsp;
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>As you can see, this code simply calls the worker, saving the return value if appropriate.  Since ParamArrays are converted to real arrays, we can just pass that along to the worker as well.</p>
<p>In the worker method we&#8217;ll use Introspection to actually call the method or to get/set the value of the property.  Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Private</span> <span style="color: #000080;">Function</span> CallByNameWorker(obj <span style="color: #000080;">As</span> <span style="color: #000080;">Object</span>, name <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>, nameType <span style="color: #000080;">As</span> CallType, args() <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
  <span style="color: #000080;">If</span> obj &lt;&gt; Nil <span style="color: #000080;">Then</span>
&nbsp;
    <span style="color: #000080;">Dim</span> info <span style="color: #000080;">As</span> Introspection.TypeInfo
    info = Introspection.GetType(obj)
&nbsp;
    <span style="color: #000080;">Select</span> <span style="color: #000080;">Case</span> nameType
    <span style="color: #000080;">Case</span> CallType.Method
      // <span style="color: #000080;">Get</span> the names of all the methods <span style="color: #000080;">on</span> the <span style="color: #000080;">object</span>
      <span style="color: #000080;">Dim</span> methods() <span style="color: #000080;">As</span> Introspection.MethodInfo
      methods = info.GetMethods
&nbsp;
      // Search <span style="color: #000080;">for</span> the specified method
      <span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> m <span style="color: #000080;">As</span> Introspection.MethodInfo <span style="color: #000080;">In</span> methods
        <span style="color: #000080;">If</span> m.Name = name <span style="color: #000080;">Then</span>
          // We found it, so <span style="color: #000080;">call</span> it
          <span style="color: #000080;">Dim</span> rv <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
          rv = m.Invoke(obj, args)
&nbsp;
          Return rv
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
      <span style="color: #000080;">Next</span>
&nbsp;
    <span style="color: #000080;">Case</span> CallType.PropertyGet
      // <span style="color: #000080;">Get</span> the names of all the properties <span style="color: #000080;">on</span> the <span style="color: #000080;">object</span>
      <span style="color: #000080;">Dim</span> props() <span style="color: #000080;">as</span> Introspection.PropertyInfo
      props = info.GetProperties
&nbsp;
      // Search <span style="color: #000080;">for</span> the specified <span style="color: #000080;">property</span>
      <span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> p <span style="color: #000080;">As</span> Introspection.PropertyInfo <span style="color: #000080;">In</span> props
        <span style="color: #000080;">If</span> p.Name = name <span style="color: #000080;">Then</span>
          // We found it, so return its value
          <span style="color: #000080;">Dim</span> value <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
          value = p.Value(obj)
&nbsp;
          Return value
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
      <span style="color: #000080;">Next</span>
&nbsp;
    <span style="color: #000080;">Case</span> CallType.PropertySet
      // <span style="color: #000080;">Get</span> the names of all the properties <span style="color: #000080;">on</span> the <span style="color: #000080;">object</span>
      <span style="color: #000080;">Dim</span> props() <span style="color: #000080;">as</span> Introspection.PropertyInfo
      props = info.GetProperties
&nbsp;
      // Search <span style="color: #000080;">for</span> the specified <span style="color: #000080;">property</span>
      <span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> p <span style="color: #000080;">As</span> Introspection.PropertyInfo <span style="color: #000080;">In</span> props
        <span style="color: #000080;">If</span> p.Name = name <span style="color: #000080;">Then</span>
          // We found it so <span style="color: #000080;">set</span> its value <span style="color: #000080;">to</span> the first argument
          p.Value(obj) = args(0)
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
      <span style="color: #000080;">Next</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">Select</span>
&nbsp;
  <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
Exception e <span style="color: #000080;">As</span> RuntimeException
  <span style="color: #000080;">Dim</span> eInfo <span style="color: #000080;">As</span> Introspection.TypeInfo
  eInfo = Introspection.GetType(e)
&nbsp;
  <span style="color: #000080;">Dim</span> eMessage <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
  eMessage = <span style="color: #800000;">&quot;A &quot;</span> + eInfo.FullName + <span style="color: #800000;">&quot; occurred.&quot;</span>
  <span style="color: #000080;">If</span> e.Message &lt;&gt; <span style="color: #800000;">&quot;&quot;</span> <span style="color: #000080;">Then</span>
    eMessage = eMessage + EndOfLine + <span style="color: #800000;">&quot;Message: &quot;</span> + e.Message
  <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
  MsgBox(eMessage)
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>This code has one significant limitation when it comes to calling methods:  it cannot handle overloaded methods.  If you have multiple methods with the same name, but with different parameters, then this code will not always call the method you expect.  In order to fix this we would have to compare the types of each of the supplied arguments with the types of the arguments for each matching method and then call the one where everything matches.  This is all possible using Introspection, but I&#8217;ll leave it as an exercise for the reader.</p>
<p>Download the project with all the code: <a title="CallByName.rbp.zip" href="http://www.rbdevzone.com/wp-content/uploads/2009/09/CallByName.rbp.zip">CallByName.rbp.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2009/09/callbyname-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Guessing Game</title>
		<link>http://www.rbdevzone.com/2008/10/guessing-game/</link>
		<comments>http://www.rbdevzone.com/2008/10/guessing-game/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 01:03:52 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/10/guessing-game/</guid>
		<description><![CDATA[by Erick Tejkowski
Did you know that your computer can read minds? This week we&#8217;ll witness its extraordinary mind-reading powers by creating a simple REALbasic project. See if you can figure out how it works before looking at the code!

Downloads
Because the code for this demo is drop-dead simple, there isn&#8217;t really any reason to cover the [...]]]></description>
			<content:encoded><![CDATA[<p><cite>by Erick Tejkowski</cite></p>
<p>Did you know that your computer can read minds? This week we&#8217;ll witness its extraordinary mind-reading powers by creating a simple REALbasic project. See if you can figure out how it works before looking at the code!</p>
<div style="text-align:center;"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/10/04-25-03-img1.jpg" alt="04-25-03_img1.jpg" border="0" width="350" height="221" /></div>
<h2>Downloads</h2>
<p>Because the code for this demo is drop-dead simple, there isn&#8217;t really any reason to cover the process of putting an interface together. Check one of the previous tutorials if you are a complete REALbasic newbie. The fact is, this project doesn&#8217;t have any tricky code at all. The trick lies in the mathematical content of the application, not the code itself.</p>
<p>Download the <a href="http://www.rbdevzone.com/wp-content/uploads/2008/10/guessinggame.rbp.zip" title="GuessingGame.rbp.zip">Guessing Game</a> project.</p>
<p><cite>Originally published by ResExcellence Reprinted with permission</cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/10/guessing-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Spinner</title>
		<link>http://www.rbdevzone.com/2008/10/image-spinner/</link>
		<comments>http://www.rbdevzone.com/2008/10/image-spinner/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 00:37:06 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/10/image-spinner/</guid>
		<description><![CDATA[by Erick Tejkowski
One of the most frequently asked questions among REALbasic lists is &#8220;How do I rotate an image?&#8221; This project will show you how to quickly and easily rotate an image in realtime. The REALbasic Group2D class simplifies matters significantly for us. By dragging a few items to your interface and adding a bit [...]]]></description>
			<content:encoded><![CDATA[<p><cite>by Erick Tejkowski</cite></p>
<p>One of the most frequently asked questions among REALbasic lists is &#8220;How do I rotate an image?&#8221; This project will show you how to quickly and easily rotate an image in realtime. The REALbasic Group2D class simplifies matters significantly for us. By dragging a few items to your interface and adding a bit of code, you&#8217;ll be spinning in no time.</p>
<h2>Build the Interface</h2>
<p>Launch REALbasic and add a Canvas, a PushButton, and a Slider control to the Window1 interface. Set the maximum value of the slider to 6283. Since one complete rotation around a circle is approximately 6.283 radians, we&#8217;ll use the larger value of 6283 to insure fine resolution upon rotation. Next, click on the slider to select it and uncheck its Enabled property in the Properties window. Then, add an image file to your project. I snagged a photo of Michael Coyle, ResEx&#8217; own top dog. His image accompanies the source code download at the end of this tutorial. The final interface looks like this: </p>
<div style="text-align:center;"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/10/4-11-03-img1.jpg" alt="4-11-03_img1.jpg" border="0" width="212" height="311" /></div>
<h2>Add the Code</h2>
<p>Double-click PushButton1 and add the following code to its Action event.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">  <span style="color: #000080;">Dim</span> px <span style="color: #000080;">as</span> PixmapShape
  <span style="color: #000080;">Dim</span> p <span style="color: #000080;">as</span> Picture
&nbsp;
  px=<span style="color: #000080;">New</span> PixmapShape(coyle)
  p=<span style="color: #000080;">New</span> Picture(coyle.width,coyle.height,32)
  d=<span style="color: #000080;">New</span> Group2D
  d.<span style="color: #000080;">append</span>(px)
  Canvas1.Backdrop=p
  Canvas1.backdrop.Objects=d
  canvas1.Refresh 
  slider1.enabled = <span style="color: #000080;">True</span></pre></div></div>

<p>Next, add this code to the Paint event of Canvas1.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">  g.clearRect 0,0,me.width,me.height
  g.drawobject d,47,60</pre></div></div>

<p>With the Window1 code editor opened, create a new property of that window, by choosing Edit-New Property. Name the property like this:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">d <span style="color: #000080;">as</span> Group2D</pre></div></div>

<div style="text-align:center;"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/10/4-11-03-img2.jpg" alt="4-11-03_img2.jpg" border="0" width="209" height="306" /></div>
<h2>Conclusion</h2>
<p>Choose Debug-Run to see your work. By drawing an image using a Group2D object, you can a number of important image operations. The speed isn&#8217;t as fast as an RGBSurface, but for many tasks its perfectly suitable.</p>
<p>Download the <a href="http://www.rbdevzone.com/wp-content/uploads/2008/10/imagespinner.zip" title="ImageSpinner.zip">ImageSpinner</a> project.</p>
<p><cite>Originally published by ResExcellence Reprinted with permission</cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/10/image-spinner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RegCode now available at Google Code</title>
		<link>http://www.rbdevzone.com/2008/02/regcode-now-available-at-google-code/</link>
		<comments>http://www.rbdevzone.com/2008/02/regcode-now-available-at-google-code/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 03:19:04 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/02/regcode-now-available-at-google-code/</guid>
		<description><![CDATA[Not that anyone has ever submitted changes to RegCode, our open-source registration code generator, but I have greated a Google Code page for it:
regcode.googlecode.com
By using Google Code, RegCode is now in a nice Subversion repository, which anyone case download (if you&#8217;re interested in contributing, let me know and I&#8217;ll add you to the project so [...]]]></description>
			<content:encoded><![CDATA[<p>Not that anyone has ever submitted changes to RegCode, our open-source registration code generator, but I have greated a Google Code page for it:</p>
<p><a href="http://regcode.googlecode.com">regcode.googlecode.com</a></p>
<p>By using Google Code, RegCode is now in a nice Subversion repository, which anyone case download (if you&#8217;re interested in contributing, let me know and I&#8217;ll add you to the project so you can commit changes).  There&#8217;s also a wiki, which I&#8217;m using for documentation and a place to track issues.</p>
<p>Check it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/02/regcode-now-available-at-google-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating an Eval function using RBScript</title>
		<link>http://www.rbdevzone.com/2008/01/creating-an-eval-function-using-rbscript/</link>
		<comments>http://www.rbdevzone.com/2008/01/creating-an-eval-function-using-rbscript/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 01:52:47 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[RBScript]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/01/creating-an-eval-function-using-rbscript/</guid>
		<description><![CDATA[On the REAL Software forums, someone posted a question about Eval functionality in REALbasic.  In other languages, the Eval function is used to evaluate expressions.  REALbasic doesn&#8217;t have a direct equivalent, but it does have RBScript which allows you to write and run your own code within your REALbasic application.  With careful [...]]]></description>
			<content:encoded><![CDATA[<p>On the <a href="http://forums.realbasic.com/viewtopic.php?t=19431">REAL Software forums</a>, someone posted a question about Eval functionality in REALbasic.  In other languages, the Eval function is used to evaluate expressions.  REALbasic doesn&#8217;t have a direct equivalent, but it does have RBScript which allows you to write and run your own code within your REALbasic application.  With careful design, we can build our own implementation of Eval using RBScript, so let&#8217;s get started.</p>
<p>First, let&#8217;s understand what Eval does.  Essentially, it takes as input a string that contains an expression to evaluate.  Usage is like this: <strong>result = Eval(expression)</strong>.  For our purposes, we can return the result as a Variant.</p>
<p>In REALbasic, we&#8217;ll want a subclass of RBScript, so create a new class, which we&#8217;ll call <strong>Evaluator</strong>, and set its super to RBScript.  To this class, add a private property: <strong>mResult As Variant</strong>.  We&#8217;ll use this value to return the result of the evaluation.</p>
<p>Now add a new public method called Eval with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> Eval(expression <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>) Returns <span style="color: #000080;">Variant</span>
  <span style="color: #000080;">Dim</span> source <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
  source = <span style="color: #800000;">&quot;Dim expr As Variant = &quot;</span> + expression + EndOfLine + _
  <span style="color: #800000;">&quot;Print(expr)&quot;</span>
&nbsp;
  Self.Source = source
&nbsp;
  Self.Run
&nbsp;
  Return mResult
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>This code creates a simple line of REALbasic code that will parse the expression and runs this code using RBScript.  The result it output using the Print command which will call the <strong>Print</strong> event in the Evaluator class.  Speaking of which, add this code to the <strong>Print</strong> event:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">mResult = msg</pre></div></div>

<p>This will assign the value that was output with Print to the property we created so that we can return it.</p>
<p>That&#8217;s it.  Our Eval function is now ready to use.  To test it, create a Window with two EditFields (ExpressionField and ResultField) and a PushButton and add this code to the button&#8217;s Action event:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">  <span style="color: #000080;">Dim</span> result <span style="color: #000080;">As</span> <span style="color: #000080;">Variant</span>
&nbsp;
  <span style="color: #000080;">Dim</span> myEval <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> Evaluator
  result = myEval.Eval(ExpressionField.Text)
&nbsp;
  ResultField.Text = result.StringValue</pre></div></div>

<p><a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/evaluatorrbp.zip">Download Evaluator project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/01/creating-an-eval-function-using-rbscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CGS Private Functions</title>
		<link>http://www.rbdevzone.com/2008/01/cgs-private-functions/</link>
		<comments>http://www.rbdevzone.com/2008/01/cgs-private-functions/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 16:00:46 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/01/cgs-private-functions/</guid>
		<description><![CDATA[by Seth Willits
Mac OS X is full of private APIs available only to Apple to use in their own software and the operating system. Clever developers, much more knowledgeable than I, have been able to reverse engineer some of these APIs and do some neat things with them. I was fiddling with the CGSPrivate functions [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Seth Willits</em></p>
<p>Mac OS X is full of private APIs available only to Apple to use in their own software and the operating system. Clever developers, much more knowledgeable than I, have been able to reverse engineer some of these APIs and do some neat things with them. I was fiddling with the CGSPrivate functions that were made popuplar by a program called Desktop Manager which makes virtual desktops, and made a REALbasic module of (almost) all of the functions in that header as well as some others.</p>
<p>One of the neat things in this header are functions to transition the entire screen, like fast user switching does. I haven&#8217;t yet done anything useful with these methods, but I did write a tiny sample application that demonstrates these effects.<br />
<a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/fastuserswitching.png" title="FastUserSwitching"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/01/fastuserswitching.png" alt="FastUserSwitching" /></a><a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/window.jpg" title="CGSPrivate Window"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/01/window.jpg" alt="CGSPrivate Window" /></a></p>
<h2>Full Screen Effects</h2>
<p>The code below is pretty simple, and with a fair amount of work using more of the functions, you could do some wickedly cool stuff, like&#8230; a virtual desktop manager program made in REALbasic. <img src='http://www.rbdevzone.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> cid <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span> = _CGSDefaultConnection()<span style="color: #000080;">Dim</span> transNo <span style="color: #000080;">As</span> IntegerdimDim transSpec <span style="color: #000080;">As</span> CGSTransitionSpectransSpec.<span style="color: #000080;">Type</span> = CGSTransitionType(PopupMenu1.ListIndex + 1)
&nbsp;
transSpec.<span style="color: #000080;">Option</span> = CGSTransitionOption(PopupMenu2.ListIndex)
&nbsp;
transSpec.WindowID = 0 // Fullscreen
&nbsp;
transSpec.BackColorPtr = 0
&nbsp;
<span style="color: #000080;">Dim</span> err <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
&nbsp;
err = CGSNewTransition(cid, transSpec, transNo)
&nbsp;
err = CGSSetWorkspace(cid, 0)
&nbsp;
err = CGSInvokeTransition(cid, transNo, 0.5)
&nbsp;
CGSPrivate.Delay(0.5)
&nbsp;
err = CGSReleaseTransition(cid, transNo)</pre></div></div>

<p>Finished</p>
<p>Download <a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/cgsprivaterbp.zip" title="CGSPrivate Project">CGSPrivate Project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/01/cgs-private-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NumberField Control</title>
		<link>http://www.rbdevzone.com/2007/12/numberfield-control/</link>
		<comments>http://www.rbdevzone.com/2007/12/numberfield-control/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 17:22:10 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/12/numberfield-control/</guid>
		<description><![CDATA[NumberField is a subclass of EditField that allows the user to only type numbers.  To use it, import the NumberField.rbo control into your project and then drag it to a window (you&#8217;ll find it in the Project Controls section of the control list).  There is only one property, which you can modify in [...]]]></description>
			<content:encoded><![CDATA[<p>NumberField is a subclass of EditField that allows the user to only type numbers.  To use it, import the NumberField.rbo control into your project and then drag it to a window (you&#8217;ll find it in the Project Controls section of the control list).  There is only one property, which you can modify in the IDE Property Editor or in code:</p>
<p><strong>AllowDecimals As Boolean</strong>: Set to True (or check in the IDE) to allow decimal numbers to be entered.  Otherwise only integers can be entered.</p>
<p>This is a simple control, but I&#8217;ve found it useful from time-to-time.</p>
<p>Download <a title="NumberField Control" href="http://www.rbdevzone.com/wp-content/uploads/2007/12/numberfield.rbo">NumberField Control</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/12/numberfield-control/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Convert Microsoft BASIC Format Real Numbers to IEEE Format</title>
		<link>http://www.rbdevzone.com/2007/12/convert-microsoft-basic-format-real-numbers-to-ieee-format/</link>
		<comments>http://www.rbdevzone.com/2007/12/convert-microsoft-basic-format-real-numbers-to-ieee-format/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 17:15:44 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Math]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/12/convert-microsoft-basic-format-real-numbers-to-ieee-format/</guid>
		<description><![CDATA[A fellow REALbasic developer, Roger Oren, was kind enough to share this code to the REALbasic community.  This code is a REALbasic module that converts the Microsoft BASIC Format real numbers into IEEE format real numbers (and back).  It runs on all platforms.
Download Convert MS BASIC Format REAL Numbers to IEEE Format
]]></description>
			<content:encoded><![CDATA[<p>A fellow REALbasic developer, Roger Oren, was kind enough to share this code to the REALbasic community.  This code is a REALbasic module that converts the Microsoft BASIC Format real numbers into IEEE format real numbers (and back).  It runs on all platforms.</p>
<p>Download <a href="http://www.rbdevzone.com/wp-content/uploads/2007/12/rbf.rbo" title="Convert MS BASIC Format REAL Numbers to IEEE Format">Convert MS BASIC Format REAL Numbers to IEEE Format</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/12/convert-microsoft-basic-format-real-numbers-to-ieee-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
