# QB Express

### Issue #5 ~ December 30, 2004

"A magazine by the QB community, for the QB community!"

### In This Issue

Contributors

- Pete (Editor)
- Adigun A. Polack
- Piptol
- Joe King
- 19day
- Angelo Mottola
- Pyrodap
- Marinedalek
- Matthew R. Knight
- VonGodric
- Jan van de Poll
- Jocke The Beast
- Oz
- Wallace
- SJ Zero
- Michael Summers

- Regular Columns
  - From The Editor's Desk
  - Letters
  - Express Poll
  - News Briefs
  - Gallery - Inspiration
  - Blast From The Past! - QB Top Sites Lists
  - Competition - Text Map Game
  - Final Word
- Articles & Editorials
  - QBCPC 2004/2005 Has Been Extended - Adigun A. Polack
  - Joe's Pointless Points - Joe King
  - Piptol Meets... Angelo Mottola - Piptol
  - DOS Emulation Follow-Up - Pete
  - Coding, the way it was MEANT to be - Oz
  - Roguelike Games - Jocke The Beast
  - New QBTK MEGA-RPG Compo - Pyrodap
  - BASIC Goes Mobile - Matthew R. Knight
- Tutorials
  - Useful Math For QBasic / FreeBasic - Marinedalek
  - Improving the PDS7.1 Error Handler - Jan van de Poll
  - PHP Series, Part One - 19day
  - GUI Programming Part Two: Textboxes - VonGodric

## From The Editor's Desk

### Written by Pete

Well hello again all you QBers out there... or should I say FBers? Looking around the QB community, I can honestly say that the QB side of things has just about died since FreeBasic came along last month. I mean, there wasn't much going on QB-wise before that, but once FB hit the scene, there has been an explosion of activity the likes of which I haven't seen in five or six years from this crowd. For once, people are excited about programming again -- they're starting new games by the dozens, teaming up for projects, designing new libraries and apps, experimenting with code and a whole lot more -- and I think that's phenomenal. V1ctor deserves all the credit in the world for completely rejuvenating the QB scene.

But can we even call it the QB scene anymore? I've known for quite some time that most of the people who hang out at QB sites don't actually program in QB anymore. They're all former QB programmers who have moved on to bigger things. I recall there was a thread over at the QB45 forum a while back where someone asked how many people actually still program in QBasic. Out of about fifteen people that replied, only about two said they still used QB. Some of the former QB hubs that were once the center of the community have completely drifted away from being about QB -- NeoBasic and #quickbasic on Efnet come to mind, and QB45 seems to be on the way out too. I consider myself to be a hardcore QBer, visiting the major QB sites just about every day to check on the latest developments...but I haven't actually sat down and programmed a significant QB program since about 2000. Now it's 2005. That's five years. And I'm only 19.

So who exactly is this magazine for? Well, it's for the "QB community" (that's what it says in the tagline, at least), and the "QB community" is a far larger group than "QB programmers" these days. Just today, Nekrophidius posted this on the QBasic News forum -- and I agree with him wholeheartedly: "The Qmunity will always be the Qmunity, even after we've laid QB itself to its long-deserved eternal rest. The language or compiler we use is irrelevant...the people are what really matter." So I've decided to take steps to make this magazine more directed to what the Qmunity -- people that frequent QB forums and read this magazine, but don't necessarily actually program QB anymore -- want. And that's FreeBasic.

Starting with this issue, QB Express is a QBasic, QuickBasic and FreeBasic magazine. But that's not all. We will also dabble in other programming languages if people are interested. For instance, this month we debut 19day's new series on PHP programming, which has nothing to do with QB, but I'm sure "QBers" will find that tutorial more useful than most other tutorials on miscellaneous QB techniques. We also have an article by Matthew R. Knight on a new dialect of BASIC for cell phones called Mobile BASIC. Is it about QB? No. Does it appeal to the QB community? You betcha. Limiting ourselves to just outdated QB and DOS is stupid. It's time to branch out.

> The Pete's QBasic Site monthly poll question for August 15th, 1999 to September 15th, 1999 was "Will the QBASIC community still be around in five years?" These are the results. In a way, both answers are right: the QB community is still around, but the number of active QB programmers is dwindling severely. This definitely ain't the same community as it was in August of 1999. But nevertheless, five and a half years later, we're still hangin' in there. Who knows what another five years will bring.

Otherwise this month, we've got a whole slew of cool new articles for you to check out. There are some comedic articles, tutorials, information on competitions, random opinion pieces and a whole lot more. But instead of relisting them all here, I'll just let you check them out for yourself. Enjoy!

### Submit To QB Express

You all know the drill. This magazine can't exist without people SUBMITTING articles, editorials, tutorials, reviews, news and feedback. This is not just a solo effort by me... it's a group effort by people throughout the QB community. If you have anything to submit, or have time to write something, DO IT!

If you want to write about something, but can't think of a topic, or need inspiration, email me! I'm good at thinking of stuff to write about, and I know quite a bit about the QB community and about QB programming. If you're interested in getting your own monthly column or just want to write an article or two, by all means, do it! Anything that is submitted will be included!

Anyway, here's what I'm especially interested in for the next issue:

- FreeBasic tutorials
- Tutorials on elements of game design, both theory and technical
- Interviews with famous QBers
- Game reviews of both QB and FB games
- QB history articles
- Exclusive news items about upcoming QB and FB projects
- And just about anything else

I also want feedback and letters to the editor regarding this magazine. I want suggestions and critiques. What do you like? What don't you like? What could be done better? Let me know!

All submissions and feedback can be sent to pberg1@gmail.com. You can also PM me on the Pete's QB Site or QBasic News message forums. Additionally, you can fill out this form to contact me if you'd prefer not to use email or PMs. If QB Express is going to continue to be so good, YOU need to contribute!

-Pete

## Letters

I didn't really get any full letters this month that would be appropriate to print, so I decided to take some of the more interesting short bits of feedback I got from people after the last issue and compile them into a single letter. That's below. But for the next issue, I expect EVERYONE to send me nice long letters with all kinds of ideas, complaints, compliments, rants and raves. So when you're done reading this issue, fill me in on what you loved, what you hated, and any ideas you might have for the next issue.

### Letter From ...Everyone

MystikShadows

  Well you definitaly outdid yourself. Just when I think QB Express #3 would be a classic, unbeatable, here you arrive with mind blowing issue that literally threw me right out of my house...pillows and all.

  I've learned alot in this issue, as I always seem to...My QB past wasn't in games, so I've been learning about games, tiles, RPGs, engines, script languages you name it. 2D, 3D and the list goes on and on...and all that from QB Express mostly. Gave me the motivation to learn what was written and search the web for more of the these.

  All this to say, Pete, you da man.....I've heard, from other issues, that QB needs magazines like yours, and as I read them all, as they are made available, I can't help but agree with them 100%.

  QB Express ROCKS!!!

  Big hand of applause for all involved.

Nekrophidius

  Pure awesomeness, as usual.

Adigun A. Polack

  On the overall content of many of the articles — including as well the one about the impressions of QuickBASIC being tested under DOSBox on such different platforms as Mac-OS and Linux — I *must* agree with Adosorken on what he has just said, which wrote..........

  "Pure awesomeness, as usual."

  Hey, even after your motherboard got fried out of shape and all (I am so terribly sorry on that little incident happening! ), you just had to overcome that difficult problem in order to bring out this next QB Express, and so I can truly understand the pain that you went through, man. And now that issue #4 is finally here, I must say that you have really outdone yourself this time, even in conquering that stumbling block indeed, too!!! !

  My very, VERY big congratulations and commendations to you for unleashing the true courage in you to bring out this issue to make it the biggest one there ever is so far, Pete!!! Be seeing you once again! =b

Neo

  Wow!

  I'm glad you were able to fix your computer Pete!

  And as always, this issue really is masterful! The QB Express is great! I really liked all those tuts by Relsoft and the news, as well as the interviews!

  Keep on the good work!

Piptol

  *Two thumbs up*

  Pete, when I'm a rich business tycoon I guarantee you a job as my PR/Marketing Director (paying top $$$) Anyone who can capture the imagination and motivate the likes of us like you can deserves a medal.

DarkDread

  That was a good read.

Z!re

  Really nice, I've read over it like 5 times, and i still have stuff to read.

dark_prevail

  Heh, my favorite part was the interview with Nathan.

  I love the way the "rant" part was the longest. True. ;D

Lachie Dazdarian

  Once again, a great issue. But I did dislike the lack of a game review. I think one per issue should be something regular.

  I think you should start whipping your reviewers.

Svante Ekholm

  Printing QB Express issues...

  God damnit, it's over 70 pages! You're killing my printer!

  :D!

> Well thanks a lot guys for all the positive feedback, I really appreciate it! I can tell you guys really liked the interviews Piptol did (I liked 'em a lot too), as well as the features on the DOS emulation. Because of all the demand, both of those features are back in this issue.

> But what I'm especially interested in is the CRITICISM. I'm glad at least Lachie mentioned the lack of a review in the last issue. Issues #2 and #3 both had game reviews, but I couldn't find someone to review games for the fourth issue. And then once again this month nobody stepped up the plate. I think that reviews are one of the most important aspects of this magazine, and it's essential that we have at least one per month. I don't have the time to write reviews and do all the editing and management stuff, plus write my own articles every month, so it's up to YOU readers to volunteer for this. It's no coincidence that the fall of the main QB reviews sites like V Planet! and GBGames coincided with the QB community's biggest slump in program releases ever. We need reviewers! Email me if you're at all interested and I'll get you started.

> -Pete

Have a letter for the editor? Send all your rants, raves, ideas, comments and questions to pberg1@gmail.com.

## Express Poll

Every issue, QB Express holds a poll to see what QBers are thinking. The poll is located on the front page of Pete's QBasic Site, so that's where you go to vote. Make sure your voice is heard!

### Have you programmed in FreeBasic yet?

Answer | Votes | Percent | Graph
Yes | 8 | 42% |
No | 11 | 58% |
19 Total Votes

> It's truly amazing how fast FreeBasic has caught on. In little over a month, V1ctor's little compiler has truly taken the QB world by storm. Already, forty-two percent of the people polled at my site have tried their hand at FreeBasic, and it's only been out since November 30th. Absolutley incredible. There's more life and energy in the "upgraded" QB community right now than there has been in four or five years, and judging by what the new FreeBasic community has already put out, that energy's not going to be dying down anytime soon.

## News Briefs

News from all around the QB community, about the latest games, site updates, program releases and more!

### QB Site News

QBChat Makes a Comeback
  QB Chat, the javascript-based chat client that has been shared among QB sites such as V Planet!, QBasic.com, the old Future Software and Pete's QBasic Site for years, has recently made a bit of a comeback. on December 1st, Badjas posted at several major QB sites to encourage them to link to the shared chat java applet to help breath some life into the chatroom. Since then, QBasic News and QB45 have both added links to QB Chat on their main pages. Now that there are no real mIRC channels that still deal with QB programming, QB Chat seems like the last refuge of real QBasic chat on the internet. QB Webmasters: add the Javascript code for QB Chat onto your site somewhere and help spread the word. You can find it in Badjas's post. And if you'd like to visit QB Chat, just click right here!
Nebula Software Updates With 3 Features
  On January 9th, Nebula Software added three new articles:

  > Descriptions of the articles:
  > - Quake Renderer is a BSP-PVS engine that renders real QUAKE maps. Blitz succeed to code an engine that's capable of drawing hundreds of polygons with an acceptable framerate.
  > - 3D Jack's Game is actually a series of shooters, all starring the demoncratic Al Snore. And Al Snore has his own way of solving political problems...
  > - Somehow, Angelo Mottola and Petter Holmberg succeed to dose information about their Project RT in a way that it attracted everybody's attention for a very long period.

  I, for one, am especially glad to see this update because it means that at least SOMEONE is doing reviews of QB games these days, even if they come out fairly sparsely. The article on Project RT was neat too, especially since QB Express has an exclusive interview with Project RT developer Angelo Mottola this month, and he answers some questions about this great raycasting engine that QB coders are just starting to crack.
Santy Worm Gets Pete's QBasic Site
  On December 21st, Pete's QB Site was hacked by the rogue Santy Worm which uses a security exploit in older versions of the popular PHPBB message forum to take sites out of commission. The worm, which spread through Google, turns all PHP and HTML pages on a server into a text message saying "THIS SITE HAS BEEN DEFACED!!!" Luckily, I had a complete backup of the site on my hard drive and was able to restore the site within a matter of hours. I also upgraded to the latest version of PHPBB to prevent future attacks. Of course, before everyone figured out what happened to my site, myself and many other visitors were convinced that petesqbsite.com was taken down by some lame hacker. I overreacted a bit until I learned about the Santy Worm and found out that my site wasn't specifically targeted. Anyway, if your site runs PHPBB and you don't have the latest version, I would suggest upgrading IMMEDIATELY.
GBGames Has Moved
  Pigeon's GBGames QB reviews site has had a minor change of address: it has recently moved to http://qbasic.gbgames.com from www.gbgames.com. This is because Pigeon plans to develop GBGames.com into a shareware games business. So everyone: make sure you update those links and bookmarks!
JacobPalm.Dk Browser Compatibility Issues Resolved
  Last month, we announced the launch of a new QB site at JacobPalm.dk, but complained that the site didn't load in popular browser Mozilla FireFox. Well, Jacob Palm quickly resolved the issue, posting the following over at QBasic News: "I've set up a temporary solution for the Firefox problem. Visitors can now press a link at the front page to go to a page which users frames instead of the javascript menu. I've also installed Firefox on my computer and will test JacobPalm.dk with it to assure compitability with Firefox."
More On The New QBXL Issue
  The new issue of QB Accelerator, SJ Zero's hilarious QB mag is still in development. Since we reported on the upcoming issue last month, we've found out that the magazine will have some chill FreeBasic content. SJ Zero posted: "The next issue of qbxl (which is nearly complete, believe it or not!) will have a couple articles on FreeBASIC. It's those articles keeping the release of the mag." I also stumbled across a cool posting at the QBXL.net message board about SJ's possible plans for the mag: "I'm contemplating a new idea: QBXL, full of democracy! Here's how it would work: Our editors would submit vague ideas for articles, and readers would vote on the ones they'd like to see written. The ones which are chosen by the readership would show up." I really like that idea. I have no idea if it will ever be implemented, but it's pretty neat. Maybe QB Express could do something like that sometime.
QuickHost2 Beta Opened
  QuickHost, the popular temporary file webhost that is used by much of the QB community for temporary storage, has had a major update. On December 4th, Quickhost developer SumoJo announced the new version of the website, which has a host of new features including: Automatically thumbnailed images, Flash movies/games play in quickhost, Txt documents show as real text, All code supported by GeSHi is shown and highlighted automatically, Photo/File Album (for registered users), Forum and Zip Previews (directory structure and files).
  The length of time that files are hosted has also been upped to 90 days, with renewal capabilities. Anyone that used QuickHost in the past will most certainly welcome the new upgrades, and hey, maybe they'll even attract hordes of new users. Spiffy.
Los Monos del Obús Launches Website
  Taken directly from their news posting:

  > Los Monos del Obús, a text adventure game design group with members aetherFox and na_th_an, recently opened. You can check out the website at http://obus.qbxl.net.
  > The next planned project, The Quest for Opa Opa, is planned to release very soon, in time for the TAC04.
  > Keep check for almost fdaily updates, development information and a forum.
  > aetherFox,
  > Los Monos del Obús

### Project News

Syn9's 3D Engine In Motion
  Recently, Syn9 released a new demo and video of his 3D engine that is pretty impressive. The 3-minute, 43-second video shows your character walking on a path through rocky cliffs and several medieval-looking towns. Though the textures are low-quality, the graphics are very nice looking from a distance, as you can see in the screenshot to the right. Syn9's demo, which we announced last month, was written in QB with the UGL library, and depends on EMS memory to run. (A lot of people have had problems getting this program to run in Windows XP or DOS emulators, unfortunately.) Anyway, I suggest you check out the video as well as the QBasic News topic where you can see a map of the path traveled in the video.
Dadsherm's Projects 1-2-3
  Recently, Dadsherm posted at the QBasic News forum about three QB projects he's got in development: a Solar Calendar, a business statistics program and barcode scanning program for retail outlets. He's looking for people to help him develop these applications, so if you're at all interested, drop him a PM.
Acalypha Source Released
  This month, VGameSoft finally released the source code for their *mucho impressivo* Zelda-style RPG, Acalypha. This game was the talk of the town back in 2002 when it was still in development, but since then, VGameSoft has dissolved. In October, the group officially declared itself "dead". Luckily, though, group-leader Sane didn't forget that there are still quite a few up-and-coming coders who might find the Acalypha source code to be a valuable learning tool. The source code was released as "an early Christmas present" on the group's now-defunct website. According to Sane, the VGameSoft website is still up "merely for those who are interested in our old files or just a piece of QB history (don't give me that look :)". Anyway, if you're interested in RPG programming, or want to learn how to use DirectQB, I suggest you get the Acalypha code while it's hot!
Nekrophidius Releases Advance.PUT - PUT to BMP Conversion utility
  Nekrophidius's handy application that changes PUT images to BMP images usable outside of QB was released recently. Here's what he posted on the Pete's QB Site forum a few weeks ago:

  > Okay...this was brewing over in the freeBASIC forum...since most everyone's probably going to be moving on to FB once it's widely available, and since there's very little in the way of a PUT to BMP converter, I spent today developing this. It's a first release, so it might have a few bugs in it, but other than the documented one (which I can't squash right now, and it's not even all that big a deal), it should work without fail. It will load PUT files of any size, including multiple image PUTs with different sized images. It will also load PAL and APF files, as long as they're PAL1024 format. I'll add the other palette formats later on, as well as other features I have in mind. Advance.PUT did this with bounce.put from PP256:
  > Anyways, I've released it now to the public, so feel free to check it out.

  This will most certainly be useful to people who are working to port their old QB games to FreeBasic in the upcoming months. You can get ahold of Advance.PUT at these links: complete installer, or just the minimal archive for people who already have the Visual Studio runtimes that this program requires.
Alternate Dementions Development's New GUI Quicklibraries
  Kurt Kuzba of Alternate Dementions Development just today released a demo of his new GUI program for QB. Written in Microsoft Quick C specifically for QuickBasic 4.5, these Quicklibraries will make it easy for someone to incorporate GUI features into their program, similar to the stuff VonGodric's teaching in his GUi tutorial series for QB Express. ADDGUIQB is currently just a .exe demo, but according to Kurt, he'll be uploading the .LIB and .QLB in "a bit", as well as the source and .obj files too. You can see the textbox, menu and scrollbar functions in the screenshot to the left. To download this program, go to this site and click the ADDGUIQB link.

### Competition News

QBXL.Net 24 Hour FreeBasic Compo Coming Right Up!
  SJ Zero recently announced a 24-hour FreeBasic coding competition that will take place on January 2nd...if you're keeping track, that's like two days away! Here's the post SJ Zero made on the QB45 message board:

  > From January 2, 8AM to January 3, 8AM, in your own timezone, pick up the latest copy of FreeBASIC, fire up your favourite IDE, and make that language sing! For 24 hours you can make any kind of game you want, using any artwork or music, but the code must all be original.
  > To enter, just say hi over at the forum.qbxl.net forums on January 2nd, and keep us all posted.
  > The official chatroom for this event is #qbxlcontest on irc.efnet.net.
  > Hope to see you then!

Two New Compos At QBTK
  Over at QBasic.tk, Pyrodap has been quite busy organizing some cool QB coding contests. The first one he organized was a weeklong compo to design an ascii-based platform engine:

  > Okay, I'll start off the weekly compo, just to get us rolling. The goal for this compo is to make an ascii-based platform engine! Now, if you want to make a whole game then be my guest, but for this compo all that's required is a character to be able to jump around a bit and achieve some goal. The goal can be just to get to a certain location on the map or find an item, avoid an enemy (NPCs aren't required) or anything you want. Simple right?

  Three entries were received for this compo -- by Na_th_an, Nixon and Pyrodap. Although the contest has not been officially called yet, it's pretty clear that Na_th_an will be the winner. You can see his cool entry in the screenshot to the above right.
  QBTK's other competition is the MEGA-RPG COMPO, but Pyrodap was kind enough to submit an entire article about this that you can check out right here.
Text Adventure Compo '04 Kicks Off... And Supposedly Ends
  Nekrophidius' annual Text Adventure Competition started on January 1st, was set to last for one month -- meaning that it ends today. However, I haven't seen any postings about it actually ending, or much attention other than the fact that both Nekrophidius and Na_th_an are entering. Na_th_an's entry is a game called Quest for Opa Opa. Anyway, the official site for TAC 2004 is here and you can find the official announcement of the compo here.

### FreeBasic News

There are about a million little FreeBasic news stories going on in the Qmunity right now, and I'm only one man. So I'm sure I missed a lot of stuff. Furthermore, I've been working on this magazine now for about 8 hours straight and I'm bored to tears... so I'm just gonna make a bulleted list of these stories. If you wanna complain, go screw yourself.

- FreeBASIC 0.01 Beta Released on November 30th -- 8 more versions since then: V1ctor released the first publicly available version of the open-source 32-bit QB syntax-compatible BASIC compiler on November 30th. Since then, he has released several more updated beta versions, the latest Version 0.09b was released on December 30th. You can download FreeBasic at the official site: http://fbc.sourceforge.net/..
- FreeBASIC Official Sites Open Up: But you probably already guessed that from the last news item. Anyway, there are two versions of the site -- FreeBasic.net, and the SourceForge mirror.
- Freebasic.tk launches: FreeBasic.tk was launched on December 13th. This site was created by the original team behind QBasic.tk . It has downloads as well as a thriving message forum.
- AAP Official Projects Squad Updates: Adigun A. Polack's new "FreeBasic Graphics Demo Central" had two major updates since the last issue, now with a grand total of 23 FB graphics demos. Also, his QBCPC 2004/2005 competition has been extended to allow FreeBasic entries. You can read more about that in his article this month.
- FreeBasic Ports of QB Projects: This thread is pretty interesting -- Barok asked if anyone is porting their old QB games to FB, and he got quite a few responses. Z!re's rewriting MOo in FB, Dr_Davenstein said "Every QB program I've ever made is now an FB project", Barok is porting his own RPG engine over, Nekrophidius said "I'm porting The Wrath Of Sona, RGB, Rise Of The Lich, Two Lords (eventually), and possibly even Distant Promises to FB", and Zap said he's ported an ascii graphics game to FB.
- Nekrophidius's FreeBasic GUI Compiler: Nek's working on GUI stuff for QB. Check this thread for current information and this thread for "very early gui stuff". Both include screenshots.
- Ryan Begins 'Jocke Attack' Text Adventure: Ryan is making a funny text adventure about Jocke The Beast called 'Jocke Attack'. It's interesting, to say the least. Check it out.
- FreeBasic IDE by VonGodric: VonGodric is designing a spiffy IDE for FreeBasic that will certainly make the compiler a whole lot more userfriendly to use. Check this thread for details.
- Pyrodap's IsoRPG: Pyrodap's restarting his isometric RPG called "IsoRPG" in FreeBasic, and it sounds really promising. This thread has information and a screenshot.
- The FreeBasic Forum and Examples/Previews Quicklist: Wildcard has been maintaining a useful list of most of the early FreeBasic demos that were released. Check it out!
- Nek's FreeBASIC Page: Nekrophidius launched his own FreeBasic site just the other day. It's at: http://fb.nodtveidt.net/
- FreeBasicX Launched: Seph, Barok and TheBigBasicQ launched a site called FreeBasicX at freebasic.w00tish.com. This site is fairily barebones at the moment, but it's going to have tutorials, downloads, reviews, a forum and all kinds of other FreeBasic stuff. Worth a look!
- And a whole lot more! The hub of the FB community is the QBasic News FreeBasic Forums. This is where you kind find out about just about everything that's going on in the FB scene.

Have news to submit? Email it, or fill out this form!

## Gallery

### Written by Pete

Every issue QB Express features a preview and exciting new screenshots from an upcoming QB game. If you would like your game featured, send in some screenshots!

### Inspiration

December has been an extremely quiet month for the QBasic end of the QB community, with so few program releases that I can count the ones I know of with the fingers of one hand. (Meanwhile, the FreeBasic scene has been booming...but that's another story.)

Anyway, the most active QB developer this month has undisputedly been Wallace of Wallace Software, who has released a new engine demo of his upcoming first person shooter Inspiration and posted news about several updates on the project on the Wallace Software homepage. This new Inspiration engine will be the basis for Wallace's Contact 2 FPS, which is a sequel to his recent Contact first person shooter. Though Inspiration is still currently in "pre-alpha condition", it's coming along quite nicely.

Take a look at some of the latest screenshots:

> Inspiration will feature high-quality animated textures. Need proof? Take a look at those vending machines -- I can almost make out the Kit-Kats and Hershey's Bar wrappers.

I asked Wallace to give me a quick run-down of what he has in mind for this FPS engine, and here's what he had to say:

> Inspiration will be used to create Contact 2 and any FPS that I create after that. The reason behind building the engine was to have an outline of functions to use in any game, instead of hardcoding a lot of it like in Contact.

> The Inspiration engine is essentially a raycaster with more eyecandy. The non-orthogonal walls [see the screenshot to the right] are achieved by placing "patches" in the screen similarly to how sprites will be placed. This function is currently under development. The whole thing is designed to have high resolution graphics and to create the most realistic looking world possible. To add realism Inspiration will have a floor and cieling bumpmapping system to allow raised areas. The AI is going to be run using scripts that can be loaded, so that different enemies act differently and how they behave can be changed as the difficulty level changes.

> The story in Contact 2 is Spartica (the same super-soldier as Contact) is sent out on a mission to re-take a government facility that has been taken over by The Deconan. The facility houses a weapon that can wipe large areas clean of Deconan while leaving all other life essentially unharmed. Of course there are some plot twists and surprises that I'd not want to give away.

Wallace has big plans for the Inspiration engine once it's finished. Not only will Contact 2 be based on this engine, but he also plans on remaking the original Contact: "while Contact was very good, the Inspiration engine would move it up from good to top-of-the-line." Also he plans on making another game with the engine called Inferno, which will be "a walk through Dante's version of hell, you will fight demons and try to escape as you examine your own soul."

I asked Wallace what his timeframe was for finishing these projects, and told me the following: "Inspiration I hope to have finished by May, Contact 2 about a month later. Inspiration will become open source 10 days after Contact 2 comes out." Sounds good to me! Maybe once the Inspiration engine is open source there will be a whole lot more games released with Wallace's cool raycasting routines. If you'd like more information about Wallace's projects, check his websites (below), or send him an email.

Visit Wallace Software of the official Contact 2 site.

## The QBCPC 2004/2005 has now been extended in a MAJOR way!!

### Written by Adigun Azikiwe Polack

Konnichiwa!!! Recently during the month of December 2004, the QuickBASIC Caliber Programming Compo 2004/2005 has turned into the Extend Edition already! Yep, you heard me. That means, it has now became the first OFFICAL compo ever to have full entire support for projects that are created using either the new Windows-based FreeBasic, QuickBASIC, MS-DOS QBasic, and Visual Basic 1.0 DOS (or VBDOS), with the deadlines extended a bit again, too! And that is just *only* the beginning of something rather big now. Strap on tight!!

R.C. Pro Am, straight outta 1987.

As I clearly have promised from issue #4 of QB Express, I have just now added an all-new and VERY EXCLUSIVE Spotlight Category based on your favorite and greatest NES game from 1987, R.C. Pro Am!! You can check it out in all of its raw and uncompromised glory right here. Plus, the requirements for most of the categories have changed and revised a bit to be much more fair to what I am talking about within this new article.

With all of that, plus all of the other uncharted originalities in FB/QB/VBDOS just waiting with such untamed anticipation to be explored at once in my current compo, there is *never* even a dull moment now, so get on up and START WINNING BIG-TIME in this programming gala today, if you can!! =b ! The now-updated Official Entry Rules are found here, and be sure to agree to them all before entering this important programming event, alright?

God bless all of you, and I am definitely looking real forward to seeing you enter and create your hottest winning game/project!!! !

> WITH MY GREATEST ENCOURAGEMENT TO YOU IN THIS,
> Adigun Azikiwe Polack
> Official Founder of the QuickBASIC Caliber Programming Compo 2004/2005
> (http://dhost.hopto.org/aapproj/qbcpc/)

## "Text Map Game" Competition Results

### Organized by Pete

Two-and-a-half months ago, QB Express challenged QB coders to make a text-based game where players move an ASCII smiley face character around a map made out of text. By the time the initial deadline came (November 10th), I had received only one entry: Ryan Szrama's The Numbervold. Since there was quite a bit of interest for this competition, I decided to run the competiton for another month, extending the deadline first until December 25th, and then again until today. Finally in the wee hours of the morning today I received a second entry: 1st Encounter by Thomas Nixon of a relatively-new QB coding group that actually specializes in text games, Pure Text. Now let's take a look at the entries!

Below you'll find the competiton rules, and below that, information and brief reviews of both entries. Then, after that, the results.

### The Challenge

This challenge was to create a text-based game using only one "map" made entirely out of text. The game had to have a character (represented by the DOS smily face character) that players move around with the arrow keys. Everything else was up to the programmer.

A screenshot of Dark Woods 2 by Jocke The Beast, a game using ASCII graphics and a smily face as your character.

This challenge was inspired by one of my personal favorite QB games of all time, Virtual Pimp. This game was made by Mike Kristopeit and Eric Boudreau, and uses a very simple text-based interface. It is a crime-based RPG, reminiscent of Grand Theft Auto and all those economy simulating games like Drug Wars. It's got very addictive gameplay, and a lot of cool random events that keep things interesting. Your game doesn't have to be anything like this; the only thing it has to have in common is that you play as a smily face on a text-based map. Other games that have used text graphics in a similar style are: Jocke The Beast's Dark Woods 2, Lost 2 by Groovy Concepts, P.R.O.G.U.E. by Dunric.

In Issue #4 of QB Express, I posted several screenshots of text-based games for inspiration and answers to questions I received about this competition. There was also some discussion about this competition on the official competition message board thread at my site.

Here is a complete listing of the rules for this competition:

> #### Rules

> - Your character must be the standard DOS smily face character. (CHR$(1), I believe.) He or she must be moved around with the four arrow keys.
> - Your game map / environment must be text-based, and consist of only one screen. No scrolling screens or walking into a "building" that is on another map.
> - Your map may adjust based on user input, but it can not change completely. For example, you can have your character pick up items, shoot bullets, interact with other characters that move around the map, open doors, push walls, etc. -- but you can't, for example, have your character push a switch and have everything on the map change. That would mean you're loading a second map.
> - Your game may be of any genre -- RPG, puzzle, shooter, strategy, dating game, etc.
> - Your graphics must be entirely text-based. Absolutely nothing but text. (You may use as much colored text as you want.)
> - You can use any screen mode you would like.

### Contest Entries

We had two entries for this competition:

- "The Numbervold" by Ryan Szrama
- "1st Encounter" by Thomas Nixon

### The Numbervold

Ryan Szrama's entry for the Text Map Game competition is The Numbervold, a neat RPG. This was the only entry to come in during the original month-long entry period for this competition, and he has already released it to the public. Jocke The Beast and Wildcard helped promote it on QBasic News a few weeks ago, and you can find out a bit more about it on Jocke The Beast's message board.

Here's The Numbervold's story, straight from the manual:

> The Numbervold is a wild, harsh frontier area inhabited by only a few people and many monsters. Even the land itself is known for its mirages and illusions that have led travellers off course for days at a time. It's almost always impossible to tell just how for you travel across the deceiving terrain.

> A single village sits in the Numbervold, inhabited by adventurers, a few shopkeepers, and more than a few loonies. The village is constantly plagued by monsters springing up out of lairs that just seem to appear in the Numbervold. As such, the Elder is always looking for some brave young bravo to purge the countryside of the foul monsters and their dens. Work is never scarce in the Numbervold, as you adventure as one such bravo. Gain glory, prestige, and most important of all, gold, as you fight for bounties and for your life in the Numbervold!

Having played The Numbervold quite a bit, I have to say that it's a pretty neat game. It has an interesting gameplay mechanic that I haven't seen used before in any game before: your character is placed on a field of random numbers that dictate how far he can move in any direction. Since your goal is to travel to specific locations (the town or the dungeon), you often have to take a round-about path to get there, and usually involves some strategy to get from point A to point B without overshooting it or getting catapulted nine spaces out of your way.

"The Numbervold" plays like a pretty standard RPG with random enemy encounters, hit points, gold that you collect, magic potions and spells, and townsfolk who like to have one-line conversations with you about random topics. There is no real story to this game other than what is posted above, and the only real goal is to level up and purchase spells. In a future version, Ryan hopes to include various quests and townsfolk at the inn to gossip with, but for now these features have not been implemented.

Although the game is pretty barebones when you actually play it, reading the manual gives it a whole lot more personality and context, and definitely adds to the experience. It also explains some of the strategy to the battle system and lets players in on a few secrets to find more gold or how to defeat a powerful Lair Beast.

Overall, pretty standard tried-and-true gameplay, aside from the whole "number" aspect to move around the map -- which sets this apart from a completely generic RPG, albeit slightly. There's a lot of gameplay time to be had here for the patient -- spells to buy, lairs to conquer and gold to find -- though there's not really much "spice" to break up the repetitive gameplay. As far as I can tell, "The Numbervold" pretty much goes on forever, but every round is more of the same.

> The Verdict: A fun game for a while, with a unique concept and quite a few features to explore, but it's in desperate need of a story or at least some goals to give the player motivation to sit through the repetitive random battles and Lair Beast fights.

### 1st Encounter

Thomas Nixon's entry to this competiton is a dark, scary mix of survival horror and RPG stylings set on a ring-shaped space station around the Earth constructed to protect our homeworld -- though nobody expected it would be the site for the first bloody encounter with hostile aliens. Here's the plot, straight out of the game itself:

> World leaders decided to prepare defense to stop attacks from space. They built a massive ring that went around the world and was able to defend every inch of the Earth.

> The ring required many people to work on it. You decide to join up for a job after being fired from your current job as a Software Designer. You go through a virtual training program on Earth to prepare you for living and working in the ring.

> After the few weeks of traing you are shipped to the ring with another couple hundred people. Once getting there you never really liked being in space. You developed horrible sleeping patterns and would spend most of your night working overtime.

> You had been working overtime in your office tonight. You finally decide to go to bed and try to get some sleep. As you are finishing up the power flicks off. This hasn't happened before. Very dim backup lighting comes up, You can't see all that well. You hear screams from down the hall, human screams...

1st Encounter uses some unique text tricks to create a dark, murky atmosphere that looks almost as if you're carrying a flashlight through a dark room, illuminating only the area immediately around you. Only the areas of the map immediately surrounding your character are visible, and areas farther away from you gradually fade darker and darker until you see nothing but pitch black. This helps create the scary, claustrophobic feeling of other dark games like Doom 3 or Resident Evil nicely. This was only enhanced by the dead smiley face graphics littering the game map in pools of dark red "blood" and the dreary gray and black hues used to color the map. This flashlight or "fog of war" effect was by far the best aspect of the game, and actually made the random battles with angry sharp-clawed aliens fit with the atmosphere.

> Here's a collection of cropped screenshots from 1st Encounter. The game only ever uses a small portion of the screen, for both the main overworld map and the battle engine, so I combined several screenshots into one.

As far as the gameplay of 1st Encounter goes, there's really not much to it. You walk around the map, fighting random battles with aliens, while searching for an escape pod to send you safely back to Earth. The game is fun while it lasts, but it is unfortunately about four minutes long your first playthough, and after you memorize the path you have to take, it can be be beaten in less than a minute. Every time you play, the game uses the same map maze where you must find some hidden power-ups, then find the escape pod where you fight a final battle with a large alien before you make your escape. Battles use a standard turn-based text system, and you fight only two types of enemy through the course of the game: a randomly-occuring alien with sharp claws and the stronger final boss. Once you beat the game, you're treated with a one-paragraph ending that completes the story for you. That's really just about all there is to it.

I really liked the engine that Nixon put together for this game, and I wish that he had developed it into a longer story with a more challenging map. Due to the restrictions of this competition, he could only have one map, but he certainly could have made it more confusing than it was, and added more than just two super power-ups. I also think that the hit point balance was a little off for the game, since there wasn't really any challenge to it. The aliens didn't do enough damage to present any real threat so long as you had ammunition for your gun. If you started with only two or three bullets and had to find more ammo and health on the map as you went along, all the while just barely escaping death, this would have much more interesting. I would have also liked a little bit of interaction with your "dead" co-workers...maybe they're not quite dead, and if you press the action button next to them, they murmur some final words to you and die. Or maybe you could even find another survivor who gives you weapons or something. Anyway, there was a lot of potential here and I wish Nixon had time to develop this further. But since he rushed it out on the last possible day, I see why it's a bit lacking. Oh, and an alien game set on a ring around a planet...can anyone say Halo?

> The Verdict: A cool concept that should have been developed more. As it stands, this game is too short, unchallenging and linear.

### Results

Winners of this competition will receive an award image to put on their websites (eventually, once I get around to it...actually, I still haven't made the images from the first compo...) and also, um, bragging rights. Woohoo!

First Place: "The Numbervold" - Ryan Szrama
  Because of its greater number of features, challenge and polish, "The Numbervold" squeaks ahead and wins this competition.
Second Place: "1st Encounter" - Thomas Nixon
  A cool concept with a lot going for it, but the game needed more flexibility and gameplay.

So there you have it -- the results of the second QB Express programming competition. This issue we're going to hold off on another competition, but in the January issue, we'll return with another fresh challenge for you readers to try your hands at. Also, I will be expanding this challenge to also allow FreeBasic entries, which will hopefully encourage more people to participate. Look for this in the January issue, due out in just a few weeks!

Want to try these games? Download this zip archive!

## Blast From The Past!

### Written by Pete

Every issue, we take you back in time to the early days of QB on the Internet and show you a lost relic of the QB Community. This is your Blast From The Past!

### QB Top Sites Lists

In Issue #3, the Blast From The Past! article was about the Qlympics, but since the Qlympics were started by Steve Martin, the owner of the QBasic / QuickBasic Top 50, I focused heavily on the QBT50's history. When I was trying to come up with a topic for a new Blast From The Past! for this month, I started looking through the archives of my site, and I kept noticing just how many QB Top Sites Lists there have been. Back in 1999-2000, there were at least a dozen of these sites where QB site owners would compete for hits to increase their ranking on the automated "top sites" page. So for this article I'm going to give you guys a brief history of QB Top Sites lists -- or at least as much as I know about them. Here they are in (rough) chronological order:

| The QBasic / QuickBasic Top 50 (http://www.qbt50.com) This is the site that started it all. Back in early 1998, the QB "community" was a collection of random Geocities and Xoom sites with one thing in common: The QBasic / QuickBasic Top 50. At the time, the QBT50 was the most-visited QB site on the Internet, and it became the hub of that connected a diverse collection of QBasic programmers. Through the QBT50, the dozens of small outposts of QBers, communicating through their own Server.com DiscApp Discussion Boards, and little mailing lists, came together. The QBT50 was instrumental in developing the Qmunity into what it is today. No QB top sites list since the QBT50 has managed to match the quality or popularity of the original, which really says a lot.
| Top 25 QBasic Sites (http://qbt25.hypermart.net) The second QB top sites list that I ever heard of was the QBT25, which was always considered a pathetic imitator to the QBT50. This is the first of many Hypermart-based QB top sites lists that took advantage of that service provider's free CGI capabilities. The QBT25 had a boring white layout and a very simple voting script that was quite easy to spam, never even came close to the popularity or the reliability of the QBT50. Nevertheless, this site is actually probably the longest-running QB top sites list ever, having operated from early 1998 until at least August 2003, since Archive.org has a copy from then. Chances are it lasted until early 2004 when Hypermart pulled the plug on its free hosting service.
| QuickBasic and QBasic Top 100 (http://www.quickbasic.com/qbt100) Dark Elf Productions was one of the early groups to jump on the top sites list bandwagon. ChUcK, the head of Dark Elf, was one of the earliest QB philanthropists, purchasing the quickbasic.com domain name and a large server to provide free hosting to a large variety of QB websites. He also was intent on community-building, and so as part of that effort, he created the QB Top 100 with its nice blue layout. Unfortunately, Quickbasic.com was short-lived, expiring just a few years after it was created due to a lack of funds on the part of Dark Elf Productions.
| The QBasic RPG Top 50 / Game Programming Top 50 (http://qbrpgt50.hypermart.net/) This next top sites list was created in the fall of 1998 as the "QBasic RPG Top 50", but it quickly had a name change to the "Game Programming Top 50" to allow other languages and other genres of game programs to join up. I don't know much about this site, though I know Pete's QB Site joined it on Nov. 15, 1998. It was also heavily-promoted by Magus, the guy who went on to found QBasic / QuickBasic News as well as The Qbasic Top 100. I'm not sure what Magus' involvement was with the site, but he posted on several message boards and guestbooks, encouraging sites to join up.
| The QBasic Top 219 (http://www.top219.org/cgi-bin/vote.cgi?c=qbasic) Top219.org was a money-making venture by some shrewd dotcommers back in 1999 or so. This site hosted top sites lists for hundreds of different types of hobbyists and made money from the advertising that accompanied the site listings. I'm not sure who exactly started the QB Top 219, but I do know that Pete's QB Site joined it in May 1999, and it lasted until at least the end of 2000. Since then, Top219.org has gone down, probably a victim of the bursting of the dot-com bubble four or five years ago.
| The Coder's Choice Top 25 (http://coderschoice.hypermart.net/) Tek, the headman of the acclaimed NeoZones Productions got in on the top sites act sometime in mid-to-late 1999 when he launched The Coder's Choice Top 25. It was a pretty standard top sites list, hosted on Hypermart, and left to be self-sufficient for years and years. Here's an ad promoting the Coder's Choice Top 25 from a 1999 issue of Tek's QB Gazette: "Want to gain some exposure for your site? Then check out the Coder's Choice Top 25 sites, made by programmers, for programmers, voted by programmers. Where does this madness end?"
| Top QBasic / QuickBasic Elite Top 50 (http://www.ampleworks.com/cgi-bin/topsites/) Another fairly generic top sites list that I don't know much about. This was created and operated by the programming group Ample Works which was at its prime in 1999 to 2000. The Elite Top 50 was just like all of the other top sites lists at the time, from what I can tell, and was created as a sub-section of the larger Ample Works website.
| QBasic Pathfinder (http://qbpathfinder.hypermart.net/trs/) The QBasic Pathfinder was probably the most original and useful QB top sites list that ever came out, and it's a shame that it was wiped out earlier this year when HyperMart shut down its free web hosting services. This site was created in early 2000 by Merlin of Master Creating, the same guy who made the widely-admired RPG "Shadow of Power." This site allowed users to rate QB sites on a scale of 1 to 10, and then rated sites with a complex equation that took into account average rating score, popularity, hits in and hits out, and also had a lot of precautions to prevent spamming. QBasic Pathfinder is one of the few top sites lists that ever gave an accurate picture of what truly were the best QB sites on the Internet, and it's a shame that it's no longer running.
| QCharts77 (http://qcharts77.hypermart.net) QCharts77 was created in 2000 by Actlab, a German QB programming team that offered versions of its site in both English and German. QCharts77 is one of the few QB top sites lists that was populated heavily by non-English sites, and had many German sites near the top of its list. Otherwise, though, it was a fairly generic Hypermart-based top sites page.
| The QB Top 50 (http://www.qbtop50.com) Run by a chap named Chinar, the QB Top 50 was like the second coming of the original QBT50, just on a smaller scale. It had an almost identical layout, it was pretty immune to spammers and had the best sites as the highest-rated, and it had an almost identical name to the original QBT50. This site was originally hosted at ogaming.com in spring of 2000, but soon moved to a loadedweb.com server in June of that same year. V Planet! was very enthusiastic about this website, and featured it in many of its monthly site reports. Here's a quote from the May 2000 monthly report: Topping off this month's Site Report, The QB Top 50 is steadily growing in usership. This new topsite, at www.qbtop50.com, gives people still updating their QB sites a chance to advertise their QB webpages in a page free of cheating! IP addresses are checked on a daily basis, so it's easy to find out if someone's been voting multiple times or if any other shenanigans have been taking place to influence the rankings of the top QB sites. And if anyone does cheat, the site owners at The QB Top 50 kick the cheaters out, no questions asked. It's gradually becoming a nice hub to go to, and there are still plenty of open spots for people interested in advertising their QB sites.
| The QBasic Top 100 (http://qbtop100.qbasicnews.com/) After developing The QBasic / QuickBasic News into one of the best sources of QB news and information on the web, the site's first owner, Magus, created the Qbasic Top 100. This slickly-designed top site list was well-organized and well-maintained while it lasted, and got heavy promotion on the old QBasic News website. Here's one of Magus's ads for the QB Top 100, posted on August 23, 2000: The Qbasic top 100 has been growing very well and the first page of rankings is actually full of sites! :D So who ever has not added theres yet, besure to do it since you WILL receive traffic in return. The QB Top 100 got promotion at QBasic News just about every week, so it quickly became a widely-used and popular top sites listing. Unfortunately, sometime after Magus gave up on QBasic News and sold the site to Jorden Chamid, this top sites listing eventually disappeared.
| The QuickBasic RPG Top 50 (http://rpgtop50.qbrpgs.com) Started by Fling-master in September 2000 as part of HyperRealistic Games and the QuickBasic RPGs network, The QuickBasic RPG Top 50 is the only QB top sites list still in operation. Since it is a QB RPG-themed site, the majority of the sites listed are development sites for RPGs, though some of the big, multi-genre QB sites are listed here too, like QBasic News and my own site. The QB RPG Top 50 doesn't get nearly as many hits as former top sites list did, and many of the sites in the top fifty are not even available anymore. However, if you want to visit a QB top sites list these days, this is the only game in town.

Well, as far as dedicated QB Top Sites lists, those are all the ones I can find. I'm sure there are more -- these were a dime a dozen. Plus, there were lots of multi-language Programming top sites lists such as The Programming Top 500 that tailored to all languages, including QB. It's amazing how many of these top sites lists have come and gone over the years. And now, looking back, they've mostly gone. The lone holdout is the most recent site on our list, The QuickBasic RPG Top 50. Quite a difference from in mid-1999 when I had a total of NINE banner images on my site for QB top sites lists -- and they were all active.

I was actually a bit overwhelmed by the sheer number of these sites myself. Check out this news posting from my site in April of 1999:

> April 22, 1999
> I'm going to decrease top site lists on my pages soon. It's getting out of hand. I'm kind of mad at the QBT25 and the QBRPGT50 (Now Game Programming Top 50). I also want to make animated .GIFs just plain images for load time. There are just too many images to load on this page for dial-up users. Oh, I also have another top sites list that I joined a while back to add, but I won't for a while. Gotta go...

But why were there so many top sites lists?

The QuickBasic RPG Top 50 is the only QB top sites list still in operation.

Well, back in QB's earlier days on the web, there were literally hundreds of QB sites all over the place, and it was pretty much impossible to keep track of them all. The best method anybody found were the anarchic top sites pages where webmasters could automatically add and promote their sites (without going through a middleman webmaster). Top sites pages like the original QBasic / QuickBasic Top 50 were extremely important to the QB community for sharing and promoting sites that would have otherwise been hidden away in the dark corners of the world wide web, never to be visited.

But as time passed and the QB community shrunk from hundreds of regularly-updated sites to dozens to now just a handful, these top sites lists have lost their importance. The shrinking QB community simply no longer needs a dozen top sites lists, and there aren't even enough sites out there to make the competition worthwhile. At the QB RPG Top 50 right now, every single site listed except for the #1 QBasic News has 0 Hits Per Day, and only the top seven listed sites have had a SINGLE "Hit In" or vote in the past month of December. That kind of traffic is definitely an indication of the popularity or necessity of top sites lists these days -- the Qmunity now just bookmarks a select few big QB sites and visits those regularly for their QB fix. And if any of the smaller sites ever are updated, since updates are so few and far between, it becomes news on the major QB message forums or even on the front page of QBasic News. Top sites lists are now left completely out of the loop.

Wanna check out a QB top sites list? The QB RPG Top 50 is the only one left!

## Joe's Pointless Points
Volume 2

### Written by Joe King

Welcome back readers! That is if you have read the last one. If you haven't, then welcome for the first time!

### 2005

It's now December, that time of year that's just before the next year. 2005 is about to approach. That means that half of this decade is already over! What?!! It only seemed like 5 years ago when the millennium came. Wait! I think it was about 5 years ago when the millennium came. My sense of time is uncanny!

### New Horizons

What will the year of 2005 bring us? I have a feeling it will turn out better than 2004, 2003, 2002, and 2001. Let me tell you why. 1999 was a great year for the QB community. I was programming in QB a few years before that, but it wasn't until 1999 when I discovered the online community. It seemed like there was a countless number of QB sites consisting of people working on a countless number of projects. Only a select few were actually finished. I can actually say that it was the best online community ever. Sure, there were other community's around related to other topics. But the QB community was just the right size at that time. It wasn't too big, nor too small. It was helpful and friendly, and it was easy to learn who the people were. Anyways, after that year the community was declining. It was still really active in 2000. After that, it started to feel empty. Today, it's so empty that any game completed gets hailed on the news of the most popular sites. Lately, however, I've noticed that it's grown a bit over the past few years. New QB sites and teams still pop up here and there. The quality of this magazine is proof that the community has reached another high point again. Still the fact remains that QB is really old; therefore, it's most likely never going to be as good as it was back in the day when QB wasn't.

I believe a lot of the reason that it's growing again is because the community has handled the transition pretty well. When the community was very active, it had thousands of sites and thousands of members. Only several of the very big ones were featured in the links of most sites. The rest of the sites were found because of the size of the community and forum activity. Once the community lost most of its members, you could say that there were no "roads" to the other sites. What you're left with are thousands of sites scattered across the web, but not as many members to surf them. Basically, there were too little people scattered amongst too many sites, or too little butter being scrapped across too much toast.

But the community's handled it by "shrinking" in a way. There are fewer forums, so it keeps everyone close together and into the same spot. There's still quite a number of dead QB sites out there, but it's a lot easier to find the active ones today. The community's gone through the process of keeping tabs on sites that stay updated, and have removed dead links, etc. So today I think it's nearing a peak in keeping the community alive with such techniques. This allows newcomers to easily find and join the community to make their contributions.

Even though it may never be as great as it used to be, it's never been so close together and accepting of others. Having said that, expect more to come out of this next year than the previous years I have mentioned.

### To Summarize it All

Well, that's all I have to say for this issue. I wish you all a happy new year and encourage you all to take the initiative to make 2005 a great year for the QB community.

Ponder these thoughts in your mind. I beg of you!

Visit Joe's site, DeltaCode.

## Piptol Meets... Angelo Mottola

### Conducted by Piptol

This man certainly needs no introduction... just think of DirectQB. Wetspot 2. RT Project. Allegro. He's been decorated with so many 'QB Legend' awards that he makes your prize-winning Christmas tree look like some pathetic dead twig your dog dragged in. Today we discover what the Enhanced Creations front-man has to say on the future of QB, the arrival of FreeBasic, and skipping through flowery meadows..

Welcome, Angelo! Many thanks for joining us here at QB Express.

Thanks to you! Glad to be interviewed, QB Express reminds me a lot of the old QB:TM days... seems the same spirit, and that's very nice!

Where do you live and what do you do in real life?

I live in Rome, Italy, and in real life I'm completing my master degree in computer engineering, software specialization. Hopefully I'll be out in 4-5 months, the time to finish master thesis...

So, how did you first get started programming?

Heh, that was long ago; I started programming in Basic on the Commodore 64, mainly copying listings from magazines, just to see what they produced :)

Let's talk a bit about your QB days. There's no doubt that DirectQB has achieved legend status. Even today, it still has arguably the biggest fan base of any QB library. What inspired you to write it?

Allegro. At that time, I was envying the C world because of Allegro; it was so easy to use and powerful, and wondered if a similar thing was possible for QB. The best "feature" of Allegro I attempted to copy was its ease of use, and I think I achieved a good result; if you look closely at DQB, you'll notice a lot of conceptual similarities with Allegro. It's not a case that when I left the QB scene I became an Allegro developer...

Wetspot 2, perhaps the most loved QB game of all time.

Seven years after creation, 'Wetspot 2' is still be considered one of the best ever QB games. What do think has been the key to it's popularity?

Good gameplay and polishness. I put lots of efforts in the small details, and that's what makes games good games. Of course by polishness I also mean bugfree: I spent several months just for the beta test phase, to ensure the game had no bugs when I officially released it... Even today I've never heard a person complaining about the game stability.

RT Engine was another benchmark in stretching the capabilities of QB, and only now are the first projects to use the technology emerging (such as Nebula, MUX and Two Lords). Which of your QB projects has given you the most satisfaction and why?

Actually when I now look back at RTE, I somewhat laugh... Just think that when I switched to C, after some months of familiarization with the language I rewrote the raycaster core in C and found a LOT of possible optimizations I left out when I coded in assembly. The C version was running at 140 fps on the same hardware where RTE ran at 23 fps... For example, on the assembly RTE I used a lot of DIV instructions that could have been replaced by MULs, which are much faster. But let's get back on topic: maybe the project I love the most is DQB, even if it has its flaws; I simply put too much effort on this not to love it, and the fact that so many people loved (and love) it is much rewarding.

Many coders who have moved on from QB have since been attracted back by the appearance of FreeBasic. Why do you think this is? And could the success of FreeBasic actually spell the end for QuickBASIC?

By my personal experience, the main reason I quit QB was its limitations due to the fact it is a real-mode DOS compiler, which in the modern world just doesn't fit. FreeBasic opens this modern world to the QB scene, and no wonder if QB will fade away in the future... But there are some issues: QB was great because it was easy, standalone and it was quick to hack simple programs with it (thanks to the IDE too). FreeBasic currently is just a commandline compiler; to fully overcome QB it needs more, starting with an IDE that possibly has the same feeling of the old QB one, up to integrated help system like the QB one. And another important aspect to consider IMHO is consistency: I've seen a lot of attempts to port just Win32 libraries to FB. This makes sense but leads to fragmentation; people should be encouraged from the start to use a consistent API that is portable... By the time this article will be published there is high chance a Linux port of FB will be available; linux FB users will not be able to compile FB sources if they use Win32 only libs, so think forward and use a multiplatform approach.

Great to hear that you are working on a FreeBasic Linux port. Any chance of an FB version of Wetspot 3?

Heh, actually Wetspot 3 development is currently on hold because I have master thesis and other projects going on... In the future who knows!

Ok, on to the non-Basic stuff. What projects are you involved with right now?

Lately I have few free time to contribute much, but I'm an active developer of Allegro and AllegroGL. And I plan to resume contributing to the Haiku (ex-OpenBeOS) project, for which I contributed the posix signals handling implementation in the kernel. Oh, and I can also say I'm involved with the FreeBasic project itself, having ported it to linux; I hope I can port it to PPC too so FB will also run under MacOS X, but that'll require a PPC compiler backend that is not trivial to me, since I have no prior experience with PPC assembly... That will be an interesting challenge.

You've been involved with the Allegro development - a kind of 'DirectQB for C++'. Allegro has helped many people - me included - ease the transition from QB to C++ games coding. Would you say you prefer cutting stones rather than building houses? (Erm, do you enjoy creating tools like this for people to use rather than your own games & applications?)

Kinda. Yes, I can say I love to hack here and there, but that is also due to another reason: creating a project from scratch takes a lot of time, and I have few free time due to university and real-life. Hacking is much quicker and requires less efforts. Yes, I'm lazy as 99% of programmers :)

You're certainly one of the busiest coders around at the moment. But do you ever feel like chucking your PC out the window and dancing through fields with a guitar strapped to your back instead?

Luckily I have a life, and even if I spend a lot of my time in front of a PC, I also spend a lot of time with friends, so I don't feel that need :) What I'd need sometimes is a couple of more hours per day...

"Never trust a skinny chef" and "don't eat yellow snow" are wise words, if not exactly inspiring. What's the best piece of advice anyone has ever given you?

"Shit happens, just try to avoid it"... Wise words...

Anything else you'd like to add or rant about?

Want to thank all the people who used and loved my projects; for a programmer, that's a big reward. And I would like to thank QB Express for this interview; keep it up guys, your magazine is great!

Thanks Angelo, the pleasure is ours.

Visit Piptol Productions or Angelo's Enhanced Creations++ site.

## DOS Emulation Follow-Up

### Written By Pete

Last month, QB Express did a few feature articles on emulation DOS in non-DOS environments. Nekrophidius wrote a great article on "Beating The XP Straitjacket" which explained a few ways to run DOS programs on the finicky Windows XP platform, including using DOS emulators, such as DOSBox as well as Virtual Machines. I also wrote an article on emulating DOS, which focused on user experiences trying to emulate QB on different platforms including Linux and Mac OS X. At the end of that article, I asked readers to send in more stories about their experiences trying to get DOS programs to run on modern systems so that I could do a follow-up in this issue. Here's what I received.

### SJ Zero: Yarr, I've got me a Windows 2000 (and so mostly XP) compatability story to share!

In 2001 compatiblity started really being an issue in the development of Quest for a King. Windows 98 had stopped being an option for development, and so I moved to Windows 2000. At the time, I was using pureQB everything and SBMIDI for music. The switch meant learning to try to tame the beast that was the Windows NT/2000/XP Virtual Dos Machine(VDM).

The most important things I found were that video, music, and memory can't be counted upon in a 2000/XP environment. Rather than fight the beast, I decided to take the easy way out.

Video in 13h is compatible with just about everything, but eating up 64k of memory for a video buffer is heinous. I already had a good ModeX renderer in place, and just made sure it was working properly on a variety of systems. In Windows XP, VESA modes are actually broken on most cards because of a broken VGA driver, which tries to intercept the calls. Ironically, Windows 2000 has a much more robust VDM in that respect, and is more likely to run VESA programs correctly, as long as the screen is maximized when the mode is called.

An slightly-dated screenshot from Quest For A King, SJ Zero's RPG.

Sound is something I had to move around a LOT. In XP you can usually emulate sbmidi, but the overhead can cause real problems if you want smooth gameplay. I wrote my own music slave, which worked for a while, but it suffered the same problem because I'm not a windows developer. Finally, Nekrophidius helped me by making a music slave program. He's a much better programmer than I am, so all I had to do was write an interface for it. I popped the QB interface source file into my project(I'm using VBDOS 1.0, which supports multiple files very easily), then had music. It's still not perfect, but it works on any version of windows, and if the slave isn't active, the game will still run correctly. To make matters worse for people using QB wave players, those rarely work right. You need a certain sound card set up right, or your users will get a blast of horrible noise, or a lockup, depending on whether you're in Windows 2000 or XP.

Memory is something you can't screw around with these days. There was once a time when you didn't need to worry about whether a person had EMS drivers installed because it was easy to tell them how to do it, and XMS was actually standardized, but modern PCs aren't guaranteed to have working EMS drivers(some motherboards completely eat up the memory space, so you have to disable something before you can load the driver), and XMS is different between Windows 98 and Windows XP in some respects. Some people managed to get XMS working in XP(because it will work in 98 if it works there), but rather than get my hands dirty with that, I wrote an algorithm to load only the tiles needed on the screen at one time, rather than loading them all at once. This meant that I could have over 30,000 sprites on a map, and 30,000 more in objects, and still be perfectly fine as long as I only used 50-100 on one screen. After this, memory concerns were greatly minimized, so I stopped worrying about it. Most people won't have that luxury(most problems don't find solutions so readily), so XMS is definitely the way to go. EMS is a real gamble, for the reasons mentioned.

The fact remains that you're often still stuck. Many XP machines have critical problems with DOS, regardless of your code, which is when you have to recommend a dramatic course of action like dosbox. Non-functional keyboards are the more common culprits, and when that happens there's no way to fix it on your end.

Hope this helps, best regards.

SJ Zero

> Lots of great info here -- thanks a lot! Testing your program across multiple platforms seems like it's the only way to go now that DOS is an afterthought in Windows NT-based operating systems. I definitely agree with you on ditching EMS for XMS if you have to use one of them. But still there are always lots of compatability issues, especially in Windows Xp. Messing with the EMS/XMS in the memory tab doesn't work all the time...in fact, it barely ever works for me...so I definitely prefer any alternatives that actually work. That's why FreeBasic is the best thing since bread and butter.

> -Pete

### Michael Summers: Bochs Virtual Machine

I noticed in your QB Express magazine that Bochs (http://bochs.sourceforge.net/) was not listed with the other VMs. You might wanna check it out since it is open source. =)

Michael

> Hey -- Bochs looks really cool! I didn't get a chance to try it out, but I took a look at the website and was pretty impressed. For example, there are screenshots of "Bochs on Linux running 'Doom' on DOS" and Bochs running a whole bunch of OSes including Windows ME, NT 4.0, Win2000, Win95, FreeDOS and more. Plus the whole open source aspect makes it even better.

> -Pete

If anyone else has stories, send 'em in! I'll keep on doing a follow-up so long as I keep getting feedback on this topic.

## Coding The Way It Was MEANT To Be

### Written By Oz

Well, there are many theories on how to go about programming, but there are some essential steps required to get the ‘best performance’ out of you, and your code.

### Step 1 - The Mood

Everybody has emotions, but which are appropriate for coding? Well, you need a motivated mood, such as anger, frustration, but these must be taken in moderate doses. Warning: Overdose of any of these emotions may cause you to stop programming! If you have trouble bringing these emotions up, here are a few tips:

1. Listen to heavy metal/hard rock. AC/DC & Jimi Hendrix do the trick for me, but there are many bands that get you into a half-downer mood. It is usually also helpful to clock the world out, so go to a dark, more secluded room, or put head-phones on. If you choose head-phones, and there are a few people around that don’t appreciate your music, turn it up so they can hear it at about a whisper.
2. If you like to box, then go to the old punching-bag and give it the old “one-two”.
3. If you are a little more morbid, maybe try kicking something like cement bricks barefoot a few times.
4. You may want to play a good First Person Shooter (FPS).
5. If all else fails, cough medicine does the job nicely, but I do not suggest this as a regular method.

### Step 2 - The Stance

This one is the easiest, if you have a swivel chair. Slouch so you are eye level with the centre of the screen. If you aren’t that tall, then lean forward so your back is almost a perfect arch. This may cause future back problems, but that’s why we are programmers. We are rebelling against the system. Society is the system. We are not society - we are programmers. The community is not a society, even though we work like one.

### Step 3 - Brainstorm

So this is the part where you start planning what your going to program. The stage every programmer does. Like hell! This is what I do, I think of what genre I want, then just start coding. No real direction or purpose. There are a few rare occasions when you wish to do something decent. Then you may want to do some planning on paper, such as plot-dev, general character sketches, and maybe a few sketches of how you want to game to look.

### Step 4 - Compatibility

Well, for most cases, If the program does work, banging your monitor or tower usually fixes the problem, but when it comes to programming, you need to make a few things more general and user friendly. The fist major one is speed. Every computer runs different, depending on the number of programs already running, and general computer speed. The most efficient way of doing this is V Sync ( WAIT &H3DA, 8 ), which waits until the monitor is synced with the computer. This is usually under a second, but is basically the same in every computer. We also have to think about graphics cards. Graphics cards…graphics cards. Yeah, not everyone has VESA/SVGA graphics cards, so we have to think about the users, not us. I know, tough job.

### Conclusion

Yeah, that’s really all I have. Not much of a conclusion for you. Don’t do drugs.

Oz~

Visit Oz's site, Atosoft QB!

## Roguelike Games #2

### Written By Jocke The Beast

> Since this month we're a bit short on content, I've decided to publish this great article by Jocke The Beast to help flesh out the magazine a bit. This article is already over a year old, but it's a great read for anyone who's even mildly interested in Roguelike games -- or for anybody who doesn't know what they are. It's been available on Jocke The Beast's Homepage since December of 2003, and though many of you might have already read it, I'm sure it's new to some people. Enjoy!

> -Pete

Yes sir, this is my second article about roguelikes. The first article did explain what a roguelike is and this article will get more into the question "why the heck arn't there any roguelikes made with Qbasic?". But for the ones who forgotten, Rogue is a text-based game made in the 1970's that started it all. You explored a dungeon, gathering items, fighting monsters and getting stronger. The main quest was to find the Amulet of Yendor. What separated rogue from most similar text-based games of its time was how it handled the output. Most adventure games described the player's environment (eg. "You are in a small room, with a passage out behind you"); rogue "drew" it using text. In other words, a roguelike is: single player, text based (no graphics), randomly generated dungeon levels, turn based (ie. nothing happens until you press a key that does something),
the emphasis is on good gameplay rather than good graphics and death is permanent. No loading saved games, no coming back to life. Once you die, you can only start from the beginning with a new character.

> To the left Rogue by Epyx Inc. 1985. And to the right the original Rogue made by Michael C. Toy & Kenneth C. R. C. Arnold back in the early 1980's

First of all, there have been roguelikes made using Qbasic (or other BASIC languages), some full-versions and some demo versions (Progue 1 & 2, The Dungeon, Tiny Roguelike and Quest) . So, perhaps the question should be "why the heck arn't there any GOOD roguelikes made yet using Qbasic?". As you might can imagine I'm not that satisfied with the roguelikes that have been made using Qbasic so far. The thing is that there are so many talented programmers in our community and some really advanced and well-designed games have been made (just look at the progress the latest years and you'll see what I'm talking about) . So, I think that the skills to make a qbasic roguelike are avaible but still one fact remains: there have been no good roguelikes made using Qbasic yet. The answer to my question is perhaps as easy as "no one wan't to do a roguelike...you freak!" but I don't buy that (and I'll knock you out if you talk that way to me) ;) I mean, I buy that argument today but hell, Rogue was made early 1980 and now more then 20 years later there still is no good qbasic roguelikes. So, ladies and gentlemens, it's time for action...

The Dungeon, one of the few "quite" playable roguelike that's been made using Qbasic

Now you might say "you little prick, do it yourself." and I understand your point of view (even if I hate you for calling me a prick). But I'm quite honest here, I've tried but failed. It's complex to make a roguelike. Sure, anyone could probally make the generated dungeon engine and a walkaround engine with some nice line-of-sight features. But that doesn't make it a good roguelike, no sir. The thing that is so cool with Rogue and similar roguelikes is the fact that they offer a gameplay that really rules. And since the game regenrates every new game you play, you can play it over and over again. One of the most important features is probally a well balanced gameplay (not too hard, not too easy) and that will most likely take alot of time (beta-testing) to work through. So, here I stand all honest before you all telling you "I've tried but I didn't make it, I've tried but I failed". Now, what is my intention with all this? To be honest, I think the reason is that I would love if I could motivate others to make (and most important...finish) a qbasic roguelike. Then I'll be satisfied (and I'll shut up for good).

One thing that I've been thinking about is that when someone starts to develop a roguelike they often start by thinking "ok, I'll make a roguelike similar to the original Rogue" and then after awhile they say "well, this shit is easy, I'll make my roguelike much more advanced then Rogue". That's one big problem in my opinion. It's not easy to make a rogue-clone (even if that game was made early 1970) and I think people often bites the dust when thinking "hehe...this is easy, Hell I'll make my roguelike much more advanced then this old junk!". Those dudes never finish there roguelikes, they'll end up as some pre-early-not-even-alpha-demo-junk. So, make a roguelike and try to make it exactly as the original Rogue (there are a huge amount of features in Rogue and that game still rules in my opinion). Later, if it really was "easy as hell to do", then you can make your own super-advanced-roguelike-alá-ADOM (and also mock me for telling you that BS) ;)What's the different between a good/bad roguelike? I read a tutorial once about it and here's the author's comments about that:

> Replayability. If the game is random enough, it is always fun to play and replay, because every time it is like a different game.
> Freedom. There is a lot of it. You can kill just about anything. There is a lot of actions you can take. Many strategies.
> Complexity. There is a lot of items, skills, classes, areas, spells.
> Difficulty. While this can be off-putting, it gives you a tremendous sense of achievement to finish a roguelike or even to get far. You always have to be careful - it is easy to die, and all that playing time was for nothing.

And as a summary: Make it easy to get into and play; no reading through 50 page files to learn how to play. Keep the controls simple. The gameplay must be good. This generally distinguishes roguelikes from similar games - the emphasis is on the gameplay. Once your character dies, that's it - no coming back to life. This makes the game exciting when you are in danger. Keep it balanced. If it gets too difficult, people are discouraged. If it is too easy, there isn't much fun in it. Make it big, with plenty of items and monsters so it is interesting to explore. Make an interesting story. And, most of all, don't make it like some or other roguelike that already exists. Use fresh, new ideas. Make it original and different.

And how do you finish making your roguelike: Basically, have a plan. Decide in which order to program it, and stick to the plan as much as possible. Keep it fun for yourself. If you get bored, work on another aspect. If you are bored on programming, work on the story, or on the graphics (if you use them). Take a break. It should be fun. If it isn't, ask yourself why, and do something about it. If you are stuck, get other people to help you.

> ADOM, by Thomas Biskup. By far the most advanced roguelike today

Ok, now I've mumbled on about how much I would love to see a qbasic roguelike and I guess you all are quite tired of me. But I won't give up on you, no way José ;) So, let me try to motivate you somewhat more (or perhaps make you hate roguelikes for the rest of your lifes). Below are some nice screenshots different roguelikes, the best way of gaming...ever (*angry crowd shouts "is this guy full of shit or what?!"*) :P

> Angband, based on Moria & Umoria:Alex Cutler, Andy Astrand, Sean Marsh,Geoff Hill, Charles Teague, Charles Swiger,Ben Harrison,Robert Ruehlmann

Rogue's Quest by Pearson Wung
Omega made by Laurence R. Brothers & Erik Max Francis
T.O.M.E, Tales Of Middle Earth, a Angband variant made by Angband/Zangband fanatics

So, thanks for reading and may you all have a Happy Christmas if I don't hear from you before that event. And as usualy I'm looking forwards to discuss this article (and other) at my Forum.

> Greetings,
> - Jocke The Beast

Visit Jocke The Beast's Homepage or read his other articles.

## QBTK Mega-RPG Compo

### Written By Pyrodap

We at QBTK would like to invite the entire Qmunity to join what promises to be a very large, and somewhat unique competition. How many QBRPGs have actually been finished compared to how many have been started. Very few. Most people that start and RPG make a tileset here, a map engine there, or come up with the greatest plot EVER. Most of these promising RPGs die within a week or two.

The problem is as follows: People aren't good at everything!! Some people are creative, they're good at writing the manuscript, or scripting the game. Some people are 1337 coders! Some people can make that grass tile faster then you can say "Pyrodap is awesome!"

The solution is, of course, teams! Groups of coders come together and put their work together. But, of course, this frequently fails when one member loses interest and just disappears, causing the others to lose interest.

BUT NEVER FEAR! THE QBTK MEGA-RPG COMPO IS HERE! The idea comes from our favorite crossdressing wizard, Zap, and as one of the new admins of QBTK, I thought I'd put it into action! It works like this: At www.qbtk.com we hold a series of compos of about a week or two each. Each of these compos will result in a single component of an RPG!

The first of these sub-compos, the Manuscript compo, which is a complete plan for the entire game, is almost finished. Not many people joined, which I can understand. In a coding community, like our wonderful Qmunity, most people are just that! Coders! The Manuscript compo was really more like writing a story. (And for the love of the 1337 Coding Ninja Monkeys, I hope this game isn't another "Oh no! The crystal has been broken into four pieces and scattered around the world! Save us! Save us!" game.)

Before we move onto the next compo, which'll probably be the scrolling engine, we're going to vote on whether this should be in QB - a sort of final fling (We all know that FB will take over QB eventually... Woohoo!) or in FB.

So keep your eyes for the right compo for you! It'll come along! These are a few of the compos - the one's that I can think of off the top of my head... There will probably be more.

> - Manuscript
> - Scrolling Engine
> - Tileset
> - Character Sprites
> - NPC Sprites
> - Map Editor
> - Maps1: World map and City maps (All outdoors)
> - Maps2: Indoor maps
> - Scripting Engine
> - Game Scripting
> - Battle Engine
> - Battle Character Sprites
> - Battle Enemy Sprites
> - Battle GFX
> - Sound System
> - Sound effects and Music composing

After all the sub compos are complete, there will be a final compo. Putting it all together. The final compo takes the winning components that have not already been merged (some will already be merged, like the tileset and the scrolling engine) and puts them together producing a FINISHED rpg! This last compo is going to take some skills though, because although we will try and keep all of the compos compatible (as in if the scrolling engine uses 32*32 tiles then the tileset can't be 16*16), some incompatibility issues are bound to surface.

Okay, I think that's about it from me, that's all I can think of to say - but I'm notoriously forgetful... So I'm sure I forgot something... Oh! I know - the winner! The winner will probably be the one who won in the most categories.

Okay, I'm done. WAIT! Can I say hi to some people?

Hi Dad! Hi sis! I'd like to thank my dog, for jumping on me everytime I fall asleep, and I'd like to thank the corrupt school system for making me have to be homeschooled for like 5 years and giving me no social life which made me turn to QB out of pure boredom! I'd like to thank the QB RPG titans for making QB RPGs so successful!

Now... JOIN!

Visit QBasic.tk and join this awesome competition!

## BASIC Goes Mobile

### Written By Matthew R. Knight

A BASIC interpreter upon thine mobile phone? Surely thou jest! But no, for tis true...

Yes, it really is true. Our favorite programming language has at last joined the mobile phone revolution, in the nubile form of the appropriately (if not somewhat unimaginatively) named interpreter, Mobile BASIC, a MIDlet that will instantaneously transform your Java phone into a light-weight programming environment.

The Mobile Basic logo.

The mobile phone, introduced only a decade ago, has already irrevocably changed our lives. It is an instrument that is light enough and small enough to carry in a pocket, yet connects us to our world constantly, stores our entire list of family, friends and business contacts, is more effective than a diary because it is an active reminder of our schedules, can be a watch, a stop watch, an alarm clock, a calculator, an entertainment centre and even a camera. For the first time in history, powerful and genuinely USEFUL computers are two a penny, and now EVERYONE is jacked into the not-so-wired world. Indeed, the pace at which cellular technology has evolved over the last couple of years is truly remarkable. The little phone in your pocket is no longer simply a portable telephone. In the 21st century, there are some things you can take with you everywhere. And now BASIC as well.

Getting started with Mobile BASIC was simply a matter of pointing my Nokia 3410's WAP browser to http://www.mobilebasic.com. Please note that this interpreter is NOT shareware, the unregistered version is available for download on a trial basis only. You are limited to using it 30 times before registration is required, and they've capped the maximum allowable source code at 1K. The paid version currently provides up to 16K for your source code, which admittedly is not much, but it should be sufficient for all practical purposes.

Writing programs on your phone might seem like a neat idea, and it is, but don't expect the same level of user-friendliness that we've come to expect from our desktops. It didn't take long to discover that entering lengthly programs on a typical keypad is positively infuriating and will almost certainly drive you to the bottle. The developer has gone to some length to simplify input, and it does get a little easier with practise, but of course it will never be quite the same as working with a regular keyboard. Many of the latest crop of phones have an integrated QWERTY style keypad, so if you're on the market for a new handset, you'd be well advised to consider that a priority. Debugging also proved to be quite problematic due to the small size of the 3410's screen, but hey, it's BASIC on a 2 year old mobile phone... so I really can't complain.

Mobile BASIC, like any flavour of the language, has its own distinctive features, but it is sufficiently close to the generally accepted standard version of BASIC to be familiar to any BASIC programmer. It comes jam-packed with a wealth of goodies ranging from sprite facilities with collision detection for animation and games, to functions that permit the creation of applications that can communicate with Remote Internet Servers. Ample documentation is available for nothing on the internet and provides a fairly complete reference to the interpreter and its capabilities, with numerous examples of individual commands and a number of short programs. The interpreter also has the ability to create both mobile phone MIDlets and website applets, and an assortment of demonstration programs created with Mobile BASIC are available for you to try on the Mobile BASIC website.

In conclusion, Mobile BASIC is one of the coolest geek toys I've seen in a long time. If you have a Java phone you owe it to yourself to give this a try, it's guaranteed to keep you tinkering late into the night.

-- Matthew Knight (with thanks to Generic for bringing this to my attention on the NeoBASIC board)

Check out the Mobile Basic website or email Matthew.

## Useful Math For QBasic / FreeBasic

### Written By Peter O'Rourke (Marinedalek)

This short article solves two common maths problems in QBASIC and freeBASIC.

The methods covered are:

1. Easy way to define Pi
2. Verifying if a number is prime or not

Hope these will be of use to someone!

### 1. Easy way to define Pi

Pi is the ratio between the diameter of a circle and its circumference. I have often written a program in QBASIC and been annoyed at having to type out:

>     pi# = 3.1415926538... etc.

I had a look on the internet for a solution and found one that caught my eye. Apparently, Pi is the arctangent of 1 multiplied by 4, and luckily enough QBASIC has an arctangent function. So now the statement in my program reads:

>     pi# = 4 * atn(1)

Much simpler! (NOTE: CONST cannot be used as ATN is not a valid constant operator)

### 2. Verifying if a number is prime or not

At some point in your programming life you will want to know if a number is prime or not (for whatever reason).

This simple function checks if a number is prime or not by dividing by integers up to the square root of the number.

It returns 0 if the number is not prime and 1 if the number is prime. The checker wastes time by checking the value with numbers other than prime numbers, but a predefined list of primes would be needed to check for primes, and that would defeat the object of the function.

>       'Prime Verification function
>       'Peter O'Rourke 2004
>       declare function primechk% (checkval&)

>       function primechk% (checkval&)
>        select case checkval&
>         case is = 1		'1 is not a prime number
>          primechk% = 0
>          exit function
>        end select
>        flag% = 1
>        for factor& = 2 to fix(sqr(checkval&)) step 1
>         select case checkval& / factor&
>          case is = fix(checkval& / factor&)
>           flag% = 0
>           exit for
>         end select
>        next factor&
>        primechk% = flag%
>       end function

You can contact Marinedalek over at QBasic News, or visit his homepage.

## Improving the PDS7.1 Error Handler

### Written By Jan van de Poll

> I got the following email from Jan van de Poll a few days ago, regarding his work to perfect the error handler in the "last" version of QB, PDS version 7.1. He sent along a nice tutorial document and a zip file of useful tools to improve the PDS7.1 error handler. You can find the email, the tutorial document and the zip file below. I'm sure you guys will find this interesting!

> -Pete

### The Email

> Pete --

> I have spent quite an amount of time perfecting error handling in PDS7.1.

> I then posted on a couple of newsgroups, to see if anyone was interested. No responses.

> Now I have had lots of help from various forums so I should return some. I know your site is frequented more by gamers and thus dont know if they even concern themselves with identifying errors and handling them.

> But I program in basic & assembly for machines that I manufacture. When the customer creates an error, they ring up and tell me they have a red screen with error details. I can then pop their project on my screen and identify the module and line where the error happened (and give them a cure).

> If you think this may be of interest, then I can send a zip file with the demo project. Enclosed a Text file description.

> > Regards,
> > Dinosaur
> > J.W.van de Poll
> > Technical Manager
> > Compu-Weigh Pty. Ltd.
> > jvp@Compu-Weigh.com.au

### Error Demo Document

Hi all

For those whom are interested in how to handle errors in a multiple module project.After months (on & off) I am finally happy with it. Thanks to some newsgroup contributors.

I use PDS7.1, MASM and UltraEdit in Win2000.

I started trying to replace the Basic Error Handler, however soon discovered that you can't get rid of it. Even if you compile without /E or /X and dont place any On Error statements, the minimal error handler remains.

So concluded that I should make it work for me.

I use a Type to group all my error variables together.

>     Type ErrControl
>     	Errer	AS	Integer
>     	etc
>     End Type

I needed to know the following:

1. Error Number

This is easy,it is waiting in Err.

ErrControl.Errer = Err

2. Module where Error happened.

As long as the Error gets trapped within that Module, after the GetRegs line at the trap,

>     ErrControl.Module = 2		'or whatever

3. Line where Error happened.

Not so easy.

Luckily basic leaves a few clues behind.

I got those clues by scanning with codeview until I saw a pattern. GetRegs.asm gets the Offset and Segment. Subtract the Segment from the Starting Segment and you have a Segment:Offset address that is somewhere in the Map file created at Link time (if you compile /Zi and link /CO).

But on my projects this file was too big to load for searching. So the easiest way was to split the Map file into smaller Map files for each module. Originally I did this manually with Cut & Paste, but then automated it, as each time you make a change, the likelyhood of the error address changing was to great. The line number in the Map file is the true line number including comment lines.

4. Filename current during Error.

Whenever a file is opened, I don't use the file name, or a obscure string,I use ErrControl.File. So once you have concluded the name of the file to open, then

>     ErrControl.File = "C:\MyFile.txt"
>     Open ErrControl.File for Input AS #Whatever
>     etc

If there is an error, then that filename shows up in the handler.

5. Getting Module level Error traps to work.

I tried searching the Help files, but no demo on how to do.

After much trial & error:

The first step is to enable the error traps in each module.

Well, just call a routine that resides in that module which has

>     ON Error Goto ErrTrap2

Then (I didnt know you could do this) place a module level line outside of any routines,

>     ErrTrap2:
>     'With error trapping code.

Finally, some conventions.

I never use "Call" to call a routine.

If you use call and forget to Declare the routine, basic can do some funny things. Not using call creates an error if you havent declared it.

I also never use "LET".

### The Error Demo

The files below are just a demo and tested.

Just some cryptic messages put on the screen.

Compile and link first for Codeview to create the Map file.(With MakeCV.bat ?)

Then compile and link normally.(with MakeExe.bat ?)

I have included all the Files used to make this project:

> - Module01.bas
> - Module02.bas
> - ErModule.bas
> - GetRegs.asm
> - MyDecl.dec
> - MakeExe.bat
> - MakeCV.bat
> - Debug.bat
> - Link.rsp
> - ErrDemo.lib (just for the "Exist2" and "StripChar" functions)

Download this demo: errhndlr.rar (49KB)

You can contact Jan van de Poll at jvp@Compu-Weigh.com.au.

## PHP Series, Part One

### Written By 19day

> I know what you're thinking -- a PHP tutorial in a QBasic magazine? These languages are not related even in the slightest! But when 19day pitched this series to me, I figured that there are a whole lot of programmers in the QB community, and most of them don't even touch QB anymore (face it, it's the truth). On the other hand, most of them have websites...and a lot of those websites, well, kinda suck. This tutorial will certainly be of great interest to the QB community, and 19day's even written the tutorial from a QB programmer's perspective. PHP is quickly becoming the most popular web language, and if you haven't started learning it, now's the time!

> -Pete

## Preamble

QB programmers often create webpages to show off their creations and to serve as an online web presence. However, sometimes the end result looks a little aesthetically displeasing, and that does have, I feel, a direct impact on how people will view the quality of the programs and demo’s featured on that page (at least, on whether or not they will be downloaded.) That isn’t a judgement, my page sucks too, but I prefer a minimalist look, but alas, I cannot tell you how to make a wicked layout and such. What I will be talking about, for the most part, is PHP, to allow you to create more interesting pages and utilities. I will also touch on CSS and XHTML as well, as they are a part of the whole web-design sphere of interest. This will hardly be exhaustive or even insightful, but is meant to be a jumping-off point, so that interest in these topics will be had, and cause the reader to delve further into the topics of their interest.

## XHTML/CSS

First off, I recommend that you try to write your pages using XHTML Strict. Strict is what it says, which causes validation to be particularly rigid. If there are some tags or attributes that you need, they might be found in the XHTML Transitional mode. Of course, this implies that eventually you would want to make all the pages strict, but for whatever reason you can’t, so this exists for that purpose. XHTML Frameset is for frame pages. This isn’t particularly hard; it only requires some conversions, and cleaning up sloppiness. Basically, without going into too much detail, what is required to validate to XHTML includes the following: using lowercase tag names and attributes, thus <A HREF=“…”> becomes <a href=“…”>, all opened tags must be closed at the same level as the opening (so no interleaving tag opens/closes), and only using tags and attributes that apply the type document (Strict, Transitional, Frameset).

One of the more annoying things of strict is that you cannot use the “target” attribute in links. This can be faked by using javascript, or you can just ignore it, since a document marked as Strict but fails to validate as such will work just as well, and browsers will allow it to work. The whole point it just to force you to make clean pages that will work properly with the newer browsers. Validate your pages here: http://validator.w3.org/

Of course, with XHTML comes the loss of the document formatting features like the FONT tag provided. The intention is that you use Cascading Style Sheets for all your formatting needs. CSS definitions can be imported from outside the current document, defined within the document, and also specified as “style” attributes on most tags. These are fairly easy to learn, and I suggest you adapt to use them. Learn more about CSS here: http://www.w3schools.com/css/default.asp

## PHP

Now that the basics for the actual webpage are out of the way, time to talk about the meat of the matter, PHP. PHP stands for, annoyingly enough, PHP Hypertext Preprocessor. It is a scripting language that is embedded directly into HTML documents. However, for the most part, servers will only process PHP code in documents with the extension php. PHP allows you to do a lot of the jobs CGI and ASP allow you to, but as it’s open and is available on many of the servers I’ve come across, I tended to use it.

PHP, as I said, is embedded in web pages, and it is executed on the server side of things, and the final output is sent to the browser, which is usually HTML data, but PHP can be used as, say, image files, where the php script can send the appropriate headers and data. The upshot of which is you can do things like The Car with his random image avatar. This means that if someone tries to view the source of a PHP file that was served to them (and assuming the server handled the php) they will only see the end result of the processing, not the source code for the php, which is in contrast to javascript, which is often used for client side scripting and of course would be visible if viewing the source. Another nice feature of PHP is that you ‘escape’ into it, using the tag <?php to enter a php section, and ?> to exit. Between php chunks, normal html tags and data can be used, so you don’t need to do a lot of bulky printings of html to generate the page.

I suppose first things first would be to determine if you can run PHP on your server at all, and if so, to get a little information about it. First, you must create a page, let’s call it test.php. Here are its contents:

<?php phpinfo(); ?>

Now you should upload this to your server. Access it… if you get nothing interesting, like perhaps the code itself, then it is possible that your server doesn’t handle PHP, unfortunately. Or, perhaps, you need to do some other setup, in which case you’ll have to read up on your server’s php usage protocols. At my school, we have to use a CGI handler, which is considered by php.net to be a bad setup, heh. Anyway, if all is well, you’ll see a generated page giving lots of information about the server’s installation of PHP and some of the information that you can access. Take note of the version number, as PHP has changed a few times from versions 2 to 3 to 4. I’m using a version of 4, but most of the things in this tutorial should still apply.

If you already know a language like C, C++, Javascript, Java, and the like, then you are halfway home, since the syntax of PHP is fairly similar, so at most you should scan the Appendix because there are some differences. If you’ve only ever used QB, you might want to read the Appendix before continuing.

### First Example

So lets now tackle a simple program and introduce some interesting elements, and then I’ll discuss them after the fact. Note that the generated pages for these examples won’t necessarily conform to the xhtml/css things I said earlier, heh, which is mainly for brevity.

>     <html>
>     <body>
>     <?php

>     //determines the factorial of $val, 0 if $val is not an integer
>     function factorial($val)
>     {
>       if (is_int($val) == false || $val <= 0) return 0;
>       if ($val == 1) return 1;
>       return $val * factorial($val - 1);
>     }

>     $num = 6;
>     echo “The factorial of $num is “;
>     echo factorial($num) . “<br />“;

>     /* now for something odd */
>     $num = “boink”;
>     echo “The factorial of $num is “;
>     echo factorial($num);

>     ?>
>     </body>
>     </html>

So what does this do? Well, first we define a function called factorial, which takes a single variable, $val. You’ll first note that variable names always start with $, the rest of the variable name follows the usual form other languages allow for the most part. You’ll also notice that the types of variables are not explicitly specified. This allows flexible and also chaotic code, just nod and smile.

The first statement in the function immediately makes the function bail out with 0 if one of two conditions is true. The second is most obvious, if the value of $val is less than or equal to 0, then return zero. The first condition employs the function is_int to determine if $val is an integer (or, so say the docs, a numeric string, but ignore that), if it isn’t, then return 0. There are many of these types of functions to determine the types of data.

The following line has the function return 1 if the parameter $val is 1.

The next line does a little recursion, with which I hope everyone is familiar. If you aren’t, here’s a quick explanation, the returned value from the function is the current value of $val multiplied with the returned value of factorial with the parameter $val minus 1. This cascades or recurses back down the values until hitting the base case, where $val is 1, which breaks the recursion, and causes it all to collapse the stack and return the actual factorial of the original call. Now all that was just the function.

Now we create the variable $num and assign it the number 6, then echo/print out the string informing the user of what’s going on, and then echo’s the result of calling the function. An interesting thing here is that you can use a variable name inside a string without any special handling, since in a string, the $ character is special, to escape it to actually print “$num”, use the usual escape backslash character, as “\$num” which would actually print $num instead of 6.

The second block does the same, but reassigns the value of $num to the string “boink”, which just causes the factorial to be 0.

You’ll notice a few things, there is no declaration of a variable needed, just use it (a la QB), and as the variables are untyped, you can assign different types of data to a variable on the fly.

You’ll also notice that C style comments are in there, and that we escaped into PHP in the middle of the HTML document without problem, and also that since it’s an HTML document, we can’t just add a newline to the echo string to get to a new line, we need to add a <br />, spiffy. Of course, if the output were generated to a text file or something, then that would change, so keep the context in mind.

### Escaping into PHP

Escaping into PHP works as it should, most of the time. There are funky ways you can do things, that don’t seem all that nice and clean, but you can do it. But you can use it to interesting effect, like:

>     <html>
>     <body>
>     <?php
>     function say($t)
>     {
>     ?><h1><?php echo $t ?></h1>
>     <?php
>     }
>     say(“hello”);
>     say(“there”);
>     ?>
>     </body>
>     </html>

We escape back into HTML in the middle of the function, to wrap the echo’ed output in an H1 tag. If this is run, and we view the source generated, we get this:

>     <html>
>     <body>
>     <h1>hello</h1>
>     <h1>there</h1>
>     </body>
>     </html>

### A Hit Counter

To end this part of the tutorial, here is the code for a very simple webpage hit counter, I will explain the code after. There, are of course many different ways to code something like this, so this is just one way, and not necessarily the best way, or dare I say it, a good way :P

Put this code in a file called counter.php

>     <html>
>     <body>
>     <?php
>     $fp = fopen(“count.txt”, “r+”);
>     flock($fp, 2);
>     $count = fgets($fp, 4096);
>     rtrim($count);
>     $count += 1;
>     fseek($fp,0);
>     fputs($fp, $count);
>     flock($fp, 3);
>     fclose($fp);

>     echo $count;
>     ?>
>     </body>
>     </html>

Now the purpose of this code is to increment the counter variable, keeping it in non-volatile storage, and displaying the new value in a simple html block.

First, the counter file is opened in r+ mode, which is read/write. The file handle is returned and stored in the variable $fp. This file handle is what we will use to interact with the file later, like a QB file number.

Then we lock the file, this is because multiple people may be accessing the webpage and cause the code to be executed multiple times in parallel, so locking the file prevents race conditions, as when the file is locked, other attempts to open it must wait until it is unlocked.

Now we get the first 4096 bytes of the file into a string variable $count, trims out the extra space, and then increment the value. PHP gracefully handles numeric strings and integers, and handles the conversions implicitly, though you can’t always rely on it.

The next lines put the cursor position into the count.txt file to be at the start again, writes the contents to the file (which is the previous numeric value incremented by one), and finally unlocks the file, as the next line closes the file completely.

The last line echoes $count to the browser.

Couple of extra notes here: This code presumes there is a file called count.txt in the present working directory of the script, which presumably was initialized with the contents of 0, and that the script can read and write it. The writing bit is a bit of a problem sometimes… it comes down to what role the execution of the script runs under. On some servers, the executing process of the PHP runs under nobody or perhaps the apache user, and probably does not have authority under user or group to write to the file, in which case you’ll have to make the count.txt world writable. On another server I’ve experimented with PHP on, they give the scripts the same access rights as me myself if I log into the server, which makes things a little nicer. You’ll have to determine how it works with where you intend to mount the pages.

## Appendix

### Syntax

For those who have only ever used QB, a newline in QB denotes the end of a statement, or a colon (for multiple statements on the same line). In PHP, as in C, C++, Java and many others, the semicolon denotes the end of a statement. So you can legally have, dothis1; dothis2; dothis3; However, this is usually not done for aesthetical reasons.

The looping structures and if blocks use a block delimiting technique different from QB. QB uses commands that denote the beginning of a block with the command itself, like DO or IF something. The end of the blocks are the properly nested LOOP or ENDIF. In PHP, like C, use curly braces to denote the blocks of influence. Blocks basically make several statements, into “one” statement. That is, am if statement only executes the one statement after it, but if you need to execute more than one, then you must wrap it in a block. If there is only one statement (where that statement could even be another blockable statement like if or for) then you don’t technically need the curly braces, but everyone has their own coding style.

So, for example:

>     if (false)
>     {
>       dothis1;
>       dothis2;
>     }

So what this does, is if false is true (which, luckily for logic, it isn’t), statements dothis1 and dothis2 are not executed.

Now drop the curly braces:

>     if (false)
>       dothis1;
>       dothis2;

Now what happens, false is still false, so dothis1 is not executed, however, dothis2 is. Hopefully this makes sense to everyone.

Further to that, you can do things like this

>     if (cond1)
>       if (cond2)
>        if (cond3)
>          dothis;

VERY IMPORTANT: this might save you some headaches later on if you look for this when code goes awry. The semicolon, as said above, marks the end of a statement. With if and looping blocks (mentioned below) you tend not to put a semicolon after them, as that ends the statement, and the rest of the block is left to do it’s thing with no respect to the previous control element. For example, the example

>     if (false)
>     {
>       dothis1;
>       dothis2;
>     }

If we make a subtle change, and accidentally put a semicolon after the end bracket on the if condition as such

>     if (false);
>     {
>       dothis1;
>       dothis2;
>     }

Then dothis1 and dothis2 will execute just fine. According to the language parser, the command it must not execute (due to the false condition) is the empty statement. This is allowed. And the other two statements execute just fine, as you can legally just use a block, or nested blocks, anywhere you want.

Blocks also involve the concept of scope (as do functions), see the Scope section for more information.

### Control Elements

Now that we have a basic understanding of PHP, I’ll run down some of the elements and give little examples that will give you some more tools.

#### if elseif else blocks

These work as usual, you have your if with the condition in parenthesises afterward. The elseif words indentically to having an else if statement as in C. An interesting sidenote here is usually we have, to check equality, a == b, as C. PHP introduces the === operator. See the operator section for details.

#### while, for

The while works like in QB,

>     while (cond) { do stuff  }

for has a structor identical to C and the like, which is different from basic. It has the form

>     for (exp1; exp2; exp3) {do stuff }

exp1 is an expression that is executed once, just before the loop begins, exp2 is evaluated for truth at the end of each iteration, if it evaluates to false, the loop is broken, exp3 is executed at every iteration. Sounds complicated, and indeed it can be, I’ve seen people do all sorts of interesting things in those 3 expression, I tend to keep them simpler, for easy reading. So for QB’ers who have no idea how this structure works given my description, here is the PHP loop equivalent of FOR i% = 1 to 10: dothis : NEXT i%

>     for ($i = 1; $i <= 10; $i++)
>       dothis;

The first expression initializes our $i variable, the second continually returns true until $i passes 10, and the third expression increments $i by one (the ++ operator will be seen later)

#### break, continue

These are two statements which have an effect on a loop, and only have meaning when inside a looping block. When a break statement is reached, the loop is immediately terminated. When a continue statement is reached, that current iteration of the loop is terminated, and control passes up to the start of the loop again, incrementing and re-evaluating the loop’s termination conditions.

An example:

>     for ($i = 0;  ;$i++)
>     {
>       echo $i;
>       if ($i < 3) continue;
>       break;
>     }

$i is set to 0, and will increment at every loop. The usual termination condition in this loop is empty, and a condition of true is assumed. So this could loop forever… It prints 0, and then checks if 0 < 3, which it is, so it continues, goes to the top of the loop, increments $i. It prints it, 1, and continues again… when $i is 3, the if statement fails, 3 is not less than 3, the continue statement is skipped, and hits the break statement, which breaks the loop completely. Thus, the expected output of this is 012.

Note on scope: break and continue affect the inner most loop that they appear in. If you have a 3 deep series of loops, and in the inner most one, you decide there is a condition where control should break out of all 3 loops immediately, or ‘continue’ all three loops, you can specify a number after the break or continue statement to indicate how ‘deep’ to apply the break and continue statement. Other languages tend not to have this, and require flag variables and breaks, labelled breaks, or goto’s (which are like labelled breaks and one of the few good times to use goto, but note that goto doesn’t exist in php anyway). There is a potential for irritating bugs here… if you use a numbered break, for example, and then alter the code to add another loop on the outside, the numbered break no longer breaks out as far as it should.

#### switch

As in C, as here, is irritating, and the structure that allowed Duff’s Device (look it up, it’s amusing).

Basically, the switch statement is analogous to the QB SELECT CASE construct, with a few differences. The important thing to remember, to mimic a SELECT CASE with switch, is to break (switch statements are, in PHP, considered to be sort of a looping structure, just for the use of break and continue) at the end of every case-content, otherwise, control falls through into further cases. Here is a basic example, of which you should be able to immediately relate:

>     switch ($i)
>     {
>     case 0:
>        echo “i is 0”;
>        break;
>     case 1:
>        echo “i is 1”;
>        break;
>     case 2:
>        echo “i is 2”;
>        break;
>      default:
>        echo “i is something else”;
>        break;
>     }

Notice the breaks, they cause control to leap to the end of the switch, which is what you’d normally want.

However, if you were to remove all the breaks, and say, $i was 1, then the first condition would be skipped, then the second would execute, saying “i is 1”, but then go on and say “i is 2” and then “i is something else” This is what it means for control to fall through. It can be use to elegant effect, but usually it just makes things harder to read, and thus, harder to maintain.

Oh, and note that the else case here is just called default, and technically we don’t need the break after its statement.

And due to switch being a “loop” structure, according to the parser, you can use continue in here, but it acts like break. And using numbered breaks and loops (if say, the switch is inside a loop) does what is ‘right’.

#### return

For our purposes, this is simple. In a function, when you want to return the value (and also immediately end the function), use return (value_exp). If the function returns nothing, just plain return.

### Operators

Not all of them are listed, as we haven’t covered everything allowed by the language yet, but here are the basics:

#### Arithmetic:

+ - * / are as you expect, modulus is %

#### Assignment:

= sets the left to be the right, as you’d expect. However, equality-comparison is NOT = alone. This is often a good place for bugs to crop up.

Note that some operators can be combined with the assignment operator, such as addition, to create +=, where $i += 2 is equivalent to $i = $i + 2

#### Comparison:

> - == is for equality
> - === is for equality and if both variables are of the same type (but this is only in PHP4 and up)
> - != and <> are both for non-equality
> - !== is for non-equality and non-same-typed (again, PHP4)
> - and > >= < <= are as you expect

#### Inc/Dec/rementing:

++ and -- increment and decrement a variable respectively. They can be applied as a suffix or prefix.

The statement echo ++$i displays the value of $i incremented by one, however, echo $i++ displays the value of $i before the increment, and then the increment occurs. It is a subtle difference and often causes hard to track bugs, so unless you’re comfortable with it, I would tend to just use the suffix form, and as a statement to itself, so no matter what happens, I know the intention.

#### Logical:

&& and || are for “and” and “or” respectively, ! for not, xor for itself.

The keywords ‘and’ and ‘or’ exist as well, for use instead of && and ||, however, they operate at a different precedence, and things tend to get confused. As this is like C and such languages, and they use && and ||, I would stick with that.

#### Short-circuiting:

This is apparently present in PHP4, but perhaps not earlier. It is merely a way of ending evaluation of a series of logical equivalences, if there is no need to continue.

For example,

>     if (cond1 && cond2) something;

Now, without short-circuiting, cond1 is evaluated, cond2 is evaluated, and they are anded to determine the final Boolean result. Now, with short circuiting, processing would start with cond1, if it were false, and then the process sees that it is being anded with something, it doesn’t even need to look at cond2, or evaluate it, since we know that if something is anded with something, and one is false, the whole thing is false. Similarly with an ||, if the first is true, the second condition is ignored.

This is usually well and good, but it can lead to some interesting troubles if you’re not careful, such as:

>     if (($d != 0) && ($n / $d == 2)) something;

So we have here two conditions to be evaluated, and they are anded together. In language/compiler/interpreter that didn’t use short circuiting, this would error out. Why? Well, if $d was 0, then the first condition would evaluate to false, but it would try to evaluate the second condition, and get a Division By Zero warning. But, with a short-circuiting system, we can do this.

Is this coding style bad? Well, sometimes it can make things less readable, in that some combinations of events aren’t immediately apparent in what they do and if they are executed. Further, we decide that we want to do some extra work in the case where the division results in 2, before work done if the denominator was zero, we might split up the if statement into a nested structure, and if the division condition was the outer if, then it would blow up again.

#### string:

The . operator is concatenation.

.= works like the combined arithmetic operators.

(There is lots to say about strings in general, which might be in a future tutorial.)

### Constants

>     define(“constant_name”, “constant_value”);

When referring to a constant, there is no preceeding $

The scope of a constant is superglobal.

### Scope

PHP tends to have only one scope, so if you had code such as

>     {
>       $newvar = 10;
>     }
>     echo $newvar;

Where $newvar didn’t exist until now, it will indeed print 10. However, once you use user defined functions, scope comes into play.

>     $newvar = 10;
>     function dothis()
>     {
>       echo $newvar;
>     }

This will fail to do what is expected, as global scoped elements are not seen. There are a couple of ways to be able to see global variables. One is to use the global keyword, which binds a global variable to the current scope:

>     $newvar = 10;
>     function dothis()
>     {
>       global $newvar;
>       echo $newvar;
>     }

Also, you can use the $GLOBALS array, which is superglobal (PHP4), that is, it automatically exists in any scope. So the function could be written as such:

>     $newvar = 10;
>     function dothis()
>     {
>        echo $GLOBALS[“newvar”];
>     }

## Postamble

I know we didn’t get to much actual fun stuff this time around, but hopefully I’ll be doing that in the next tutorial. I hope to cover such things as references, arrays, passing data to PHP, more filesystem stuff and perhaps MySQL if I’m feeling up to it. There’s still is a lot to talk about. Anyway, if you want to delve into more PHP, check out www.php.net

And a note about the contents of this tutorial and the code: I can’t guarantee the accuracy of everything here, or that the code won’t explode the universe or anything, which is the usual thing people say. Even more, PHP has undergone many changes, I tried to list some of the things I’ve used in PHP4 that didn’t exist before, but other things are probably floating around, so beware. And as programming languages are complicated beasts, I may have made mistakes just in some of my statements, or my explanations, but I think everything there is fine, or at least, suitable for the current context, which is just getting people off the ground in using PHP.

Contact 19day at admin@SPAMMY19day[d0t]com or visit him at http://19day.com
Download a Word (.doc) version of this tutorial here.

## Programming GUIs in QBasic Part Two:
Textboxes

### Written By VonGodric

Hello to you all who read this. I hope it will be a bit more useful then previous one, though not as long because my time at the moment is limited. In this part I will concentrate on Textboxes. Why are they needed? Let’s see. In my opinion every self-respecting game has a text input routine somewhere in the game - either to just get Player name or even save-game name. So they are useful for getting all kind of information from the user. So better their done, more attractive UI of your game/program is. So let’s start then.

### Textboxes

Just like I said in previous Part about Buttons, the same applies to the Textboxes –there are many ways to create them. And sometimes it is not efficient to code a whole textbox routine into your program/game if you for example use it only once. It’ll be a waste of space. But if you use them many times then more complicated handling routine is in order. What is Textbox? It is a GUI widget where you can nicely enter user input (from the keyboard). The simplest one in Qbasic is: INPUT Textstring$. Where Textstring$ will hold the data you enter from the keyboard. But now comes the tough part. Let’s say while user enters his name into textbox, you want also to show time or some animation on the screen at the same time… or just use textboxes in some Vesa mode under some Gfx library? Like Future.Library for example doesn’t have any textboxes. So, one solution is to do it ourselves.

In Basic idea of the textbox, you read user input by one keystroke at the time (aka: Key$ = INKEY$), if the key pressed it is a printable character (letters: uppercase: “A” to “Z” and lowercase: “a” to “z”, numbers 0-9 and etc) then you add it to the buffer string. And if it is for example backspace then remove last character from the string. Before we can go more deeply into this we need to go through one thing. ASCII character set.

### ASCII Character-set

ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort. Every letter or number has its own number in the ASCII table, but so do all the keys. After all letter “a” is one key on the keyboard and so is backspace. The standard ASCII character set consists of 128 decimal numbers ranging from zero through 127 assigned to letters, numbers, punctuation marks, and the most common special characters. The Extended ASCII Character Set also consists of 128 decimal numbers and ranges from 128 through 255 representing additional special, mathematical, graphic, and foreign characters. In all what ASCII is will be out of the bounds of this tutorial so I just do a short introduction on how to use them in Qbasic.

NOTE: In Qbasic you can get ASCII Character-set in the help. It depends of the version, but it is usually: Help-> Contents-> ASCII Character Codes.

So Type in the following example:

>     CLS
>     LOCATE 1, 1: PRINT "Character    ASCII code:"
>     x = 2
>     DO
>        a$ = INPUT$(1)
>        LOCATE x, 1
>        PRINT a$
>        LOCATE x, 15
>        PRINT ASC(a$) 'Print ascii number of the character
>        x = x + 1
>        IF x $gt;= 24 THEN 'if screen is full
>           CLS
>           LOCATE 1, 1: PRINT "Character     ASCII code:"
>           x = 2
>        END IF
>     LOOP UNTIL a$ = CHR$(27) 'do until ESC is pressed

It will return ascii code of every key you press. However you may notice that sometime it returns only 0 –- don’t worry, these keys are handled specially. Now about few functions used in the program: ASC turns any character into ASCII number and CHR$ turns ASCII number into character. To see more about the matter go to: http://www.asciitable.com/

For what is this ASCII anyway? If we program Textbox we need some way to define what key is pressed. We can of course do something like: If Key$=”a” or Key$ =”b” or Key$=”c” and so on and on, but THAT would be really not efficient. And slow too to process, and impossible to debug… (And I’ve done that when I was younger) And what if Backspace is pressed?

So we need ASCII. Some values we are going to need.

ASCII Codes
Uppercase Characters | “A” to “Z” | 65 to 90
Lowercase Characters | “a” to “z” | 97 to 122
Numbers | “0” to “9” | 48 to 57
Other tokens | “! " #$%&'()*+,-./” “:;<=>?@” “[\]^_`” “{|}~” | 33 to 47 58 to 64 91 to 96 123 to 126
Enter key |  | 13
Esc key |  | 27
Space |  | 32
Backspace |  | 8

Or all printable characters from 32 to 255 with exception of 127 which is delete key.

So as you see it is also easy to group these different characters. And let’s say to make a textbox that accepts only numbers, or symbols and so on. Or for example only every third letter from the alphabet.

### First textbox

As most of the time coding in QBasic people don’t need complex textbox system and It’s easier to understand if start from a smaller and easier things and then to move on to more complex. This will be something like Qbasic’s Input. But it will be a textbox and logic here will be used also later on. I also will use same Print and mouse routines I used in a previous tutorial. But it can easily be tweaked to work with any Gfx library or routines. And also it is completely un-optimized yet. Also you’ll need a file “Cradle.bas” what comes with this tutorial. It has nothing except mouse and special print routine I’m going to use.

Enter the following code in the “cradle.bas” between “User code:” and “User code ends here:” or open “tb1.bas”

>     SCREEN 12
>     PAINT (1, 1), 1
>     InitMouse

>     TextBoxLenght = 15   'Set textbox size
>     ReDrawTb = 1         'Textbox flag, if 1-then redraw
>     TextBoxX = 100
>     TextBoxY = 100

>     DO
>        Key$ = INKEY$
>        IF LEN(Key$) THEN          'If some key is pressed down
>           SELECT CASE ASC(Key$)   'Get ASCII code of the key.
>           CASE IS > 31            'Any printable character
>              IF LEN(Buffer$) < TextBoxLenght THEN
>                 Buffer$ = Buffer$ + Key$
>                 ReDrawTb = 1
>              END IF
>           CASE 8                  'Backspace
>              IF LEN(Buffer$) > 0 THEN   'If there is smth in Buffer$
>                 Buffer$ = LEFT$(Buffer$, LEN(Buffer$) - 1)
>                 ReDrawTb = 1 ‘set flag. If is 1 the redraw textbox
>              END IF
>           END SELECT
>        END IF
>        IF ReDrawTb = 1 THEN
>           ReDrawTb = 0 ‘turn flag off
>           Xp = TextBoxX
>           X1p = TextBoxX + TextBoxLenght * 8 + 10
>           Yp = TextBoxY
>           Y1p = TextBoxY + 12
>           LINE (Xp, Yp)-(X1p, Y1p), 15, BF
>           LINE (Xp, Yp)-(X1p, Y1p), 0, B
>           printF Buffer$ + "_", Xp + 2, Yp + 3, 0
>        END IF
>     LOOP UNTIL Key$ = CHR$(27)
>     SCREEN 0

As you see the logic and the code is pretty simple. All needs to be done are: read value from user input, check what type is it and take action accordingly. Now the same code will work also if we put it into function with few minor changes. Like that: (you can either type it yourself or “open tb2.bas”)

>     function TextBox$ (TextBoxX, TextBoxY, TextBoxLenght)
>     ReDrawTb = 1         			'Textbox flag, if 1-then redraw
>     DO
>        Key$ = INKEY$
>        IF LEN(Key$) THEN		'If some key is pressed down
>           SELECT CASE ASC(Key$)	'Get ASCII code of the key.
>           CASE IS > 31            		'Any printable character
>              IF LEN(Buffer$) < TextBoxLenght THEN
>                 Buffer$ = Buffer$ + Key$
>                 ReDrawTb = 1
>              END IF
>           CASE 8                  		'Backspace
>              IF LEN(Buffer$) > 0 THEN   	'If there is smth in Buffer$
>                 Buffer$ = LEFT$(Buffer$, LEN(Buffer$) - 1)
>                 ReDrawTb = 1
>              END IF
>           case 13			‘if enter key is pressed
>           	TextBox$ = Buffer$	‘return function value
>           	exit function		‘exit function
>           END SELECT
>        END IF
>        IF ReDrawTb = 1 THEN
>           ReDrawTb = 0
>           Xp = TextBoxX
>           X1p = TextBoxX + TextBoxLenght * 8 + 10
>           Yp = TextBoxY
>           Y1p = TextBoxY + 12
>           LINE (Xp, Yp)-(X1p, Y1p), 15, BF
>           LINE (Xp, Yp)-(X1p, Y1p), 0, B
>           printF Buffer$ + "_", Xp + 2, Yp + 3, 0
>        END IF
>     LOOP UNTIL Key$ = CHR$(27)
>     end function

As you might notice, now we pass textbox x and y positions also textbox length to a function. It is improvement over previous example. Now to use it you need: TbText$ = TextBox$(Xpos, Ypos, Length) in main code. But still this is not perfect, if we are using textbox, everything else stops and it is not mouse clickable. To solve this problem we need to make a system that would detect if mouse is clicked on the textbox or not. Very similar to buttons isn’t it? Actually logic here is almost identical. Though there are few things need to be done. Like user defined type to hold textbox data:

>     TYPE TextBoxData
>     	Xpos  AS INTEGER
>     	Ypos  AS INTEGER
>     	X1pos AS INTEGER
>     	Y1pos AS INTEGER
>     	Lenght  AS INTEGER 'sixe in characters
>     	Status  AS INTEGER 'if 1 then exists
>      END TYP

>     DIM SHARED tb(NofTb)  AS TextBoxData
>      DIM SHARED TbText(NofTb) AS STRING
>      DIM SHARED Key$
>      DIM SHARED TextBoxTemp

Some things are same as with buttons. Length as said is the textbox size in characters. Status holds a flag if is used or not. Also I dimmed TbText() as string. It’s because if to define string in the TYPE structure then it’s only fixed length, this way we can have nonfixed length string for textbox.

Next similar to buttons we need to make a function that creates the textbox.

>     FUNCTION CreateTextBox (TextBoxX, TextBoxY, TextBoxLenght)
>     'create new textbox
>     'first find if there is some free textbox left
>     FOR i = 1 TO UBOUND(tb)
>     	IF tb(i).Status = 0 THEN
>     		TbID = i
>     		EXIT FOR
>     	END IF
>     NEXT

>     IF TbID = 0 THEN EXIT FUNCTION 'if no free textbox was found then exit

>     tb(TbID).Status = 1        'assign values
>     tb(TbID).Xpos = TextBoxX
>     tb(TbID).Ypos = TextBoxY
>     tb(TbID).X1pos = TextBoxX + TextBoxLenght * 8 + 10
>     tb(TbID).Y1pos = TextBoxY + 12

>     tb(TbID).Lenght = TextBoxLenght
>     drawTextBox TbID, 1        'Draw textbox
>     CreateTextBox = TbID       'return tb id

>     END FUNCTION

The code should be sinple. If some statusin the array of textbox data is 0(meaning free) then use it. Fille with data and call drawtextbox() wich only draws textbox to the screen.

>     SUB drawTextBox (TbID, Action)
>     'Action -what to do
>     '2    update text
>     'Mouse pointer off
>     '----------------
>     MousePointer (2)
>     '----------------

>     Xp = tb(TbID).Xpos
>     X1p = tb(TbID).X1pos
>     Yp = tb(TbID).Ypos
>     Y1p = tb(TbID).Y1pos
>     LINE (Xp, Yp)-(X1p, Y1p), 15, BF
>     LINE (Xp, Yp)-(X1p, Y1p), 0, B
>     IF Action = 1 THEN PrintF TbText(TbID), Xp + 2, Yp + 3, 0
>     IF Action = 2 THEN PrintF TbText(TbID) + "_", Xp + 2, Yp + 3, 0

>     'And back on:
>     '----------------
>     MousePointer (1)
>     MousePointer (3)
>     '----------------

>     END SUB

I’m sorry if it looks a bit too lame or too simple(you can improve it), but I try to keep simplicity.

Now that these two routines are clear to us (I hope you understood) we need to make one final part of the textbox –the handling routine. By the system, it is similar to buttons. We have to check if the mouse cursor is on the button or not, if is then decide what to do. I tried to keep it simple.

>     SUB TextBoxSystem
>     Key$ = INKEY$

>     'This sub is the place where main textbox handling is done.

>     'If some textbox is already active
>     '---------------------------------------
>     IF TextBoxTemp > 0 THEN
>     	IF Key$ > "" THEN
>     		Buffer$ = TbText(TextBoxTemp)          'for simplicity
>     		TextBoxLenght = tb(TextBoxTemp).Lenght
>     		SELECT CASE ASC(Key$)   'Get ASCII code of the key.
>     		CASE IS > 31            'Any printable character
>     			IF LEN(Buffer$) < TextBoxLenght THEN
>     				Buffer$ = Buffer$ + Key$
>     				ReDrawTb = 1
>     				TbText(TextBoxTemp) = Buffer$
>     			END IF
>     		CASE 8                  'Backspace
>     			IF LEN(Buffer$) > 0 THEN   'If there is smth in Buffer$
>     				Buffer$ = LEFT$(Buffer$, LEN(Buffer$) - 1)
>     				ReDrawTb = 1
>     				TbText(TextBoxTemp) = Buffer$
>     			END IF
>     		CASE 13, 27             'if enter or esc is pressed then cancel
>     			drawTextBox TextBoxTemp, 1
>     			TextBoxTemp = 0

>     		 END SELECT
>     	END IF
>     	IF ReDrawTb = 1 THEN
>     		drawTextBox TextBoxTemp, 2 'draw tb

>     	END IF
>     END IF

>     '----------------------------------------------------------------------------
>     IF MouseB = 0 THEN EXIT SUB 'if no mousebutton is pressed then exit
>     'now it goes pretty much like with buttons
>     FOR i = 1 TO UBOUND(tb)
>     	IF MouseX >= tb(i).Xpos THEN
>     		IF MouseY >= tb(i).Ypos THEN
>     			IF MouseX <= tb(i).X1pos THEN
>     				IF MouseY <= tb(i).Y1pos THEN
>     					'now if it makes here then mouse cursor is on the textbox
>     					IF TextBoxTemp > 0 THEN
>     						IF TextBoxTemp <> i THEN
>     							'if old tb is active then make it inactive
>     							tb(TextBoxTemp).Status = 1
>     							drawTextBox TextBoxTemp, 1
>     						ELSE
>     							'if mouse is clicked on the same tb then exit sub
>     							EXIT SUB
>     						END IF
>     					END IF
>     					'assign new active tb and exit sub after drawing it
>     					TextBoxTemp = i
>     					drawTextBox TextBoxTemp, 2
>     					EXIT SUB
>     				END IF
>     			END IF
>     		END IF
>     	END IF
>     NEXT

>     'if mouse has been clicked and program reader reaches this point
>     'then it means outside of the tb has been clicked
>     'so any active textbox should become inactive
>     IF TextBoxTemp > 0 THEN
>     	drawTextBox TextBoxTemp, 1
>     	TextBoxTemp = 0
>     END IF
>     END SUB

As you can see from the first part we save into TextBoxTemp the Id of the textbox that is active. If it is above 0 then we check if the key is pressed down. The following code is almost same as was in previous textbox examples. Except it now calls DrawTextBox, instead of drawing it itself.

The rest of the part should be easy because it was used with buttons where it is more in depth explained, but now just for textboxes. If mouse is on the textbox (what is just like button a rectangle specified by four points) and if no then do check if some textbox is active. Though unlike with buttons we here don’t bother with checking if no mouse button has been clicked. Following the comments it shouldn’t be too hard to understand.

As for the example look into “Tb4.bas” there small and pathetic (I know) example on how to use these textbox routines, but here’s the logic: TbText(TbID) holds the string that is entered into textbox. If for example enter (If Key$=Chr$(13) then … ) pressed then you can read from one of the textboxes it’s value. The key can be also for example esc, or any other for that matter.

Now we have small and rather primitive textbox handling routine, but you can improve it –to be for example to make it able to accept larger strings then textbox itself! It’s not very hard. You need the change the limiter of string length and add new variable that for example prints into textbox only last right side of the string that is fits into textbox if the string is larger then visible textbox area. Or for example only accept numbers? Scrollable textbox is a bit harder to make. Then you need to also know the position of the text cursor in your textbox. But you can try.

Download the tutorial and all .BAS source code files in this zip file.
Contact VonGodric at vongodric@hotmal.com or visit one of his WizGUI sites: here or here.

## Final Word

I have to be honest, making this magazine is a bitch. It's soooooo much work. Hours upon hours of boring, grueling emailing, formatting, image editing, research, writing, proofreading and more every month. Putting this together seriously sucks. But when it's finished and I'm putting the final touches on it, it's really satisfying. Then getting all the positive feedback and great responses from everybody afterwards makes it all worth it.

But still remember that I can't do it on my own. I need help from YOu to keep this thing going. When I say I need submissions, I'm serious. I'm not just a nag...this month, only half of the articles people said they'd write actually came in. This magazine is also missing some important sections -- take game reviews, for instance. Also, the comic didn't make it into this month's issue either for some reason. Also, the tutorials section was a whole lot shorter than normal this time around. All these very important sections were either absent or lacking. I'd love to take care of them myself, but I simply don't have the time or the energy to do those articles on top of everything else I've got to do for this magazine and in real life. So please help me bear the burden of this magazine -- contribute! I guarantee you'll find it worth your while.

Oh, and one more thing...before I forget -- Have a happy new year! 2005 could very well be the best year yet for the QB scene. With FreeBasic just starting to gain momentum, who knows what the new year can bring! Whatever happens, though, I assure you that QB Express will be there to cover it.

Until next time...END.

-Pete

Copyright © Pete Berg and contributors, 2004. All rights reserverd.
This design is based loosely on St.ndard Bea.er by Altherac.