<?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>The curse of Dennis D. Spreen &#187; Delphi 2009</title>
	<atom:link href="http://www.spreendigital.de/blog/category/delphi/delphi-2009/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.spreendigital.de/blog</link>
	<description>A blog about Delphi programming, web and other technical stuff</description>
	<lastBuildDate>Fri, 26 Mar 2010 08:35:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lua 5.1 for Delphi 2010</title>
		<link>http://www.spreendigital.de/blog/2009/09/28/lua-5-1-for-delphi-2010/</link>
		<comments>http://www.spreendigital.de/blog/2009/09/28/lua-5-1-for-delphi-2010/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 18:36:18 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi 2009]]></category>
		<category><![CDATA[Delphi 2010]]></category>
		<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[Lua]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=375</guid>
		<description><![CDATA[This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback functions.

&#8220;Lua is a powerful, fast, lightweight, embeddable scripting language, it has been used in many industrial applications (e.g., Adobe&#8217;s Photoshop Lightroom), with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games [...]]]></description>
			<content:encoded><![CDATA[<p>This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback functions.<br />
<span id="more-375"></span><a href="http://www.lua.org/about.html" target="_blank"><br />
<em>&#8220;Lua</em></a><em> is a powerful, fast, lightweight, embeddable scripting language, it has been used in many industrial applications (e.g., Adobe&#8217;s Photoshop Lightroom), with an emphasis on embedded systems (e.g., the Ginga middleware for digital TV in Brazil) and games (e.g., World of Warcraft). Lua is currently the leading scripting language in games and it has a deserved reputation for performance. To claim to be &#8220;as fast as Lua&#8221; is an aspiration of other scripting languages.&#8221;</em></p>
<p>This Lua Wrapper is based on Lua-Pascal v0.2 by <a href="http://www.marcoabreu.eti.br" target="_blank">Marco Antonio Abreu</a><br />
- converted PChar to PAnsiChar<br />
- converted Char to AnsiChar<br />
- added function LuaLibLoaded: Boolean;<br />
- added a new base class (TLua) with OOP call back functions</p>
<p><strong>Download</strong><br />
<a href="http://www.spreendigital.de/blog/wp-content/uploads/2009/09/LuaDelphi2010-v1.2.zip"></a><a href="http://www.spreendigital.de/blog/wp-content/uploads/2009/10/LuaDelphi2010-v1.3.zip">LuaDelphi2010-v1.3</a></p>
<p><strong>History</strong><br />
1.3 Improved Callback, now uses pointer instead of object index. Modified RegisterFunctions to allow methods from other class to be registered, moved object table into TLua class<br />
1.2  Added example on how to extend lua with a delphi dll<br />
1.1  Improved global object table, optimized delphi function calls<br />
1.0  Initial Release</p>
<p><strong>Example</strong><br />
TLua automatically creates OOP callback functions for Delphi &lt;-&gt; Lua:</p>

<div class="wp_syntax"><div class="code"><pre class="delphi" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">uses</span>
  Lua<span style="color: #000066;">,</span> LuaLib<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">type</span>
  TMyLua <span style="color: #000066;">=</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #000066;">&#40;</span>TLua<span style="color: #000066;">&#41;</span>
  <span style="color: #000000; font-weight: bold;">published</span>
    <span style="color: #000000; font-weight: bold;">function</span> HelloWorld<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">:</span> TLuaState<span style="color: #000066;">&#41;</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> TMyLua<span style="color: #000066;">.</span><span style="color: #006600;">HelloWorld</span><span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">var</span>
  ArgCount<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">Integer</span><span style="color: #000066;">;</span>
  I<span style="color: #000066;">:</span> <span style="color: #000066; font-weight: bold;">integer</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">begin</span>
  <span style="color: #000066;">writeln</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Delphi: Hello World'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  ArgCount <span style="color: #000066;">:</span><span style="color: #000066;">=</span> Lua_GetTop<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000066;">writeln</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Arguments: '</span><span style="color: #000066;">,</span> ArgCount<span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  <span style="color: #000000; font-weight: bold;">for</span> I <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">1</span> <span style="color: #000000; font-weight: bold;">to</span> ArgCount <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000066;">writeln</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Arg1'</span><span style="color: #000066;">,</span> I<span style="color: #000066;">,</span> <span style="color: #ff0000;">': '</span><span style="color: #000066;">,</span> Lua_ToInteger<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> I<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Clear stack</span>
  Lua_Pop<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> Lua_GetTop<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">&#41;</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;">// Push return values</span>
  Lua_PushInteger<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> <span style="color: #0000ff;">101</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Lua_PushInteger<span style="color: #000066;">&#40;</span>LuaState<span style="color: #000066;">,</span> <span style="color: #0000ff;">102</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  Result <span style="color: #000066;">:</span><span style="color: #000066;">=</span> <span style="color: #0000ff;">2</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span>
  MyLua<span style="color: #000066;">:</span> TLua<span style="color: #000066;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">begin</span>
  MyLua <span style="color: #000066;">:</span><span style="color: #000066;">=</span> TMyLua<span style="color: #000066;">.</span><span style="color: #006600;">Create</span><span style="color: #000066;">;</span>
  MyLua<span style="color: #000066;">.</span><span style="color: #006600;">DoFile</span><span style="color: #000066;">&#40;</span><span style="color: #ff0000;">'Helloworld.lua'</span><span style="color: #000066;">&#41;</span><span style="color: #000066;">;</span>
  MyLua<span style="color: #000066;">.</span><span style="color: #006600;">Free</span><span style="color: #000066;">;</span>
<span style="color: #000000; font-weight: bold;">end</span><span style="color: #000066;">;</span></pre></div></div>

<p><em>helloworld.lua</em></p>

<div class="wp_syntax"><div class="code"><pre class="lua" style="font-family:monospace;"><span style="color: #b1b100;">print</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;LuaDelphi Test&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
p1,p2 <span style="color: #66cc66;">=</span> HelloWorld<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #b1b100;">print</span> <span style="color: #ff0000;">&quot;Results:&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #66cc66;">&#40;</span>p1<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #66cc66;">&#40;</span>p2<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2009/09/28/lua-5-1-for-delphi-2010/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Unicode in Resource files</title>
		<link>http://www.spreendigital.de/blog/2008/10/14/unicode-in-resource-files/</link>
		<comments>http://www.spreendigital.de/blog/2008/10/14/unicode-in-resource-files/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 15:20:22 +0000</pubDate>
		<dc:creator>Dennis Spreen</dc:creator>
				<category><![CDATA[Delphi 2009]]></category>
		<category><![CDATA[Delphi Programming]]></category>
		<category><![CDATA[Resource]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[Unicode]]></category>

		<guid isPermaLink="false">http://www.spreendigital.de/blog/?p=79</guid>
		<description><![CDATA[Ever tried to put a unicode string (Delphi 2009) in a resource (.rc) file and tried to compile it with brcc32 or rc32?
You&#8217;ll get this error:  Expecting resource name or resource type name
The Solution is very simple (though it kept me searching some hours  :

Use
cgrc.exe
(CodeGear Resource Compiler/Binder) instead!
]]></description>
			<content:encoded><![CDATA[<p>Ever tried to put a unicode string (Delphi 2009) in a resource (.rc) file and tried to compile it with brcc32 or rc32?</p>
<p>You&#8217;ll get this error:  Expecting resource name or resource type name</p>
<p>The Solution is very simple (though it kept me searching some hours <img src='http://www.spreendigital.de/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> :</p>
<p><span id="more-79"></span></p>
<p>Use</p>
<p><code>cgrc.exe</code></p>
<p>(CodeGear Resource Compiler/Binder) instead!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spreendigital.de/blog/2008/10/14/unicode-in-resource-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
