<?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>Gray&#039;s blog &#187; quickbasic</title>
	<atom:link href="http://graysblog.org/tag/quickbasic/feed/" rel="self" type="application/rss+xml" />
	<link>http://graysblog.org</link>
	<description>Web Developer, Platform Coder, Coding Samurai, Person.</description>
	<lastBuildDate>Sat, 31 Jul 2010 08:54:29 +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>Writing webapps in QuickBasic 4.5</title>
		<link>http://graysblog.org/2010/02/27/writing-webapps-in-quickbasic-4-5/</link>
		<comments>http://graysblog.org/2010/02/27/writing-webapps-in-quickbasic-4-5/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 04:04:07 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[cgi-bin]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[qb]]></category>
		<category><![CDATA[qbasic]]></category>
		<category><![CDATA[quickbasic]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://graysblog.org/?p=260</guid>
		<description><![CDATA[Disclaimer: I realize this has no real valuable use whatsoever.
First off, credit where credit is due, when I initially had to setup the CGI I ran into a problem solved buy a guy on reddit, who managed to write a website clone in quickbasic. You have to do a simple C++ stub app that can [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>Disclaimer: I realize this has no real valuable use whatsoever.</em></strong></p>
<p>First off, credit where credit is due, when I initially had to setup the CGI I ran into a problem solved buy a guy on reddit, who managed to write a website clone in quickbasic. You have to do a simple C++ stub app that can direct the output from quickbasic apps into the server.</p>
<p>In order to pull this off, you&#8217;ll need a copy of the following tools:<br />
<strong>1.</strong> Dev C++ (For compiling the stub app, to make your life easier, grab the one with a compiler built into the install) <a href="http://www.bloodshed.net/devcpp.html">here</a></p>
<p><strong>2.</strong>Quickbasic 4.5 (capable of generating EXE files) <a href="http://www.phatcode.net/downloads.php?id=172">here</a></p>
<p>I also recommend xampp, very quick installation, works perfectly for this example. Grab it <a href="http://www.apachefriends.org/en/xampp.html">here</a></p>
<hr />
<p>Now, to actually install quickbasic from this zip on windows, you have to create a fake A drive, or copy the files to a floppy.</p>
<p>The trick to doing this is a command line trick called <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/subst.mspx?mfr=true">subst</a></p>
<p>So, copy the quickbasic disk1 folder from the download, place it in a folder on C: like, FLOPPY1 and run this:<br />
subst a: C:\FLOPPY1</p>
<p>Run the quickbasic setup app on the fake disk, when prompted to insert another disk, copy the contents of disk2 into the fake drive. Hopefully you&#8217;ll be able to run quickbasic now, and be greeted by this screen:</p>
<div id="attachment_261" class="wp-caption alignleft" style="width: 310px"><a href="http://graysblog.org/wp-content/uploads/2010/02/qb.png"><img class="size-medium wp-image-261" title="qb" src="http://graysblog.org/wp-content/uploads/2010/02/qb-300x155.png" alt="QuickBasic 4.5 welcome screen" width="300" height="155" /></a><p class="wp-caption-text">QuickBasic 4.5 welcome screen</p></div>
<p>Once your in quickbasic, navigate the menus with ALT or your mouse, type out this simple program:</p>
<div class="codesnip-container" >PRINT &#8220;Content-Type: text/html&#8221;<br />
PRINT &#8220;&#8221;<br />
PRINT &#8220;&#8221;</div>
<div class="codesnip-container" >PRINT &#8220;</div>
<div class="codesnip-container" >&lt;h1&gt;Hello World!&lt;/h1&gt;</div>
<div class="codesnip-container" >&#8221;<br />
PRINT &#8220;&#8221;</div>
<p>Move over to the run menu and hit make EXE file, save your app. The app will be in the saved file directory, take it, rename it something simple (e.g. &#8216;app.exe&#8217;) and close.</p>
<p>Now, open up dev C++, navigate to File-&gt;New-&gt;Project and select console application, select C++ for the language, copy and paste this code into main.cpp:</p>
<div class="codesnip-container" >#include &lt;iostream&gt;<br />
#include &lt;string&gt;<br />
#include &lt;stdio.h&gt;<br />
int main(int argc, char *argv[])<br />
{<br />
std::string piper;<br />
FILE* data = popen(&#8220;app.exe&#8221;,&#8221;r&#8221;);</p>
<p>for(char c = getc(data);c != EOF;c = getc(data))<br />
{<br />
piper.push_back(c);<br />
}<br />
pclose(data);</p></div>
<div class="codesnip-container" >std::cout &lt;&lt; piper;<br />
return 0;<br />
}</div>
<p>Press ctrl+F9 to compile or select compile from the menu. Open the directory where you saved the project, and copy the generated EXE file over to your cgi-bin directory (in htdocs for apache, with xampp it&#8217;s in the root directory of xampp/cgi-bin).</p>
<p>Now, with the stub in cgi-bin, rename your compiled quickbasic app to &#8216;app.exe&#8217;, and copy it to cgi-bin. Navigate to <a href="http://localhost/cgi-bin/stub.exe">http://localhost/cgi-bin/stub.exe</a> where stub.exe is whatever your compiled C++ application is called, you should now see a screen something like this:</p>
<div id="attachment_263" class="wp-caption alignleft" style="width: 310px"><a href="http://graysblog.org/wp-content/uploads/2010/02/helloworld.png"><img class="size-medium wp-image-263" title="hello world" src="http://graysblog.org/wp-content/uploads/2010/02/helloworld-300x107.png" alt="hello world from quickbasic" width="300" height="107" /></a><p class="wp-caption-text">hello world from quickbasic</p></div>
<p>Now you can run your webapps and display output in the browser, all you need now is to parse CGI variables, which is done via the ENVIRON$ function.</p>
<div class="codesnip-container" >PRINT &#8220;Content-Type: text/html&#8221;<br />
PRINT &#8220;&#8221;<br />
PRINT &#8220;&#8221;<br />
PRINT &#8220;</div>
<div class="codesnip-container" >&lt;h1&gt;Hello World!&lt;/h1&gt;</div>
<div class="codesnip-container" >&#8221;<br />
PRINT ENVIRON$(&#8220;QUERY_STRING&#8221;)<br />
PRINT &#8220;&#8221;</div>
<p>QUERY_STRING is set by the CGI gateway, accessing this page with a url like http://localhost/cgi-bin/qload.exe?bla would print:<br />
&#8220;Hello World! bla&#8221;</p>
<p>This has no real practical use anymore, but it&#8217;s just interesting to try out. Also, sorry about the code blocks here being screwed up, wordpress managed to mangle them.</p>
]]></content:encoded>
			<wfw:commentRss>http://graysblog.org/2010/02/27/writing-webapps-in-quickbasic-4-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
