# QB Express

### Issue #4 ~ November 28, 2004

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

### In This Issue

Contributors

- Pete (Editor)
- DarkDread
- RelSoft
- Matt2Jones
- Neo Deus Ex Machina
- Adigun A. Polack
- abionnnn
- Piptol
- Na_th_an
- Nekrophidius
- Svante Ekholm
- Joe King
- Stéphane Richard
- Johnathon Simpson
- Ryan Szrama
- 19day

- Regular Columns
  - From The Editor's Desk
  - Letters
  - Express Poll
  - News Briefs
  - Gallery - Two Lords
  - Competition - Text Map Game
  - Comics - Bobby The QBasic Maniac
  - Final Word
- Articles & Editorials
  - Is It A Bird? Is It A Plane? No, It's FreeBasic! - Blitz
  - The QBCPC 2004/2005 Needs Entrants! - Adigun A. Polack
  - Interview with RelSoft - Piptol
  - Interview With Na_th_an - Piptol
  - Joe's Pointless Points - Joe King
  - Beating The XP Straightjacket - Nekrophidius
  - Some DOS Emulation Impressions - Pete
- Tutorials
  - File Manipulation In QB: Sequential Files - Stéphane Richard
  - Lensflares - RelSoft
  - Pixel*Tile Scrolling Engines - DarkDread
  - Data Structures & Algorithms: Pathfinding I - abionnnn
  - QBNow! Chapter 5 - Neo Deus Ex Machina

## From The Editor's Desk

### Written by Pete

First I had finals, so I pushed this issue back a day or two. Then I didn't receive a lot of the submissions that I had been expecting for this issue, so I pushed it back another four or five days. Then, as I was putting together the issue to come out for the delayed deadline, my computer broke. The motherboard got completely fried. The work-in-progress version of this issue was inaccessible for a week. So it got pushed back another 8 days. Oy vey. Right now, QB Express Issue #4 is over 13 days late from its original deadline of November 15th...

...but I can honestly say that it was worth the wait. We've put together another DYN-O-MITE issue this month, and all contributors should be proud of the great work they've done. The level of quality of QB Express surprises even me...this is one impressive little magazine. And I have you all -- the QB community -- to thank.

Last month in my opening letter, I lamented a bit on how the QB community was dying... Just one month later, I'm seeing a complete rebirth. QB has a bright future -- but not in its original form. This month, we bring you information about emulating QB in Windows XP and in other different platforms, and also information about the biggest newsmaker of the year in the QB community: FreeBasic. In just a few short weeks, this 32-bit QB compatible compiler by V1ctor has turned the QB world upside down. It's so popular that it was given its own message forum at QBasic News, and it's become the most visited forum there. Anyhow, Blitz wrote a great article about FreeBasic this month, which everyone should check out.

Also, once again, we've got a collection of great articles and tutorials on all sorts of QB topics. Piptol conducted two interviews with QB gurus Na_th_an and Relsoft. Nekrophidius wrote a great article called "Beating The XP Straightjacket" about DOS emulation and using virtual machines to run QB programs. Also, I followed up this article with a bit more on DOS emulation. Finally, Joe King wrote a few Pointless Points, and Adigun A. Polack is back once again with information on the QBCPC 2004/2005.

As for tutorials this month, we've got a great selection: Stéphane Richard makes his QB Express debut of a new series on File Manipulation in QB. The first issue is on manipulating sequential files. Relsoft is back with a sweet tutorial on Lens Flares. Also, abionnnn has written a tutorial on Pathfinding that you might learn from. As always, we've got Neo's latest QBNow! chapter. And finally, a "lost tutorial" by DarkDread on Pixel*Tile Scrolling Engines is published for the first time...right here in QB Express!

I could go on longer, but I don't want to hold you back from the issue. So...GET GOING!

### 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!

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. If QB Express is going to continue to be so good, YOU need to contribute!

-Pete

## Letters

### Letter From Adigun A. Polack

To Pete:

Well, I must so finely say in advance that I gotta *congratulate* you again for your most excellent issue of QB Express that has just been released today!!! ! And my man, I especially loved that “Blast from the Past” section of yours about the famous Qlympics, one of apparently the FIRST-EVER compos ever to even hit the QB scene, where, while it had its ups and downs — especially where its own voting system was concerned in which a minor simple flaw in it resulted in such upset and brutally shocking victories from 1999-2000 that really did not even make any sense at all (like Elysian Fields winning out over the highly praised Wetspot II as best QB game, for instance!) — it fought so hard and moreover smarter to become an intense success that it eventually turned out to be in its own second compo!! Man, outstanding work there! =b !!

Also, I gotta commend you very richly as well on the way you wrote my article, pics and all, just the way it was meant simply to be!! d==b

As a result of it all, THIS TRULY IS ANOTHER HANDS-DOWN WINNER OF AN ISSUE HERE, I gotta tell you for flat-out sure!!! ;*) !!

You just tell it like it is, Pete, and be seeing you!!! !!

GIVING YOU SUCH SERIOUS PROPS, Adigun Azikiwe Polack
One of the Founders of “Aura Flow”
Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger”
Webmaster of the “AAP Official Projects Squad”

> Always nice to hear from you Adigun! (You're always quite happy and excited about everything...maybe a bit TOO happy, but hey, it's cool with me.)

> Anyway, I'm glad you liked the Blast From The Past! on the Qlympics. I spent quite a bit of time on it, and I think it turned out really well. Unfortunately this month, I didn't have time to write a "Blast From The Past!" article (since this issue is already late and I wanted to get this magazine out as soon as possible). It's a shame too, since the Blast From The Past! is usually the most popular article in the magazine, and my favorite to write. Next month, I promise there will be another great Blast!, just like in the first three issues.

> -Pete

### Letter From Piptol

Pete,

Superb work, Pete. I found the article about the QB Top 50 particularly interesting, because I'm wondering if QB Worlds webring - now with around 70 members - is in a similar postion to develop into a hub site to support the QB network like the old QBT50 did. In the past I've decided against it because:

a) I didn't want webring members to think that, through the QB Worlds portal, they were just linking to somebody else's site that was 'stealing the thunder' of the other sites in the webring.

b) My PHP skills are not yet ready for such a task.

I may still add a forum for discussing suggestions and improvements to webring. So I guess I could try that and see if anybody uses it for starters..

Anyway, we now have a shiny new easy-to-remember URL: http://qbworlds.qbasicnews.com

(Thanks wildcard )

-Piptol

> The QB Worlds webring is by far the best QB webring that I've ever been a part of -- it's well-managed, not run through some commercial web service, has a lot of members and is reliable. So I definitely agree with you that you have the potential to evolve it into a hub / top sites list. For this month's Blast From The Past! article, which I unfortunately didn't end up writing, I was considering writing about either the huge number of QB webrings in the past, or all the QB top sites lists that once existed. If you want an idea of how many there were just a few years ago, check out this remnant from the old version of Pete's QB Site, circa 2000.

> But I say go for it! Right now the only QB top sites list still around is the low-traffic QB niche hub, The QB RPG Top 50. If anyone has the vision to make a decent and successful top sites list that will bring the QB comunity together, like the QBT50 of old, it's you.

> Also, I've got to thank you again for the two interviews you submitted this month. They're great! Entertaining and insightful, and you couldn't have chosen two better people to talk to than Relsoft and Na_th_an.

> -Pete

## 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!

### What was your first big QB project?

Genre | Votes | Percent | Graph
Arcade game | 9 | 12% |
Strategy game | 4 | 5% |
Platform game | 4 | 5% |
Puzzle game | 2 | 3% |
RPG | 25 | 33% |
Text Adventure | 7 | 9% |
Utility Program | 6 | 8% |
Fake OS | 12 | 16% |
Other | 7 | 9% |
76 Total Votes

> RPGs sure are popular among QBers, aren't they? Out of the 76 people we polled, a third of them said an RPG was the first major project they worked on in QB. I was one of them. My first big QB project was an untitled epic RPG...that never got much beyond the planning stages. A lot of people also listed "Fake OS" as their first major project. That's understandable, with all of the Windows-mimicking "OS" shells and GUI programs floating around. Personally, I think more QB programmers should start out with simpler programs like Puzzle games (the least popular category). Puzzle games are usually the easiest to make, and often the most fun to play. And since they're small and simple, they're more likely to get done than, say, your untitled epic RPG. *Ahem*.

## News Briefs

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

### QB Site News

V Planet! Updates, Moves To VPlanetMag.com

  After four months without an update, "The First 100% QuickBasic Game Review Magazine" V Planet! has finally budged. Last week, new editor Nekrophidius posted two short articles on the site announcing the 2004 Gaming Gold Awards and discussing the future of the site. Over the past several months, Nekrophidius had been promising a complete overhaul to the V Planet! website, meanwhile leaving the site static and unupdated. The two articles Nek posted were not the major overhaul that readers had been waiting for, but most were glad that the V Planet! staff was finally making baby steps toward the promised renovation. Nekrophidius wrote: "This updates marks the beginning of the new age of V Planet. It's a small update, but hopefully it will prove once and for all that V Planet is NOT dead after all, but is just beginning its second life."

  A few days later, Nekrophidius updated again. This time, he moved the site to its new server and domain name, VPlanetMag.com, and officially opened the 2004 Gaming Gold Awards for nominations.

  Nekrophidius is still working on the major revamp that he has been promising, but he has finally outlined what he has in mind to the QB community. I, for one, am extremely happy to see that V Planet! is back in business. I really hope that it returns to its policy of regular updates, and begins covering QB news stories and doing QB reviews again like it did in its heyday. V Planet! has been silent for an uncomfortably long period of time, and these small updates signaled a unanimous sigh of relief among the QB community... even if they are just baby steps.

Zext.Net Shuts Down

  Zext.net, Marcade's long-time free host of QBasic and QuickBasic related sites, is on the way out. Out of the blue on November 14th, Marcade posted the following on the NeoBasic Board:

  > For the people who are being hosted by zext.net...
  > Please consider making a backup and moving somewhere else. I really am going to try to get rid of the server asap.
  > I probably will be cutting off FTP access first to see who actually still uses it and then wait for those ppl to contact me. (or not, and then I'll just remove them)
  > _Marcade

  Marcade later explained that he was shutting down Zext.net in order to save the monthly cost of keeping extra servers online. Over the past month, he has been experimenting with hosting NeoBasic on his home computer, and recently announced that he will be moving the site to Wildcard's server (See below). Later, Marcade announced that he will be transferring the Zext.net domain name to Wildcard, and anyone hosted on the server is free to contact Wildcard and reestablish their account on his server.

  This announcement came as a surprise to many QB webmasters who have been hosted by Zext.net for the last five years. Unfortunately, many Zext webmasters not have been informed that their sites will soon be removed, and some abandoned QB sites will likely be lost forever. Already the Zext.net-hosted sites are inaccessible, including CosmoSoft, 19day Productions and The QB RPG Scene. Luckily, Marcade had the foresight to back up these important pieces of QB history, though they will probably not return to the web unless the webmasters contact him and then set up a new account at Wildcard's server.

  19day, who had been hosted on Zext.net since October of 1999 wrote a eulogy for the fallen server, from his perspective:

  > Requiem for Zext

  > It had to happen eventually, but marcade is shutting down his zext.net server. I'm not certain how many people were hosted on it, but for me it was my main presence online, as was the email address. It was a great space to have, unlimited storage until you abused it and marcade cleaned up, subdomain, php, email, all for free (which is of course, the reason it's now shutting down). I'm not sure how long it was around for, I do know that it was shortly after marcade first started offering space that I jumped on it (abandoning Xoom, which was a free hoster like geocities for a while). I managed to find the old News section blurb I wrote, which at least gave me the date that I lived there:

  > October 28th 99
  > Hey hey, I'm now being hosted on zext.net, run by Marcade, and out of the goodness of his heart, he's hosting me.

  > So late 1999 to late 2004, 5 good years of goodly goodness. Sure, it's a pain to move, and I knew I had to get my own space someday, but out of marcade's generosity (and pocket), I got to postpone that 5 years, with better services than I ever got for free anywhere else. Thanks again 'cadey.

  > 19day

  QB Express salutes Marcade for keeping Zext.net running for so long, and for the hundreds of dollars he has spent to provide free and reliable QB web hosting. Marcade's generosity has truly helped this community grow and thrive, and we thank him for his selfless philanthropy.

NeoBasic Moving To Wildcard's Server
  Shortly after his announcements regarding Zext.net, Marcade announced that NeoBasic will also be hosted on Wildcard's server. The www.neozones.com server, which is independent from the Zext.net server, apparently will also be shutting down in order to save Marcade some more money. NeoBasic is a long-standing and popular QB site, with one of the most visited message boards in the QB community. It's got a long history, and is descended from the original "Neozones.com" site, Tek's NeoZones Productions, and Simply QB, with a flavor of Marcade's original QB site. Though the conversation on the message board there is rarely about QB, most of the people there could be considered QB experts.
Fling-master Readies New RPG-Dev.net Design

  Fling-master recently revealed a new design for his RPG-Dev.Net website on the QB45.com boards. This new design gets rid of the cute RPG character sprites that adorned the old blue and pastel green site (with orange and yellow highlights), replacing it with a red and silver layout. It also cleans up the presentation on the main page quite a bit. You can see the potential new design here.

  I personally think that both the old design and the new design look good, and instead of working on RPG-Dev, Fling-master should get back to work on the QB45.com revamp... but what do I know?

SJ Zero Set To Release New Issue Of QBXL
  SJ Zero revealed that he is working on a new issue of QB Accelerator, his raucous and offbeat QB magazine which had three issues between 2003 and 2004. This came out when he mentioned that he is planning to write a tutorial on his new QB lightmapping system, which you can try out here: "I worked out a system a few days ago which uses raycasting, blender maps, and a low resolution bitmap to create a fairly convincing lightmap system for low resolutions at 256 colours." When we offered to run his tutorial in QB Express, he scoffed, saying that he would soon be releasing a new issue of QBXL. He continued: "The reason I don't just start submitting to other QB mags is I don't like the dryness and seriousness of almost any given QB magazine. That's the reason why I started QBXL." You can check out past issues of QBXL at this address.
Pete's QBasic Site Adds 294 QB Tutorials

  On November 7th, I added 294 more QB tutorials to the already massive Pete's QBasic Site tutorials section. There are now 609 tutorials available on my site in the Tutorials section. Pete's QB Sitehas, by far, the largest collection of QB tutorials available anywhere.

  Most of the new additions were from QB magazines that have published over the years. I extracted all the tutorials I could find and uploaded them as single, more easily navigable files. Each tutorial listed is accompanied with a brief description, the title of the article and the author. Currently, the majority of the tutorials are on a single page, so the best way to browse it is to load up the tutorials section in your browser and use the "Find" (CTRL + F) function to search for keywords. Eventually, I plan to make this section more easy to navigate, but for now that will work. (Besides, in a few weeks, Google will have spidered this page and you'll be able to search it more efficiently than any means I can provide.) Anyway, take a look!

Qbasic.tk Staff Changes

  SumoJo announced some major staff changes at QBasic.tk recently. He posted the following message on October 25th:

  > Just thought I'd pass a few things on so that those who aren't aware will now know.

  > As of about two weeks ago, the three previous admins (Paz, Rhican and I) of qbtk stepped down from the position and passed it onto Pyrodap, Dr_Davenstein and Webberboy. The three were chosen from various people by the previous admin staff.

  > With the new admins come many changes to qbtk. The new staff is promising a change in the look of the site and more contests and an attempt and restructuring the site.

  > With the new changes hopefully you, as the visitor, will have a better experience with qbtk and be provided the site/forum that should be given to the qbers out there.

  > As for Paz, Rhican and I, with all the free time now (not really that much...) we are working on redoing quickhost. Hopefully we'll be providing a service that will compete with the top free hosting services out now and will offer many new features that haven't been seen before. More news about quickhost will be given upon completion.

  > Thanks

  'Nuff said.

New QBasic Site: JacobPalm.dk

  and VBDOS coder Jacob Palm opened up his new site last month. JacobPalm.dk launched in mid-October, and includes some tutorials, programming tips & tricks, downloads and a neat GUI section with a collection of several dozen GUI and Fake OS programs written in QB. The site is still largely under construction, and be warned: the browsing system is incompatible with many browsers, including Mozilla FireFox. However, the site is off to a good start. I'm hoping for good things to come out of JacobPalm.dk.

### Project News

Adigun Shows Off Frantic Journey's 'Master' Difficulty

  Adigun A. Polack, the guy behind the awesome Frantic Journey space shooting game, recently gave QBasic News visitors a taste of the highest difficulty setting of his highly-awaited game:

  > "Just yesterday night, as I was tweaking and experimenting on the difficulty-level creations for the game Frantic Journey (FJ), I am learning to be careful that while I am indeed planning on making the bullet intensity — or the huge if not INSANE amounts of enemy shots — to the level of the DoDonPachi series or Progear on one of the difficulty-based courses, I am to *also* balance the gameplay and control into proper order so as to aim dead-on at the player’s interest curve. In so doing, I cause it to rise up and blow its very top into such sheer excitement and thrills!! Not an easy task one bit, but can be mastered so acefully, you understand that? ! "

FreeBasic Rocks The QB World!
  V1ctor's 32 bit QB-compatible compiler, FreeBasic, has lit the QB community on fire...but this is too big a story to just list in the "news briefs" section. Check out Blitz's full article on this incredible program!
Stephane Richard's Windows IDE for QB Compilers

Stephane sent me some news about his upcoming Windows IDE:

  > Hi Pete,

  > I once read, on QBasic News that some dude start coding a windows IDE for QB compilers -- qbw_1_1.zip it was if I remember... I never heard from that again. So my bit of news is I've decided to make my own. It's not complete yet, but I think I put in some interesting stuff in there. for instance

  > - Syntax highlighting
  > - Auto Complete (well on it's way)
  > - Tooltip (like regular IDE's when you type a function it will list it's parameters so you know what you should be typing.
  > - like the QB family, keywords will be uppercared and such.
  > - The ability to open more than one mak file at a time thus allowing moving, cut and past between modules and projects instantaneously
  > - and a few other IDE related features.

  > One form allows the editing and managing of one whole project. I also list all sub and functions automatically and double clicking on one brings the module to that function or sub. Ultimately I could do like the DOS ide's and show only the function, but for now it positions the editor at the right place :-).

  > I also start the IDE itself, and I'll also be allowing to select options and execute lib.exe, bc and link...and anything else I can think of :-)...to bring a better IDE to the QB community :-).

  > Stephane Richard
  > Software Developer

Syn9's "3D World Map" Demo

  Syn9 is at it again, making an incredible QB game engine for all of us to feast our eyes on. Just two days ago, he released his latest 3D engine, set on an island with sandy beaches, grassy bluffs, craggy mountains and a beautiful view of the sea. This engine looks great despite the simple textures. The engine itself is based on bad-logic's ugl graphics library. You can download the program at this address. Now if only Syn9 would turn this into a finished game... (If you're interested, here's the QBasic News thread where this was announced.)

MOoRPG - Engine Build 276, Light FX Added
  Z!re's Massive Offline Open RPG had another engine build released. This time, some light effects and "smothing" effects have been added. Z!re is looking for feedback and for users to post their specs with the engine. You can download the engine build here or read about it and post feedback here.
QuickerBasic Preliminary Scratch Interpreter (4th/Final) Released

  Someone42 recently announced the release of the 4th and final version of his QuickerBasic Preliminary Scratch Interpreter. He posted the following on the QBasic News forums:

  > I previously completed the 4th and final release of the QuickerBasic preliminary scratch interpreter. It is available at:

  > http://qkrbasic.sourceforge.net/qkrbasic-prelim4.zip

  > It is programmed in VB, although a binary is included. Note that the real thing will be programmed in C (and maybe some C++).

  > It currently implements a wide range of standard library functions and programming contructs including:
  > expressions, variable assignment, line labels, line numbers, one-line IFs, GOTO, PRINT, INPUT, multi-line IFs, DO/LOOP, FOR/NEXT, EXIT DO/FOR/WHILE, DIM/DIM SHARED, DEFxxx, END/SYSTEM, ABS, ATN, COS, EXP, LOG, RND, SGN, SIN, SQR, TAN, LET, RANDOMIZE, CLS, LOCATE, COLOR, ASC, CHR, MID, INSTR, LCASE, LEFT, RIGHT, UCASE, LTRIM, RTRIM, SPACE, SPC, TAB, STRING, LEN, CDBL, CINT, CLNG, CSNG, FIX, INT, HEX, OCT, STR, VAL, INKEY, GOSUB, RETURN, SELECT CASE/CASE/END SELECT, WHILE/WEND, $STATIC arrays, DECLARE SUB/FUNCTION and SUBs/FUNCTIONs.

  > What it doesn't implement is graphical standard functions, $DYNAMIC arrays and user-defined types.

  > A range of examples/tests is included, although I believe there will still be a lot of bugs in the scratch interpreter. However, the performance or stability of the scratch interpreter is not the main reason why I'm posting here.

  > I'm going to begin the real thing soon, and I'd like a bit of feedback on what kinds of enhancements and extensions you would like to see QuickerBasic implementing over QuickBasic. A plan is available at: http://qkrbasic.sourceforge.net/qkrbasic.txt

  > Remember, feedback is a critical component of open-source projects, so I encourage you to reply with your ideas. This is your chance to help shape a "modern" QuickBasic which can be actively managed and maintained. Of course, as per previous feedback, improved efficiency of compiled code and greater memory capacity will definately be implemented.

Dark Ninja's Space Invaders Game
  Dark Ninja released a Space Invaders-style game. According to Dark Ninja, "it's a shooter game in the style of space invaders, but also very different. The controls are explained in the opening screen when you first hit F5." This game is in textmode, with some graphics as well, and it includes several kinds of weapons: "Bomb, super bomb, piercing, and shaky bullets." They all "all have their own look, as do the enemy bullets." Sounds neat!
Dot Life Simulator By Meg

  Meg has released four editions of her "Dot Life Simulator" over the last month over at the QBasic News forums. I've checked out the program myself, and it's very interesting to watch the little dot "cells" roll around, mate, reproduce and die. Not to mention, this program is written in pure QB. You can find the latest version of Meg's program (11/10/04) at this link.

  Meg plans to add some neat features to the program, including the following:

  > 1. No more random movements. Make a dot variable that's a scale ranging from shy----social, and have it locate the nearest dot and either move towards it or away from it. Adjust the shy----social variable depending on stuff like if the dot gets into a fight, mates, reaches certain ages, etc.
  > 2. Instead of instant birth, have the female dots go through pregnancy (show with new color of dot). Environmental variables can adjust the length of pregnancy.
  > 3. Rework the dying of old age code to be more realistic (the older you get, the higher the chance of death each year)
  > 4. Replace the current "death fight" encounter (occurs 50% of time when dots of same sex meet) with something more interesting.

  I've always found life simulators to be interesting. Anyone that's interest in Biology, or even partical effects systems (because that's basically what this is), should take a look!

3D Chess, Anyone?
  After Oz finishes Hobbit 3D, he plans on making a 3D chess game. Over at the QBasic News forums, he said the following: "Well, as soon as i get the 3d engine done, and get h3d completed, im going to do a 3d chess kinda thing....ya-know." Was this newsworthy? I dunno. I'm just trying to fill up this mag!

### Competition News

The 2004 QB Gaming Gold Awards Have Officially Opened

  Nekrophidius, editor in chief of V Planet! QuickBasic Magazine has opened up the nominations for the 2004 QB Gaming Gold Awards. Since the Qlympics, the Gaming Golds have been the the biggest and most popular awards ceremony in the QB world. In 2000, 2001 and 2002, the Gaming Golds were great successes, but unfortunately, last year's 2003 ceremony never made it past the drawing board. Luckily, new V Planet! editor Nekrophidius has stepped up to organize the 2004 event!

  On the V Planet! site, you can find the official nomination form, which allows you to nominate both games and developers (up to 1 a day) for the 2004 contest. This year, you may submit any game which was developed in QB up to this point in time. That means that "a game from 1999 is just as valid as a game from 2004. Developer nominations are valid for any year, past or present." So basically, any QB program ever made can be nominated, unless it has already won the award in the past.

  Perhaps the most interesting categories this year will be the Best Game of 2003 and Best Game of 2004 awards, which will honor the best QB releases of the two most recent years. Due to a recent slump in QB community activity, the most recent games have gotten a lot less attention than they would have in years past. The 2004 Gaming Golds will finally give recent games the respect they deserve.

  I encourage everyone to nominate their favorite games and development teams. You have until December 20th at midnight to submit your nominations. This is the biggest QB event of the year, so don't miss it!

7-Line Text-Based Graphical Screensaver Challenge Wrap-Up!

Here's the official results from contest manager Adigun Azikiwe Polack. Take a look:

> From QB Express #3, I introduced to you this interesting challenge presented to you in the QBasicNews.com forums that took place originally during September 2004. Now, the deadline of November 1, 2004 has passed and the mini-contest is over. Unfortunately, there were no legitimate entries from somebody else (because some of the participants sadly have not followed the rules of this challenge as properly as they should). BUT, much to its good credit, I have done a fitting *seven* text demos based on the challenge itself, and they are:

> > - Twin Whirlwind of Colors
> > - 80x50 Television Static
> > - 80x50 Textmode Firefall
> > - 80x50 Textmode Firefall Perfect
> > - Flowing Sea, Starry Dusk
> > - Grasslands Under the Stars
> > - Chambers of Molten Magma

> .....and they are ALL available in this QB programming compilation of mine coming up that I am sure you will enjoy! ;*) Its title is called the "AAP QB 7-line graphical screensaver collection". As well, other entries that did not pass the challenge successfully are included here, too!

> Also, do bear in mind that in the download, the "Readme" file is in .PDF Acrobat Reader format, and it features some great informative and fun-to-read descriptions about each and every last one of the entries, including my own original and breathtakingly amazing text-based 7-line examples as well, so you won't want to miss it all!!

> And finally, my VERY thanks to those of you who participated in this fine challenge and to QBasicNews.com and to my man Wildcard for all of the wonderful support! Chao and God richly bless all of you!!! ^_^ !

> -Adigun Azikiwe Polack

You can visit the official 7-Line Screensaver Compo site at this address. Also, the complete collection of entries is available right here: AAP7Line.zip (333 KB). Enjoy!

QB Compo Rap-Up

  There are quite a few competitions going on in the QB community right now, so I thought I'd just do a quick list of the coolest ones that you might want to check out:

  - Neo's Lingo Challenge
    Lingo is a daily TV gameshow of ID-TV that is broadcast by the TROS and other foreign broadcasting companies. The goal in Lingo is to guess a word of 5 letters. The first letter of the word is always given. You have to figure out the rest. Neo challenges you to write a program that can solve the puzzles!
  - Write A Bulletproof Date Validation Routine
    Neat competition to make a program that can test the validity of any date in history.
  - VonGodric's Limited Variable Game Compo
    Write a game where you can use each data type only once. You're allowed the following: NO constants, one integer, one long, one single, one double and one string. Very cool concept -- check it out!
  - QBTK's Spam Mod Contest: 30 Line Math Art Program
    In 30 lines or less, make the most dynamic "Math art" program in Pure QB. It can be anything, but a program that draws something resembling realistic nature scenes is bound to be better. You can use any of the standard QB drawing primitives. You can use any SCREEN mode. You can use any keywords, with the following exceptions: (1) CALL ABSOLUTE (2) CALL INTERRUPT. You cannot use any libraries, except QB.qlb. You cannot merge lines with colons. GO!!!!
  - Nekrophidius' Text Adventure Compo '04
    "Every year, I hold a competition called TAC: Text Adventure Compo. It's a one-month competition, in the month of December, where developers create a text adventure from scratch in any language of their choosing." This should be starting soon.
  - QBNZ Frozen Bubble Clone Competition
    Create a Frozen Bubble Clone (aka, a Bust-A-Move clone) in QB!

### Other News

Barok's "So, You Wanna Make An RPG, Eh?" Article
  QB aficionado Barok compiled a very amusing and helpful collection of quotes and ponderings from the RPG-Dev.net forum in an article called So, You Wanna Make An RPG, Eh? - Quotes On This Topic From The Community. The article includes a wide range of insightful quotes, from all types of programmers. There are quotes from stupid, annoying newbies (showing you what not to do), as well as quotes from RPG programming masters, covering all aspects from how to ask for help, how to get started, how to start a MMORPG, and what to do about sound, graphics, and more. I encourage any prospective RPG programmer to go and read it immediately! Ninkazu soon followed Barok's piece up with a great theory article of his own. It's a step-by-step explanation of how to design a game, which dispels many of the myths of game programming. Ninkazu's article is also available in this thread, right below Barok's article. You can read both of these great articles at the RPG-Dev.net Forums!

## 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!

### Two Lords

Nekrophidius's latest QB project, a first person shooter called Two Lords, is one of the most impressive games I've seen come from QB in a long time. Following in the tradition of Quake, Wolfenstein 3D and Heretic, Two Lords puts players into maze-like dungeons filled with hordes of killer demons, where the only way to survive is to shoot...and then run for your life. Two Lords replicates the frenzied, claustrophobic, horrifying shootouts you'll find in mainstream FPS games, complete with good graphics and intuitive controls. But unlike the mindless run-and-gun mainstays of the FPS world, Two Lords also has a story and strong characters to back up the hellacious gameplay.

Two Lords' weapons are magical rings rather than the traditional shotguns, railguns and chainsaws.

According to Nekrophidius, "An often overlooked feature in many FPS games is the storyline. Very often, the storyline is an afterthought; tacked on to keep the more intellectual players happy (Quake, for example...the ingame story was far different from what was depicted in the user manual, and neither were very interesting). Two Lords, on the other hand, is based around a story...a story of family, power, death, betrayal, and revenge. Great attention to detail is paid in the unfolding of the storyline."

After playing Two Lords, I can see exactly what Nek is talking about. The game's underlying story gives gravity to the locations, characters and gameplay elements. There's a story behind the magic rings that you use to slaughter demons -- they're not just there for looks. And you're no longer in some random dungeon, but a dungeon where you were imprisoned by your maniacal brother, who wishes to usurp your power. But instead of me telling you the story of Two Lords, I'll let Nek tell it himself:

> The Two Lords Story

> "'You are to be the keepers of the arcane...the pillars of wisdom and strength...together, you must guard and defend all natural magic...'"

> "These were the last words spoken by our mother before death claimed her soul, as it had claimed that of our father just minutes earlier. We were the next to inherit the Lordship of Magic from our parents, who had overseen all natural magic since their teenaged years. Now, the responsibility fell onto the shoulders of myself and my older brother, Asrael."

> "Since he was older, Asrael was endowed with the gift of black magic and the three rings that accompanied that power: Blue, Purple, and Black. Being the younger son, I inherited the gift of white magic and its three rings: White, Green, and Red. It was our parent's dying wish that we work together to continue to maintain the balance between the Dark and the Light."

> "Unfortunately, my brother Asrael eventually became obsessed with having control of all natural magic. Using his newborn mastery of the black arts, he created a legion of demons to try to take my rings from me. Although many a demon fell to my attack, Asrael's formidable black magic overwhelmed me and he was able to capture two of my three rings. But since I am the Lord of White Magic, he could never take my White Ring..."

> "I was imprisoned in a subterranian dungeon and guarded by demons day and night while Asrael worked to figure out not only a way to get my White Ring, but also a way to duplicate his own rings and endow his loyal followers with the magics that they represented. Soon, he had a powerful and dangerous army of demon warriors capable of five of our magics. These demons went forth to pillage and destroy..."

> "I do not remember what day it was when one of his demons turned his back to Asrael and broke the lock which bound me to my cell. That demon paid the ultimate price as loyal demons enjoyed his slaughter...but now I was free..."

> "Now I must recover my Rings and work to restore the balance of natural magic...and then slay my own brother, the Lord of Black Magic...Asrael..."

I had the privelege to play a two-level demo of Two Lords, and I have to say that it is pretty slick. It does a great job of replecating that hectic, always-on-the-edge feeling of Doom, where there are enemies waiting to pop up around every corner. Nek did a wonderful job of placing enemies in little nooks and crannies, around corners, and right behind doors, so that they're always popping out of nowhere to surprise you. The majority of the enemies in the first two levels were Brutuses -- giant muscular fist-fighters that charge straight at you. Several times, I was confronted with two or three Brutuses at once, which led to some pretty frenzied shooting. However, most of the time these enemies were quite easy to take out. The more powerful demons, such as the green-ring toting Abishai at the end of the first level had more advanced attacking patterns; instead of charging you, the Abishai stood back and fired green magic at you. Dodging the green magic projectiles as well as three Brutus demons at once makes a pretty interesting battle. Hopefully in the finished version of Two Lords, we'll see more compromising group attacks like this one, since it was one of the most enjoyable battles in the game.

In between battles, though, your character is alone in the giant maze-like halls and pathways of the dark dungeons or ice palaces. These dungeons are maze-like and dark; every wall looks the same, and distant walls fade away into darkness. Although this is partly due to technical limitations, the darkness of this game really contributes to the atmosphere.

There were several power-ups and secrets in the two demo levels of Two Lords. My favorite was the map, which gives you an overhead view of the dungeon you're in, and is absolutely essential to finding your way to the exit and finding all the hidden items. Once you find the dungeon map, the map gradually fills in as you explore new areas. The way this happens is really neat; the map fills in based on which areas you see on screen, so in order to completely fill in all the holes, you have to go into a room and look in every corner and crevice. This was a neat element of the gameplay, and my search to fill in the holes on the map steered me in the right directions: to find the hidden rings and health capsules scattered throughout the dungeon, as well as the level's exit. There are some neat environmental effects built into this game, such as teleportation blocks, water areas which you can walk through, as well as some places where you can go outside and see clear sky instead of the normal low, claustrophobic ceiling. In the final version of the game, these elements could be used for some neat puzzles or to conceal secrets. Speaking of which, there are already some "hidden areas" in the levels...which I didn't find (though if I had more time, I would have definitely looked harder).

Two Lords is based on Angelo Mottola's Project RT raycasting core, and I imagine that in Windows 95/98, it would run pretty smoothly. Unfortunately, Two Lords doesn't run under Windows XP unless you use an emulator or a Virtual Machine. When I played Two Lords, I used the DOSBox DOS emulator, and as a result, the game was extremely choppy. I had to boost up the frameskip and then "overclock" the emulated x86 processor in order to get the game to run at a sluggish 4-5 frames per second. It was playable, but certainly not enjoyable. I was also unable to get any sound to play (though I'm not sure if there actually was sound included in this demo). I was surprised that this didn't run a bit faster in DOSBox, especially considering that it is a fairly simple engine, and all levels have only one floor / level. I wish I was able to run this at full speed, instead of playing it as if it's in slow motion. According to Nek's website, he's working on adding sound and increasing Windows XP compatability.

> > One neat feature of Two Lords is that enemies are unable to enter water, but your character is. From this position, the two demons are sitting ducks. (This screenshot is from the game running on Pete's computer in DOSBox. Notice the frame skip and overclocked CPU speed necessary to run the game.)

At any rate, Two Lords is looking really incredible, and I can't wait to get my hands on the finished version. Nekrophidius once stated an estimated release date of "Quarter 4, 2004" for this game, but since then, the release date has been made indefinite. Whenever it gets released, though, QB Express will definitely be there first with the inside scoop!

Visit the Two Lords Official Site for more information.

## Is It A Bird? Is It A Plane? No, It's FreeBasic!

### Written by Blitz

### Is it a bird? A plane? No, it’s superman!

WisdomDude's FreeBasic floormapper program. In the short weeks since it hit the scene, a myriad of FreeBasic graphics demos like this one have been released.

Not quite, but almost, it’s super BASIC. If QuickBasic was the skinny and geeky older brother, this would be the smarter, athletic and popular younger brother. The son your parents always wished for, but had to settle with you instead. The girls love him, and the geeks want to be him. And all the other cool guys say he’s gay, he just haven’t figured it out yet. But they’re just jealous!

Yes kids, that’s FreeBASIC (FB for short) alright, if FB had been a high school kid. So who is VB then? It’s the fat smelly kid who ate all the food. Yes, that’s him alright. So where am I going with all this analogy? I’m simply trying to show you the picture, if you’re not so familiar with all those languages.

Remember everything you loved and hated with QB? Now take that list, remove all the bad stuff and you have the recipe for FreeBASIC. So what is FreeBASIC you ask? It’s a QuickBasic compatible compiler that generates Windows applications (soon Linux too), that means that it has direct access to 4 GB of memory and access to any Windows API there is. OpenGL, DirectX (not directly yet), BASS, SDL, TInyPTC and whatever else you might like. But don’t be scared, just because it’s a 32-bit compiler doesn’t mean that you have to create GUI applications. You can create simple console application which will run in text mode, just like QB.

### In the beginning

Around 3 months ago v1ctor decided to code an interpreted toy parser, out of boredom I guess. Once it was able to parse real programs he thought why not make it generate 32-bit x86 assembly for windows. So that’s what he did, and the first time he showed it to me it was generating code directly from the AST (Abstract Syntax Tree), which is a lot more advanced then any QB compatible compiler I’ve ever seen. But it was still missing a few elements from being a full modern compiler. Being the good sport I am, and having read a few books on compiler coding I pointed out to him what was missing and gave him a few links. So three days later we talked again and he showed me what he had done. Unbelievable, it now was a fully function compiler, the way it’s supposed to be. With a front, mid and back end. It was now possible to have it produce optimal code instead of just being a straight down translator.

### Today

The actual compiler was originally written in VBDOS, because the plan was to get it to compile itself later on. At that time the compiler couldn’t compile a source file with more a thousand symbols because the symbol table would run out of memory - the joy of limited resources in DOS. But about two weeks ago FreeBASIC compiled its own 20,000+ lines of code. And now there are no limits whatsoever on what it can compile because it can use up to 4GB of memory. This is a huge accomplishment, because it shows that it’s a mature compiler that has no limit on how complex code it can compile. In other words, it’s a real compiler. More advanced then QB.

### Let's talk about the main features:

- The syntax is the most compatible possible with Microsoft's
- QBASIC/QuickBASIC/PDS/VBDOS interpreters and compilers. FreeBASIC is not a "new" BASIC language, you don't have to learn anything new if you already know any MS-BASIC variant. Everything is case-insensitive, scalar variables don't need to be dimensioned, it supports line numbers, there's no MAIN functions and so on.
- The syntax is clean, only a small number of keywords were added, all functions are implemented as libraries, there's not a single new intrinsic routine, like MSGBOX of example, so there's no variable clashes with old code. If you want to show up a message box in Windows, simply do:

  >     '$include: 'user32.bi'
  >     MessageBox NULL, "Title", "Text", MB_ICONASTERISK

  (Note, MessageBox is case-insensitive, it can be MESSAGEBOX if you want)
- There are a great number of variables types, like BYTE/SHORT/INTEGER, SINGLE/DOUBLE and STRING. All integer types have unsigned versions (UBYTE/USHORT/UINTEGER) and strings can be fixed- or variable-length (up to 2GB long). All numeric types can me mixed together without explicity conversion from one type to another.
- User defined types (UDT's) with unlimited nesting and support for UNION's too: union MYUNION

  >     a as integer
  >     b as short
  >     c as double
  >     mylist(0 to MAXITEMS-1) as MYITEM
  >     myfunc as MyFunc( byval arg1 as integer ) as integer	end union

- Support for enum's (Enumerations):

  >     enum MYENUM
  >     A
  >     B = 3
  >     C
  >     end enum

  >     dim e as MYENUM

  >     e = C (ie, e = 4)

- Dynamic and static arrays, up to 2GB, with unlimited number of dimensions, any lower and upper bounds and redim preserve
- Pointers to any data type listed above, including UDT's and arrays, using the same syntax as in C, with unlimited indirection levels, for example:

  >     currNode->nextNode->prevNode = NULL
  >     *a = *b \ **c

- Inline assembly blocks, with Intel syntax and reference to variables made by name - no trick code needed.
- Creates OBJ's, LIB's, DLL's, console and GUI EXE's, you are in no way locked to an IDE and also can create static libraries as before.
- Supports compiling source-code files up to 2GB long and the number of symbols (variables, constants, etc) is only limited by the memory available (you can include/use for example OpenGL + SDL + BASS + Windows API within your applications).
- Generates optimized code: while freeBASIC isn't an optimizing compiler, it does many kinds of optimizations to generate the fastest possible code on x86 CPU's, not losing to other BASIC alternatives, including the commercial ones. Code generation will get better in the next releases with use of more sophisticated algorithms.
- Completely *FREE*: all 3rd party tools are also free, no piece of abandoned or copyrighted software is used. assembler, linker, archiver and other cmd-line tools came from the (awesome) Mingw32 project (the GCC Windows port).
- Portable: runtime-lib is being written with portability in mind, OS dependent functions are being handled to make porting easy later. Also the compiler is written in 100% in FB (that's it, FB compiles itself), and all modules are independent, porting to other OSes on the x86 platform won't be too difficult.
- Easy to use: creating a "hello.exe" is simple as calling fb from comman-line as "fbc hello.bas" or even just drag-and-dropping hello.bas into fbc.exe. Yet, for more complex projects, there are many command-line options to play with.

### Release date

Release of the first beta version is planned to the done at end of November/2004, so stay tunned and don't forget to check the news at http://www.freebasic.net/ (thanks Plasma for registering the domain).

Thanks for reading and bye.. Signed: Clark Kent directly from Deadville.

Two impressive FreeBasic demos by RelSoft. Check them out!

Visit FreeBasic.Net or the QBasic News FreeBasic Forum!

## The QuickBASIC Caliber Programming Compo 2004/2005 Desperately Needs New Entrants!

### Written by Adigun Azikiwe Polack

If you would recall back in the premiere issue of QB Express about the QB Caliber Programming Compo 2004/2005 being so clearly explained in full and unmasked detail and the *real* history behind the first two QBCPCs there, you should well know why I have poured my heart and soul out for you so hard and so cleverly to bring you the most revolutionary, more improved, and more fun QB compo that you will ever want to enter into. Well, just more than four (4) months has passed now since it has first opened on Tuesday, June 22, 2004 and also since I have changed the rules in a MAJOR way a month or so into the event (to make it even much better and exciting than my first two!), I found out that no one has so far signed up to enter as of yet. :*( BUT, things will be bound to change on forward now as the QBCPC 2004/2005 has recently updated with some better promises. C'mon now and I will so gladly show you!! ;*)

After a month-and-a-half of the QBCPC 2004/2005 lying dormant without an update in the compo, it has recently updated on the start of November 2004 with a brand-new category to replace the Athens 2004 category that became quickly outdated on the count of the games already being over. That replacement category is.............

Now let’s just see you try and make that in QB during this compo! Here are some examples of a couple of appropriate games from Japan to wow you and inspire you ON-PURPOSE for this new never-before-experienced category:

(Left to right: Block v1.30 by Kenta Sato and Renga Funsai Yuugi by ORA Soft, two of the finest freeware hits.)

They were first presented on the QBCPC Winter 2003 back in 2002, and I am telling you, those two games are OUTSTANDING examples of how great games should and shall look and play through QB on my compo! No arguments, no blood, no gore, no bull, just pure unadulterated gameplay taken to the highest possible caliber, period. ^_-=b !

And you wanna know about some of the coming attractions for what is ahead on the QBCPC 2004/2005 in the next few updates (or sooner!) to intensely stir up wide the blazing fires of excitement? For starters, I am gonna throw in another all-new Spotlight Category, this time being *specially* devoted in its uncompromised and rawest entirety to one of the greatest NES classic racing games of all time, R.C. Pro-Am (you remember that one from 1987?)! And secondly, as always in keeping in the spirit of my compos, I am gonna add in more of the newest and hottest inspiration files to inspire you for some dead-serious, bullseye excellent programming in QuickBASIC/QBasic!!!

Sure QB the programming language is getting more and more outdated to at least some to a lot, but hey, so what? It is STILL a real great and fun language and stuff to be rather plain honest on tight, and so I am doing my utter best with this compo and make the truly most out of it all to make it a most challenging yet *very* fun and rewarding contest that you will ever wanna experience!

Also, did I even mention that I have extended the main QBCPC contest deadline to April 30, 2005? It's there for you!

So why are you just sitting here on the computer for? I need entrants, people, and what I have got that no other QB compo so far has even thought or dreamt of — plus a special challenge based on our favorite ancient console of our time, the Atari 2600 — is just *no* excuse for you to just pass it up and not enter! So, get your tail right on up at bat and why don't you CREATE SOMETHING OUT OF THE ORDINARY IN QB, AND START WINNING BIG!!! ;*) !! Entry registration details and the current and up-to-date Official Entry Rules are found right here, and prepare to start your coding engines like never before!!!

> WISHING YOU ALL THE RATHER HOTTEST SUCCESS IN QB PROGRAMMING,
> Adigun Azikiwe Polack
> Official Founder of the QuickBASIC Caliber Programming Compo 2004/2005
> http://dhost.hopto.org/aapproj/qbcpc/

## Piptol Meets... Relsoft

### Conducted by Piptol

If QB is our Kung-Fu, the Relsoft surely sits at the Grandmasters' table guiding the students who trip over their own toes and handing out braces when their pants fall down. A hugely talented coder without an ounce of ego, our reporter discovers why Bruce-Rel Lee will never abandon QB..

Hi Rel, thanks for joining us.

The pleasure is mine. ;*)

Where is home for you, and what do you do in real life?

Home for me is Iloilo, Philippines, with my daughter and wife. A very safe area in a tropical country with great beaches and mostly smelly politics. I was a nurse with a BSN RN degree, but quit my job this year due to health reasons. I now work on a review center reviewing students and professionals take standardized national exams.

How did you get started in QB, and how long have you been coding?

It all started in college when I was 19 (yep, I started late). We had computer 101 which the descriptive name is "Introduction to computers". Not a lot of programming actually, mostly typing and everything you'd expect in that descriptive header. Programming started when I saw my teacher rotating a 2d cube using DRAW statements in BASICA. As you'd expect from someone studying a medical course in scholarships (I had 2), some of us can memorize stuff just by looking at it. So I started to type the same code the next day and my teacher was impressed by what I can do since not a single student has been able to code in BASICA. Little did he know that I didn't understand a single line on code! :*). Then he lent me the BASICA manual so that I could learn to code, and all was history. How long? after computer 101, I stopped coding since I had no computer to play with. It was just last 1999 when my mom bought my sisters a used 486/66 dx with which I was able to code again. When I sum it up, it's approximately 5 - 6 years.

You've been branded a 'Mad Genius', the 'Einstien of QB', 'Professor Lope' and 'Dr SomethingelseIjustmadeup'. Do you consider yourself a Fruit-loop, or just plain talented?

Aside from the fact that I have no idea what "fruit-loop" means, no. Mad? definitely. Genius? not really. Most of what I learned came from the net. I was able to code a breakout game on my own without the help of the net then but what I produced, although working, could be made by a 12 year old kid in sweden or finland. Even after I was able to connect to the net with its plethora of tutorials, I wasn't back then a decent coder, in fact Pacmaniod (my pacman clone) is probably one of the worst pacman clone in the community ever released. What I knew today came from you guys (the community). No one ever knew this but I missed half my highschool class in trig and physics due to a ruptured appendix, so I could say my math is not that deep. But not knowing about matrices and vectors in highschool did not stop me from learning it on my own. Math is only boring and abstract if you have no use for it. So by necessity, I read trig and math books on my free time using the public library. It's a slow process but it could be done, and it's never too late to start now. If I can do it so can you.

What are you working on right now?

Not a lot. I am learning to code in C so that I could help some computer science students with their programming probs in ASM or C/C++ and getting paid for it. Considering it's less than a month since I started coding in C, it's a little dumbfounding. I am working on a QBgame though. It's a space shooter (again) featuring an all-ripped sprites and tiles, faster engine than FJ (Frantic Journey),a feel similar to strikers 1945 and combines 3d and 2d in one game. Of course, there's Rellib and AFlib. I am also contemplating on making another small demo with just wupixels in it.

'Frantic Journey' is a real showcase game, the sort you would show that fat kid down the road when he says QB is crap. What have been the biggest challenges for project team? And will we ever see it finished?

But so is Ghini Run. You're right though. I made FJ for the heck of it. I never intended it to be as cool looking as it is, but with the help of Adigun, Eebs and L_O_J, it became what it is now. We could technically finish in a month, but I'm as lazy as they come. So I am passing the ball to AAP as I'm very sure he's capable of finishing it himself. Don't count me out helping it get finished though, I may get enough motivation one of these days and help AAP finish it. The biggest challenge is drive (at least for me). I get into coding FJ and here comes an idea to learn some new algos. In learning new stuff, I get sidetracked easily fom my objectives like finishing FJ. Heh, it took me 1 year just to accomodate requests to finish the XMSput routines in Rellib. :*)

So what's happened to 'Dark Woods 3'?

It's in the "dark". I might as well apologize to Jofers and Jocke for my procastination in finishing the engine. The engine itself is close to being finished but I wasn't really that happy with what I made. I decided on an object system that I thought to be better than what I had, but turned out to be as crap as it could ever get. It's not Joe or Jocke that's keeping darkwoods 3 in the dark (pardon the pun), it's me. We all have invested a lot of time and effort (mostly Jofers) in darkwoods 3 that it pains me to see it go to waste. I don't really know if it's okay to finish then release the engine as it stands now with minimal script support and no sound just to get it off our backs.

RelSoft's impressive graphics demo Mono and Disco pushes the boundaries of QB with some of the most mindblowing and breathtaking graphical effects ever seen in a DOS program. In Neo's review of M&D at QBNZ, he said "It was wonderful, probably the best graphical demo I have ever seen in my life."

'Mono and Disco' is the best demo I've ever seen in QB, 'RelLib' is a superb library, and 'Cheesy Run' .. er, hurts my eyes. Which of your projects has given you the most satisfaction and why?

I don't believe it to be the best, Optimus' "ITFDEMO" literally blew me off my chair, Plaz' "Digital reality" was one of a kind, Qasirs demos never fails to impress, Biskbart's "Blue" I thought was impossible, Antoni's "dithered earth" was unbelievable, Entrophy's "Sliq" could never be touched, and Toshi, once he decides to make an awesome demo could really pull some stuff that I couldn't ever imagine to be possible in QB. Then there are the guys from "IBMLAND" doing some really crazy graphical stuff in QB you'd want to make another demo yourself. Kudos to these guys, I made Mono and Disco a lil better just to be on par with what they did. "Cheesy Run" was a spoof of your "Ghini Run". I was so impressed with Ghini Run that I made a textmode version. Satisfaction does not really come from my projects, helping people get better at coding is what makes me proud. I sometimes get emails from other coders thanking me for the help I gave them when they were starting to code. That really lights up my day. It's also the reasom why I made those 3d tutes so that I could impart what I know to people wanting to do 3d in QB. I probably would never have enough drive to finish a 3d game. I'm retro, I like 2d games better than 3d games. But even if I could never finish my own 3d game, I could help other coders understand the principles behind 3d and make their own game. I've already got numerous thank you letters because of those series.

What awesome additions can we expect to see in future updates to 'RelLib'?

Not a lot. The QLB is already approaching 70KB which is my size ceiling for it. I already finished the "dissolve" effect though. Bugfixing the XMS routines is also on the list, plus some SNES type graphical effects. I'm open to suggestions though. I didn't make Rellib to be released. It was supposed to extend the capabilities of CosmoX since some stuff we want like memory conserving translucency routines are missing so I made some routines just for that. But some friends liked it so much that they pushed me to extend it to be a proper lib. Thanks to CGI Joe and Adam Hyde for their ASM tutes that started me in ASM. Without their tutes, I have probably never have learned ASM.

As one of the latest QBers to jump on the C/C++ bandwagon, is your wagon heading outta QB Town or will you be sticking around for a while to play us some more tunes?

I would never abandon QB or BASIC in particular, never. I had to learn C and Pascal, just as I had to learn ASM a while back, in order to make a lil money on the side helping some students with their C projects. Just because you're a C coder now does not mean you're better than all QB coders. But I'm particularly interested in v1ctor's and Blitz' FREEBASIC compiler. From what I have seen, it could really be a winner not only with this community, but all the BASIC community as well. So in short, I'll not only play some tunes, I'd be dancing as well. Give or take an orchestra or two. ;*)

Ancient chinese wisdom teaches us, "He who wash cloak with winning lotto ticket in pocket will cry ten-thousand tears." Do you have a life philosophy?

Yeah, "It's the coder, not the language" and "Knowledge is language independent", just kidding. Seriously, it's "Live and let live", I believe that all of us has a part in this universe. Every being, sentient or not, is as important as you are. Just because you can doesn't need you have to. You may be better than someone at coding or art but he may have talents that that you can only dream of. You as a human being should respect someone else's religion, ideas and beliefs. *Gets some insecticide to kill some creepy cockroaches hiding in the cupboard....

Which character from 'Street Fighter' do you most identify with and why?

I'm never a fan of Street Fighter, nor Tekken, nor most fighting games except King of Fighters. I could not really identify with SF characters, I could identify more with the character "Genso (Genjo) Sanzo" from the anime "Gensomaden Saiyuki" or "Dias Lag" from "Shadow Skill". But if I had to choose from a fighting game, I would choose "Iori Yagami" from King of Fighters. I fashion myself to be a something of a *jack* not the *king*. Good enough but not the best. Genso, Dias and Iori is like that, a well balanced person, a "rounded" guy. I could be adept in almost all subjects I'm interested in but not quite good enough to be looked up to.

Anything you'd like to add or rant about?

Yeah. Don't let QB die, code with a happy heart, and share what you know. :*)

Visit Piptol Productions or RelSoft's Genso's Junkyard.

## Beating The XP Straightjacket

### Written by Nekrophidius

Now that Windows XP is the dominant OS for the PC, QB programmers have been faced with even more roadblocks than we had before. What was once a simple matter of finding drivers that worked in DOS has become an all-out compatibility battle: keyboard problems, sound problems, memory problems, and the biggest killer of them all, video card problems, can plague a would-be great product. So then, what can we do to take back DOS? |

### EMULATION

The first thing we'd think of is to try an MSDOS emulator. Emulation in this sense is a program which mimicks specific hardware in order to run specific software. In this case, we're emulating an x86-based computer, and the software to run is MSDOS.

DOSBox (http://dosbox.sourceforge.net/)

  Emulation of MSDOS in XP is best accomplished through a program called DOSBox. DOSBox is arguably the most advanced third-party emulator and emulates the environment very well.

  Pros:

  - Emulates common hardware that virtually all games support
  - Cross-platform: Windows, Linux (Fedora Core 2, Gentoo, Debian, Suse), Mac OS X, FreeBSD
  - No extra environments to install
  - Emulation speed can be controlled and the environment can easily be optimized
  - Completely free (open source)

  Cons:

  - Can be VERY slow, even on high-end machines (your 2GHz machine may run as if it were a 486 with default settings!)
  - Very little protected-mode support (although not much of an issue for us QB coders and gamers)

### VIRTUAL MACHINES

When emulation isn't enough, try a virtual machine package. Virtual machines attempt to "mirror" your hardware in a seperate environment to allow you to run another operating system inside your presently running operating system.

To use a VM application, install it, then create the environment you'd like to use. For our purposes, the best possible environment is probably Windows 98 Second Edition, so be sure to have a copy of the disc handy, or a way to copy its files into your VM environment. Start up the environment, install the OS from the installation disc as you would normally, and when it's ready, most VM packages have a special set of "tools" you can install to give additional speed and features inside certain operating systems, so be sure to install that too.

Please note that the pros and cons I've listed here are all relevant to my own and others' experiences with these products, and I try to cover issues which are important to those of us who use QB, especially for making and/or playing games.

VMware Workstation (http://www.vmware.com/)

  VMware produces this VM package which has been around for quite some time now. The latest major builds, the 4.x family, require a Generation 6 (Pentium II or AMD Athlon) or better processor due to CPU-specific instructions that are only present on those processors. Older versions (like the 3.x family) will run fine on 586-class machines, although often somewhat slowly. When run in Windows, VMware Workstation requires an NT-class operating system as its host.

  Pros

  - Cross-platform: Windows NT, Linux
  - Exceptionally easy to set up
  - Attempts to mirror most hardware directly

  Cons

  - Tends to install certain devices which have no MSDOS support (for example: network)
  - Raw video modes can be very slow to draw (like the Windows boot screen)
  - On fast computers, games with no speed throttling can run too fast and the video will break up a lot
  - $189 download cost, $199 for the boxed version
Virtual PC (http://www.microsoft.com/windows/virtualpc/default.mspx)

  Microsoft bought this product from Connectix in February of 2003. Thus far, the only changes made to the Windows version of it have been the removal of all *nix versions from the environment table. This VM package also requires an NT-class operating system as its host, and also requires a Pentium II, AMD Athlon, or greater processor. For Macs, it requires at least a 700MHz processor (however, Windows 98 is not supported on the Mac version).

  Virtual PC is the VM I use for development of my FPS game, Two Lords. It runs the game at a good speed (a little fast though) although the palette fades are exceptionally slow.

  Pros

  - Cross-platform: Windows NT, Mac OS 10 or higher
  - Mirrors some hardware directly and installs common devices for others (example: my AC'97 was installed as a SoundBlaster 16 in Windows 98SE)
  - Raw video modes are only slightly slower than tool-driven modes, even when windowed
  - MSDOS games run a bit slower than with VMware Workstation, so on fast computers, games with no speed throttling won't have as much video break-up

  Cons

  - Resizing the Windows desktop in the VM while fullscreen can have strange effects on the desktop size of the host OS
  - Writes the certain ports (especially certain video ports, like the video palette ports) is often painfully slow (palette fades in your favorite QB games are going to be very slow)
  - The use of the "action key" is very foreign and many users get discouraged with it rather quickly (this is like a "hot key" which allows for certain functions inside the VM, such as releasing the mouse from the VM window or allow Ctrl-Alt-Del inside the VM...VMware handles this MUCH better)
  - $129 boxed version only

### CONCLUSION

So while neither VM package is really a very elegant solution (an extra 200-300MB of space used up on your hard drive just to run MSDOS applications, plus the cost of purchasing them), the use of a VM is going to be a bit more reliable and faster than using emulation. Either way though, you're still going to be able to run all your old MSDOS games as well as continue to do QB development while in these environments if set up properly.

Then again, perhaps your favorite application or game runs perfectly fine inside the XP MSDOS VM. Well, chances are you have no sound support, so you'll want to install a great little driver called VDMsound (http://www.ece.mcgill.ca/~vromas/vdmsound/). This will give you sound support inside the Microsoft VM, and development is underway for VESA support as well, meaning that all those games which use realmode SVGA modes may someday work without problems inside the Microsoft VM.

Even as Microsoft attempts to kill off the last traces of MSDOS, there are people out there willing to keep it alive one way or another. That can only be a good thing for those of us to still cling to this ancient little thing we call QB. :)

-Nekrophidius

Nekrophidius has been called "QB's Busiest Man" by SJ Zero (author of Quest For A King)...you can find him at just about every QB message board around, as the editor of V Planet!, and the head of Lost socK Software.

## Some DOS Emulation Impressions

### Compiled by Pete

This month, I was originally planning on writing an article on...well...beating the XP Straightjacket. But it seems that Nekrophidius has beaten me to it -- and did a great job at it too. So I decided to scrap my article on DOS emulation / virtual machines and just release a few user accounts that I received about emulating DOS and QB on other platforms besides Windows XP. Johnathon Simpson emailed me about emulating DOS in a Linux environment, and Svante (alienqb) emailed me about emulating QB on Mac OS X. I think you might find their commentary interesting. No longer is QB limited to just Microsoft operating systems!

### QB Emulation on Mac OS X

By Svante Ekholm ("alienqb")

> I always appreciated the simpleness of QB. If one has a problem that so calls for writing a small program that calculates anything, QB is THE way to code it FAST and SIMPLE. I couldn't stand being without QB on a computer, so when I bought a Powerbook I started looking for ways to run QB on it, and I found it with DOSBox.

> DOSBox is a competent and free emulator that runs MS-DOS software with more compability than Windows does with it's embedded DOS emulator (it can even run Windows 3.1 - on the mac!). The only problem is the speed of the emulation. Running QB on the emulator is like running QB on a fast Intel 386, i'd say 33mhz, with 16 megs of RAM. As my G4 CPU hit's the pedal to the medal, Command & Conquer runs slowly and Sim City is very much playable. Granted the nature of interpreted programming languages, the speed's not much for running the comparatively slow QB games.

> I'm sure that speed won't be a problem in a few years. The emulator's are being optimized, we have Moore's law and it's not like QB is getting bigger system requirements as time passes. Today QB can be run on cross-platform with to write simple applications with ease. Just don't try to play Wetspot just yet. :-)

/svante "alienqb"

#### Some Screenshots of QB Running in Mac OS X:

The Mac OS X Desktop with DOSBox running. Click here to see this full size.
Closeup of the DOSBox application window running QB.

### DOS Emulation in Linux

By Johnathon Simpson

> Used DOSEMU on linux before. I ran a service for a while I called DIAB, dos in a browser. The concept behind it was that multiple related DOS sessions would run on a linux box, all of which had access to the same filesystem. These would be semi-interactive, as far as a file written to a location from one session could be read in another, or even by the host linux system. Piggybacking on top of linux even provided a modicum of network support.

> Basically, you could browse to my server, login, and get your session. Sessions stayed active, so a you could program in the same session all day, week, month... whatever. Since you could save to the linux filesystem, and the linux box had apache, it was even possible to download (or upload) your work. All of this happened in a small Java applet that emulated the display for your DOS session, and handled keyboard/mouse stuff. I borrowed the pieces and modified them to suit my purposes for this project. All in all, I used a stripped down linux mandrake distro, slightly modified tightvnc, and DOSEMU. The linux box had apache, vnc, dosemu, and smb support installed, with very little else.

> Anyway, it succesfully ran QB, PDS, VBDOS, and PB without difficulty, for the most part.

Have your own DOS / QB emulation stories? Send them in, and we'll feature them in the next issue of QB Express!

## The "Text Map Game" Competition Has Been Extended!

### Organized by Pete

You now have another month to enter this competition!

Although there was quite a bit of interest in this competition, I received only one entry to this month. I think a lot of people intended to enter, but they simply ran out of time and missed the deadline. For that reason, I've extended the time frame until Christmas!

Below you'll find the same instructions that I ran last month. Under the next heading, you'll find some more screenshots and some ideas, taken from the official message board thread. Finally, under the last heading, you'll find some information about the one entry we've received so far: The Numbervold by Ryan Szrama, a.k.a. "Ryan".

### The Challenge

Your challenge is to create a text-based game using only one "map" made entirely out of text. Your game must have a character (represented by the DOS smily face character) that you move around with the arrow keys. Everything else is up to you.

A screenshot of Lost 2 by Groovy Concepts, 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.

Entries will be due on or before December 25th, 2004 at midnight, Eastern Standard Time. (That's Christmas day!) Results will be revealed in Issue #5 of QB Express, which will come out by the end of December.

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.
> - Entries are due no later than December 25th, 2004 at midnight Eastern Standard Time.

Visit the official message board thread for the latest information on this competition. This is where you go to ask questions and chat about your progress. You can also check here to get updates of when entries are submitted, and how the judging is going.

Good luck!

### Perhaps A Little Inspiration?

Below are some other examples of games that use a smily face on an ASCII map. Some of them use scrolling/multiple maps (which is not allowed in this competition), but they all use a smiley face character on a text map...and they all do it pretty well. Make sure you take notes!

> Dark Woods 1 by Jocke The Beast

> Dark Woods 2 by Jocke The Beast | Capture the Flag by NeuroLake Software

> P.R.O.G.U.E. by Dunric

> Wurmi (site) | QBasic: The RPG

> Crystal By SingSong

#### Some answers to a few questions:

Nathan1993: Does it HAVE to have a map? Or can I enter the text-based war game that I am currently working on?

> Your "map" can consist of just empty space if you'd like -- which would mean that you don't really have a "map". Basically, what I don't want is a scrolling "tile engine" type set-up, just with text. By my definition, your "map" consists of the static text "objects" that your character will move around in the game.

> So, you can have no "map" per se, if you simply don't have static objects like walls, trees, buildings, etc. However, your smiley face character still has to move around the screen using the arrow keys. How this figures into the gameplay is up to you.

Neo: Pete, I'm currently making a game. But I don't know if it's actually allowed (it would be nice if it was allowed...it's not top-view but front-view. And the players have ascii characters that can move to some extent. In short, I'm making something like Scorched Earth in text mode. Am I allowed to do this? (I hope so).

> Yep, sounds good to me. As long as your map is made entirely out of text, and you move your character using the arrow keys. It doesn't have to be a top-down game, and it doesn't have to be an adventure / RPG game. You can use any perspective you'd like -- side view, top view, 3D raycaster, etc. Actually a neat idea would be to make something like the Game Boy version of Face Ball 2000, a very simple FPS game.

Nekrophidius: How about a fighting game in ASCII using the smiley face as the characters' heads? That would be definately something I'd make.

> Yes! A fighting game would qualify as long as you have only one "map" and you move the character with the arrow keys. For example, take a look at this game: Fight! v2.0

> That qualifies for this compo, and is pretty much what you had in mind.

### 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!

You can download The Numbervold at Ryan's site as well as Jocke The Beast's Homepage. There is also quite a bit of information about the game at Jocke's site, especially on the message board.

Having played The Numbervold quite a bit, I have to say, it's a pretty fun and neat game. And right now, it's guaranteed to win this competition (since it's the only entry so far)! I encourage everyone to follow Ryan's example, and ENTER this compo!

Send your entries to pberg1@gmail.com!

## Joe's Pointless Points

### Written by Joseph King

Welcome readers. It's time to talk some trash. People love to read trash. For one, it's relaxing, humorous, and has no point. So you don't have to leave this article thinking you missed out on anything, because you won't. This article just contains paragraphs that have nothing in common and lead nowhere in general, but I had fun writing it, so you just might have some fun reading it. If you don't, I'll hunt you down in your sleep! ;)

### A Brief History of the Qbasic Life

Qbasic was introduced sometime in the 80's. Q, meaning "quick", was probably more of a selling tool than an actually description of the product. Although it is the fastest language that I know of where you can program "Hello, World" in, so maybe the 'Q' wasn't just for a selling point, or was it?

Later on, Microsoft started distributing this "Qbasic" with their windows software. Since windows became the dominant OS, Qbasic became the dominant basic language for some time. This fired up an online community that peaked in the late 90s.

### A Serial Killer's Shadow Lurks Within His Source Code

There's something about Qbasic that attracts serial killers. Yes, I said serial killers. Most Qbasic developers have developed at least one pointless blood & guts shooter during their "intimate" time with Qbasic. Should this go on the official list as one of the attributes of a serial killer? We might know in about 10-20 years when all the little, bloodthirsty programmers have time to mature to the full extent of their crazy psychoness!

### Keystone Light!

Future Software, once the key stone of the QBasic community, now just rubble under the remnants of half-active sites, is constantly trying to be restored back to its fullness. There's only one problem. It's like that commercial were some guy is holding a party at his home, and the cd player has just finished playing all the CDs. By the time he's able to change the CDs and press play, all his guests have left. The same theory can be applied to the community. By the time, if ever, the Future Software site is restored back to its fullness, who's going to be there? Sure, there are still quite a few sites and a good-sized community, but the community now is only a fraction of what it once was. Part of this is also due to the evolution of computers and Micro$oft trying to get rid of DOS. Many have moved on to other platforms, such as C++, Visual Basic, Java, etc.

### A Beautiful Oblivion

What about those sites that vanish into oblivion? A once potential Qbasic site with some great content is floating around online. The next day, there's no evidence that it ever existed. Was it all just a part of your imagination, or did the person who owned the site feel so much shame from once using Qbasic that they can't bear the fact that someone may know that they once programmed in it?

### To Summarize It All!!!

Today, I covered "controversial" questions about the community. Will Qbasic developers become Serial Killers? Will Future Software ever be restored back to its fullness? If so, will the community's growth accelerate dramatically? And finally, do some people feel pure shame from programming in Qbasic to the extent that they remove all evidence that their Qbasic site ever existed?

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

Visit Joe's site, DeltaCode.

## Piptol Meets... Na_th_an

### Conducted by Piptol

Free-thinker, musician, artist and coder.. Nathan is the most prolific poster on the QBN forums, and incredibly not a single post of his is spam! Creator of acclaimed platformer 'Jill the Goddess', and general all-round helpful bloke. Our reporter investigates..

Hi Nathan, and thanks for taking the time to talk to us.

No prob, it's me who's honoured. What I hope now is that you are able to run the na_th_an-to-English translator without problems :D

So, where are you from and what do you do in real life?

I'm from Andalucía, Spain, simply the best place on the world. In my real life I'm trying to pass my last subject at college, so probably on December I will be a computer engineer. Meanwhile I am waiting for a job call that may come soon. Appart from that, I enjoy drawing comics, playing and composing for my indie rock? band, and of course hangin' 'round with friends and drinking tons of beers.

How long have you been coding in QB, and how did you get started?

I had coded a whole lot in all sorts of 8 bits computers BASICs when I was a kid, mainly in the Sinclair Spectrum and Amstrad CPC lines, so when I was bought my first PC in 1994 the first thing I did was starting that QBASIC.EXE which came with MSDOS. In 1999 I got a connection to the internet so I could find and download QB 4.5, so I don't know whether to answer 10 years or 5. I could say that 10 years coding and 5 years with the hassle of compiling ;)

Which of your projects has given you the most satisfaction and why?

The most part of my projects have been collaborations. I've realized that most of the time I've been in the QB communtiy I've been helping other people in their projects and being some kind of "intelligent tutorial" in the forums instead of coding my own stuff. The most used ones have to be my GUIs and script parsers, used by Clara in all her games and some other people. From my games, most of them had to be left unfinished due to time constraints. Anyhow, I have to answer "Jill the Goddess", 'cause it's one of the few things I've actually completed, even though my entry to the minigames compo at VPlanet a couple of years ago, Lala, was very superior. Many people ask me to finish Lala. And I would like to.

'Jill the Goddess' caused some controvosy when released due to pictures of naked and scantily clad curvaceous women. How do you answer your critics who say nudity in games is wrong?

I've became more tolerant with time, maybe it is that I am getting old or something :D. In 2001, when the game was released, I replied every complain with endless rants. Now I've changed my attitude, and just ask people that if they don't like it, just don't look at it. But also that, please, don't bitch about it. Now I can understand if someone gets disturbed by nudity, and I accept it. Anyhow I've been demonized by some people, they should consider me a pervert or something like that that eats children and rapes goats. I dunno. To me, the depictions shown in my game were just artistic naked poses. They were beautiful, as the human body is beautiful. There wasn't sex in my game, that's why I complained when it was put in the "for adults" section in many places. A pervert is not the person who places a naked woman in his game; a pervert is the person who finds it lewd and related to sex. Maybe some people should face life as it is. Naked.

A wise man once said, "He who posts nude photo of self on internet will regret when little sister finds it". Any regrets about that naked photo on the Basicnetwork forums?

That was the kind of "hard question" I expected! Well, I just found it the best way to be honest, just that. Me, the #1 person in the QB community to tell that the naked body isn't something "bad" or "dirty"... I just tried to teach by example, I guess.

What are you working on right now?

Right now I am tidying up my life, plus I have a really big compromise with the comics web I collaborate in, http://ojodepez.cjb.net. Anyhow, I still find some time to code. I'm working on a DX wrapper in VB that's easy enough so people can code games in the same fashion they do them in QB but using VB. I started doing it 'cause I had to port the BSC3 engine to VB. The BSC3 engine is a Point'n'Click engine that Clara (from Bulma) and I coded using QB and Future.LIB. As QB/Future.LIB programs only work on one out of 20 computers out there, we decided that we weren't gonna make any games for the BSC3 engine until we ported it to Windows. Appart from that, I plan to release my everlasting "Phantomas 3" project with my pal Phobeous. It's a classic platformer named after an 8 bits classic. The game is causing great expectation in the retrogaming scene. As long as it refers to QB, nothing at the moment, but very soon you'll begin to read about something called "Jill 2".

I've been looking forward to 'Coshinos Quest' since the VPlanet 2K3 Expo. What's the story with that?

The story is that it is on hold until I find the time, i.e. I find a job. When I have my job, I'll be able to organize my time, to find time to draw for my comics web and to code like I did before. My #1 target on the QB scene is Coshinos' Quest. After all, it just needs a couple of details and levels to be finished. The problem is that when I think about QB and all the hassle with sound in MSDOS I get discouraged. But we now have VDMSound, so I think I'll use DirectQB + QMidi as always, so problem solved.

It would be so sad that I dismissed that project. I got it to run at 60 fps in my old 233MMX computer, with 50 pigs on screen and that nice parallax scroll. I really liked the idea 'cause it's a game of a sort that has never done in the QB comunity, I think. Let's see if I can have it finished before next summer. I want to have the honour of having it reviewed at the new VPlanet by Nekrophidius in person by then ;).

Which character from 'Street Fighter' do you identify most with and why?

He he! You know I always choose Chunli to play. I remember that funny quiz that someone posted at QBN that told you which character from 'Street Fighter' fit you the most according to your replies. And yes, it was Chunli :D

A famous philosopher once said, "You must defeat Sheng Long to stand a chance!" Do you have a life philosophy?

Wise words. I couldn't expect less from Ryu. A life philosophy? Yeah, I guess everyone with a minimum of intelligence has one. If I had to sum it up in a sentence, it would be "respect those who respect". And I am Spanish, and from Andalucía, so I guess my attitude in life is enjoying it the best that I can. I'm of those kind who wants a job to live, not to live for my job.

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

Rant? Well, everyone knows that I have two or three subjects of continuous ranting, so I won't ellaborate more on the topic. But yeah, I have something to add. Something that we all know, but we love to read: QB will never die! It's a bummer, it's a hassle, but it will never die.

The problem is not the outdated compiler, but the things you expect from it. The QB Community should realize that as time goes by less and less people will be able to run QB games, and that in a short future we will have to use emulation to make our games run. There is something that is a huge truth: if you want your games to be played they have to work without problems in the Windows platform. Even with things like v1ctor's or Nekrophidius' upcoming 32 bits compilers you'll have to recode many portions of your already finished games to port them to Windows, unless those new compilers come with wrappers for the most common libraries out there, which is unlikely to happen.

Why keep people coding in QB, then? I dunno, maybe 'cause it is easy and stuff. Anyhow, I recently found that what I liked was not coding games in QB, but coding games in BASIC. The ease was not because I was coding in QB, but 'cause I was coding in BASIC. What are we, QB fans or BASIC fans? If the answer is "QB fans"... What has QB that other BASIC compilers don't have? It's a hard question. Specially for me, who recently have found out that you can code exactly in the same way in VB, getting fast, compatible and stable programs that everyone can run and enjoy. Some purists will kill me, and most of you may think that I am running into a contradiction, but to me VB is the latest version of QB.

Anyhow, and in a completely irrational fashion, I still need to turn that nice blue screen on. And there are lots of people like me. Hence QB will never die.

And that has made me remember a lil' rant I had to shout ;) : QB will never die if the QB Comunity keeps working together. There is some stupid kind of competitivity among QB sites that plainly sucks. The more the merrier, uh? This is a call.

Thanks for your time :)=

Visit Piptol Productions or Na_th_an's site.

## Data Structures & Algorithms: Path finding I

### By abionnnn

This is the first issue of the series that I am writing about Data Structures and Algorithms in QB. Unfortunately, due to end of semester exams I had to rush this through and I couldn't cover everything I wanted to in detail. Thus I decided to split up the issue into two pieces, the first being a descriptive piece, the second being an throughly analysed implementation. I hope you find them useful.

### 1. Introduction

A problem which often arises while making a strategy game, some AI code or just doing things out of interest is the path-finding problem. A lot of the text that can be found online, either oversimplifies the problem, or involves Graph Theory which a lot of QB programmers maybe not be familiar with. In two issues, I will attempt to make this both easy and satisfying. Be warned though, I did say attempt. =)

There are two basic algorithms for finding a path in a map, a depth first search (DFS) and a breadth first search (BFS). The latter is guaranteed to give the shortest path, if a path exists. There is also an algorithm called Dijkstra's algorithm, which gives the shortest path but in most usage in games (unweighted graphs ... don't worry) this reduces to the BFS algorithm so it won't be considered. An additional fast path finding algorithm is the A-star algorithm. This doesn't always give the shortest path but it is faster. This requires a lot of data structures, deserving its own issue.

Anyways, for now we will only look at the DFS and the BFS. There are some pre-requisites though people who know about them can just skip them and read on. You are not really missing anything! (*evil conspiracy chatter*)

### 2. Pre-Requisites

In order to be able to do a lot of the coding you will need to know about the data structures called the "Stack" and the "Queue". Alternatively these are called Last-In-First-Out (LIFO) and the First-In-First-Out (FIFO).

### 2.1 Queue

The queue is exactly what its name implies. For example in a night club, people line up in a queue because they are stopped by a bouncer at the door. Generally no one is allowed to push in front of anyone (unless they have priority, in which case it becomes a priority queue ... maybe another time ;)) and when there is room to spare, the bouncers let the first person who lined up inside. Then the person after them becomes the first person lined up in the list and the process continues.

In our case we have 'items' which are lined up in a queue. We can do the following operations:

- Extract the first item waiting on the queue

>          _________\ Extract
>         /         / Eggs
>      __|__________________________________
>     | Eggs | Butter | Cheese | Rice | ... |
>     |______|________|________|______|_____|

- Add an item to the back of the queue

>                    Insert __\_________
>                     Ham     /         \
>      __________________________________|__
>     | Eggs | Butter | Cheese | Rice | Ham |
>     |______|________|________|______|_____|

- Check to see if the queue is empty.

> (This is used for decisions in algorithms.)

- Empty the queue

To implement these operations we use an array and two index integers. Unfortunately, QB 4.5 doesn't allow you to place an array within a TYPE (though PDS does), thus we'll need to implement our queue on the go.

The easiest way to do this is to first assume that we will never overflow. Thus we use a fixed array size such that for our use, it would never be accessed out of bounds.

One of our index integers will point to the last item on the queue, while the other one will point to the first. If the queue is empty, we can make the "first" pointer, point to the very last block on the array and the "last" pointer point to the very first block on the array. When we add an item, we would add it to the back, thus this scheme is logical.

In the next issue, we will implement a queue. Make sure you understand what it does first though!

### 2.2 Stack

A stack is a simple data structure. It is like a queue but in reverse. You add items from the back, and take items from the back. Implementing a stack is a lot simpler, since you only need a stack pointer (indexing the back) to add/remove/determine emptiness/clear.

The jargon piece for placing items on the stack is PUSHing, while removing items is POPing.

### 3. Depth First Search

Think back to those silly maze puzzles that you used to solve when you were bored (you're a lot more cunning now, since you get computers to solve them for you ... when you are bored). You'd trace your position from the start until you reach a junction where you had to make a choice. After reaching a dead end you would trace back to the junction and try another path. This process is repeated in a recursive fashion until the goal is reached.

The DFS algorithm is very similar to this. You will require the following essential data structures (ingredients):

- A stack
- An array of already visited locations

These are some things to note (some are quite obvious)

- The top of the stack contains the current location.
- The array mentioned above can be one which is initially filled with zeros. When you "visit" a location, you set it to 1.
- A location is reachable is one which is: not visited, not a wall, not out of bounds.
- The stack will need to be big enough to hold the longest possible path. Just to be safe, make it the same length as the number of location on the map.

The algorithm for DFS is as follows:

> (0) Initialisation: Empty stack, empty already visited locations.
> (1) Push the start location on to the stack, mark it as visited. (This is the current location.)
> (2) Check if the stack is empty. If so, terminate failing to find the goal.
> (3) Check if current location is the goal. If so, terminate successfully.
> (4) Check if there are no reachable positions from current location. If so, pop the current location off the stack, then goto step 2.
> (5) For the current location, find an adjacent location* which is reachable and push it onto the stack, marking it as visited.
> (6) Goto step 2.

You can do this by checking the location which is above, below, to the left or to the right of your location. But only do it once. Of course if diagonal moves are allowed, you will need to check these too.

As you can see, it is a very simple algorithm. The best way to understand it, is to try it on paper. Draw yourself a maze (on square paper if you have it), a starting location and a goal. Following each step, marking visited squares by shading them. By choosing the adjacent square methodically (ie. having a preference for direction) you can see how it typically works in a computer.

Where is the path you ask? Heh, it's in the STACK! By reading the stack consecutively like an array you can get a trace of the directions you must move in order to reach the goal. Unfortunately, this algorithm will not always deliver the SHORTEST path from the start to the goal. In fact, the paths it typically finds would make you crack up a bit. =) This is where the BFS shines, as described in the next section.

### 4. Breadth First Search

This method can seem counter intuitive at first, but it is akin to flooding the maze with water to see if the goal gets wet... kind of. But not as fun. =P It can be quite processor intensive though, if the map is sparse (i.e. large open areas) rather than one with thin corridors. A method similar to it, called the A-star algorithm fixes this by preferring to move in the direction which gets you closer to the finish. But to understand A-Star (and all it's various siblings), you must first understand BFS.

The following ingredients are required:

- A queue
- An array of already visited locations.
- An array containing the "parent" locations, i.e. the location which added this location. (explained in algorithm)

You can actually combine the last two, by having the value for a non-visited location as 0, and combining the coordinates into an integer for the parent locations. Obviously, if something has a parent location then it already has been visited.

Like before, the current things need to be noted:

- The first item on the queue contains the current location.
- A location is reachable is one which is: not visited, not a wall, not out of bounds.
- Just to be safe, make the queue length the same length as the number of location on the map.

The algorithm for BFS is as follows:

> (0) Initialisation: Empty queue, empty already visited locations.
> (1) Push the start location onto the queue, mark it as visited, but set it's parent location to some special value indicating that it is the start. The initial location is the current location.
> (2) Check if queue is empty. If so, terminate failing to find the goal.
> (3) Check if current location is the goal. If so, terminate successfully.
> (4) Add each reachable location to the end of the queue, marking them as visited. For each of these added locations, make their parent location the current location.
> (5) Remove the current location from the front of the queue, set current location to the item now at the front of the queue.
> (6) Goto step 2

The two algorithms may seem similar, but the key to their difference is about to be highlighted. At the end of the DFS we noted that the path is given by the stack. Unfortunately, finding the path for the BFS is not so simple (but it is not too bad). This is where the parent location thing comes in handy! Each of these point back to the location which added it onto the queue. This is the key to understanding how the BFS works, since the queue will give you the shortest distances from the starting location each time you ask for another item. Getting back to things, assuming you terminated successfully, you will need to start at the goal. Look at it's parent location, then go there, and look at that location's parent location. Repeat this until you reach the beginning. Sounds simple enough, indeed you can put the queue array to use for this, since it's guaranteed to be of a sufficient size to hold the path.

Doing BFS on paper is not as manageable as DFS, but it's doable if you are willing to be extremely methodical.

### 5. Conclusion I

Well, using the above information, you should easily be able to code yourself a path finding routine. Failing that, next issue will contain a step by step implementation! Do not miss it! =)

-abionnnn

The author can be contacted at abionnnn@gmail.com
.

## Comics

### By Matt2Jones

Matt2Jones returns this month another "Bobby The QBasic Maniac" comic! Warning: This comic contains strong language.

## Lensflares

### By Relsoft

### I. Defint A - Z

A screenshot from the FreeBasic version of RelSoft's Lensflares program. It looks great in motion!

I was supposed to write a tutorial on game object systems when a friend asked me if could help him with his ASM project. The ASM project he submitted was just an input function and a floormapper but I got a lot of $$$ for it since a lot of groups wanted me to help them with their ASM projects. One group did not pay in currency but with the whole Hunter X Hunter "Greed Island OVA" (including G.I Final, about 9 CD's / 23 episodes). That's where the idea of making a lens flare article struck me. The Anime, as good as it was has blended CG effects with traditional hand drawn pixels to achieve a masterpiece! And one of the effects used to the fullest are lens flares.

So what are lens flares? It's those things you see in your camera when a bright light passes on the camera field of view. Lens flares are not that hard to model. They're just blended lightmaps put in a linear fashion superimposed together. One common thing with lens flare models is that they rotate from the center of the screen.

### 2. Coding

You need some basic undestanding of vectors if you want to understand the concepts I'm about to rant here. You can get an intro in vector math in Chapter 3 of my 3d tutorial. The basic idea of making the flare movement believable is to use linear interpolation. To lineary interpolate, we need two points, in screen 13:

The Center of the screen (cx, cy) or (160, 100) The Light's position on the screen (Lx, Ly)

Now that we have the 2 points, we need to define a vector between those 2 points. For those who haven't read the URL above, to get a vector from Center to Light point:

> Vector = Center - Light

or

>     QB code:

>     Vector.x = Center.x - Light.x
>     Vector.y = Center.y - Light.y

The vector we have at this moment is next to useless since directly manipulating the flare's position with it is a little cumbersome. What we need to do is to "normalize" this vector. That is, make its length equal to 1. To normalize this vector:

>     Normalized Vec = Vec / VecLength

We get the vector's length by using the distance formula:

>     c = Sqr(a^2 + b^2)

or

>     QB code:

>     dx! = v.x
>     dy! = v.y
>     dist! = SQR(dx! * dx! + dy! * dy!)
>     IF dist! < .00001 THEN EXIT SUB  'just a precaution for too small
>                                   	 'values
>     v.x = dx! / dist!
>     v.y = dy! / dist!
>     v.mag = dist!

> >     Where:
> >     v.x -> x component of vector
> >     v.y -> y component of vector
> >     v.mag -> Length of vector (may be used for scaling sprites)

How do we calculate each flares' position relative to the center of screen? That's the easy part. We define how far the farthest flare from the center and multiply it with the components of our normalized vector. Let's say we want the farthest flare to be 100 units(pixels) away from the center:

>     QB code:

>     Distance = 100
>     Flarex = vector.x * Distance
>     Flarey = vector.y * Distance
>     pset (Flarex, Flarey), col

That would be the location to the farthest flare. To calculate flares in between the center and the first flare, we just divide the value of the Distance and multiply it with the vector's components. So to get the position in the half-way mark: (Assuming the distance is 100)

>     QB code:

>     Flarex = vector.x * (Distance/2)
>     Flarey = vector.y * (Distance/2)
>     pset (Flarex, Flarey), col

Also...

>     Try these values:

>     1. Distance/4
>     2. Distance/8
>     3. Distance/1.8
>     4. -Distance/4
>     5. -Distance/8
>     6. -Distance/1.8

Here's an example file: Flaremov.bas

### 3. Sprite

I suggest you try to make your lens flare images with Photoshop. There are a lot of tutorials on the net on how to make nice flare textures. The textures I'm using here are all generated using some mathematical sampling I got from BLACKPAWN. And I'm not using some 13h color hack so that you'd understand the concepts behind them. For a thorough explanation of how to generate these textures, I suggest you visit his site. It's in C/Pseudocode but it's realy easy to understand. But the best way really is to get some free images off the net as there are tons of them.

### 4. Blending

The blending method I would use here is pretty straightforward. The concept behind blending is easy. You just "attenuate" the RGB values of each pixel depending on the flares pixel and the pixel behind the flare. Weighted mean in statistics would come in handy. :*)

To attenuate in true color with normal weights, you just get the average RGB values of the pixels.

>     ie:

>     	NewR = (ScreenR + FlareR) / 2
>     	NewG = (ScreenG + FlareG) / 2
>     	NewB = (ScreenB + FlareB) / 2

>     	putpixel (x, y), RGB(NewR, NewG, NewB)

One problem though is the fact that we are using palettised screen 13. So we cannot do some nice true-color stuff here. What we will do is to arrange our palette from black to bright-white in a gradient so that we could calculate the colors to pset easily.

>     	ie.
>     	color = (screencolor + flarecolor) /2
>     	pset (x, y), color

>     	Image() is a 2d integer array:

>     	QBcode:

>     	SUB transsprite (x%, y%, image%())
>     	'Draws out images translucently using a simple
>     	'blending method

>     	xmax% = UBOUND(image%, 1)
>     	ymax% = UBOUND(image%, 2)
>     	FOR ny% = 0 TO ymax%
>     	FOR nx% = 0 TO xmax%
>     	    c% = image%(nx%, ny%)                           'get color of image
>     	    IF c% <> 0 THEN                                 '0?
>             	dc% = POINT(x% + nx%, y% + ny%)             'get color of screen
>     	        PSET (x% + nx%, y% + ny%), (c% + dc%) \ 2   'blend and draw
>     	    END IF
>     	NEXT nx%
>     	NEXT ny%

### 5. Demo

Now that we have the sprites, then math, and the concept behind, making the program would be a cinch. All we have to do is to put(blended) the flare's images instead of pixels. To center the images on the points:

>     	x, y -> point we want to center the flare image

>     	x = x - (imagewidth/2)
>     	y = y - (imageheight/2)

>     	Transput (x, y), image()

We also would want to add flicker to the flare. Again, it's very easy. We just alternately draw a blank screen with the flare screen.

>     	Do
>     		frame = frame + 1
>     		if (frame and 1) = 0 then
>     			draw flares
>     		else
>     			don't draw flares
>     		end if
>     	Loop

Here's the whole demo:

- Exe <flaretut.exe>
- Source <flaretut.bas>

And if you want to see the demo in 32-bit...

- Exe <FBFlare.exe>
- Source <FBFlare.bas>
(Made with FreeBasic and TinyPTC)

### GOSUB CREDITS: END

Credits:

- Blackpawn for his nice flare textures tute
- Plasma for SetVideoSeg
- Pete fro this mag
- v3cz0r for the coolest 32-Bit BASIC compiler
- Gaffer for TinyPTC

RETURN

Download this tutorial and all source / executables right here!
Visit Relsoft's website, Genso's Junkyard.

## File Manipulation In QuickBasic: Sequential Files

### By Stéphane Richard

### INTRODUCTION

It is true, that all great programs seem to have one thing in common, they all allow to save data in some form or another. Whether it's scores to a game, the whole game, data for a contact list, you name it, there are many reasons you can find to need the ability to save the data of your program to a file. This will be the purpose of this series of tutorials. To teach you how you can save your data to a file and retrieve it at a later time in your programs.

This tutorial assumes that you know your way around QuickBasic and it's statements. Since the examples shown here may use these statements, it would help if you knew them. Let's go right ahead.

### WHAT ARE SEQUENTIAL FILES?

In this first installment, I will be teaching you how to work with Sequential files. What are sequential files? Well the best way to explain this is it is a file that is read from start to finish, character by character or line by line. There's more than one format of sequential file. Here are the more popular ones.

Comma Delimited File:
  Comma delimited files are bits of information seperated by a comma. The number of commas in a given line read determines the number of fields that will need to be accomodated. In a typical scenario, a comma delimited file is read line by line and split into as many commas are found on the line for processing. This format is used alot for importing and exporting data between applications.
Fixed Length File:
  Fixed length files are again read line by line only this time, the fields are aligned one under the other. Many programs, when they generate reports use this format. As far as reporting goes, the fixed length file is the most presentable form of sequential data.
Variable Length Files:
  This is your regular, garden variaty, text file. This tutor can most definitaly be categorized as a variable length file. It's a text file that has no specific formatting per se. It's usually used for editing purposes as a whole.

### WORKING WITH SEQUENTIAL FILES

Let's get right down to it shall we? In QuickBasic, as well as any Basic released after QBasic, all file manipulation statements are the same. What you'll learn in these 3 installments, will stay with you even in your Visual Basic projects that don't require so much data that a database is not needed.

Let's start by looking at a small sample program and it's related sequential file. Learning by example is often the best way to learn. I find that saying true especially when dealing with files. This example deals with a fixed length sequential file (because it's just clearer to read in an example program and data file). However, all coding done can be used for any kind of sequential data files that you can imagine.

>     -----------------------START OF PROGRAM-------------------------

>     ' -------------------------------------
>     '  VARIABLES REQUIRED FOR THIS PROGRAM
>     ' -------------------------------------
>     DIM FileNumber AS LONG
>     DIM LineRead   AS STRING
>     DIM ItemNumber AS LONG
>     DIM BookTitle  AS STRING
>     DIM AuthorName AS STRING
>     DIM BookPrice  AS DOUBLE
>     DIM TotalPrice AS DOUBLE

>     ' -------------------------------------------------------------
>     '  ACQUIRE NEXT FILE HANDLE AND OPEN THE DATA FILE (READ MODE)
>     ' -------------------------------------------------------------
>     FileNumber = FreeFile
>     OPEN "TEST.TXT" FOR INPUT AS #FileNumber
>     ' -------------------------------------------------
>     '  LOOP THROUGH THE FILE UNTIL THE END OF THE FILE
>     ' -------------------------------------------------
>     DO WHILE NOT EOF(FileNumber)
>        ' ----------------------------------
>        '  GET A LINE OF DATA FROM THE FILE
>        ' ----------------------------------
>        LINE INPUT #FileNumber, LineRead
>        ' ------------------------------------------------
>        '  GET EACH BIT OF INFORMATION FROM THE LINE READ
>        ' ------------------------------------------------
>        ItemNumber = VAL(LEFT$(LineRead, 4))
>        BookTitle  = MID$(LineRead, 6, 35)
>        AuthorName = MID$(LineRead,36, 18)
>        BookPrice  = VAL(MID$(LineRead, 60, 5))
>        ' ---------------------------------
>        '  DISPLAY THE ITEMS ON THE SCREEN
>        ' ---------------------------------
>        PRINT ItemNumber; "="; BookTitle; " "; AuthorName; BookPrice
>        ' -------------------
>        '  SUM UP THE PRICES
>        ' -------------------
>        TotalPrice = TotalPrice + BookPrice
>     LOOP
>     ' -------------------------------------------
>     '  DISPLAY THE TOTAL ACCUMULATED IN THE LOOP
>     ' -------------------------------------------
>     PRINT
>     PRINT "PRICE TOTAL = ", TotalPrice
>     ' -----------------------
>     '  CLOSE THE FILE HANDLE
>     ' -----------------------
>     CLOSE #FileNumber

>     ------------------------END OF PROGRAM--------------------------

The data file TEST.TXT should contain the following data to work properly with the example above.

>     ------------------------START OF FILE---------------------------
>     0001 Compute's First Book of PC         Unknown            3.99
>     0002 Compute's Second Book of PC        Unknown            4.99
>     0003 Compute's third Book of PC         Unknown            6.99
>     0004 Compute's Fourth Book of PC        Unknown            10.99
>     -------------------------END OF FILE----------------------------

#### EXAMPLE NOTES:

- Note that I used the FreeFile function to determine the next available file handle to be used in the OPEN statement. This is not a must. I could have used #1 or #n instead. However, In a bigger project that uses files alot, FreeFile assures that there is no conflicting File Handles used. It's good practice to use it whenever you're not sure of the number of files your program might need to open.
- OPEN "TEST.TXT" FOR INPUT AS #FileNumber is the line that does the physical opening of the file And assigns it #FileNumber as it file handle. Here "TEST.TXT" is hardcoded as they say. Of course it could be a string variable and you could ask the user for the name of the file to open. The "FOR INPUT" part tells QuickBasic that you want to open the file in Read mode as you'll be reading the contents of the file later in the example.
- Next is the loop indicated by the DO WHILE NOT EOF(FileNumber) line. In QuickBasic EOF() means End Of File. There is also BOF() for Beginning Of File and LOF() for Length Of File. Since you can't go backwards on a sequential file, you won't be needing BOF() at all. You'll see the use of BOF in the second installment for Random Access Files.
- The first line Gets a line of Data from the data file Using this: LINE INPUT #FileNumber, LineRead which means, essentially, Get a line of text from #FileNumber and put it in LineRead, a string variable that I declared at the beginning of the example.
- The next 4 lines in the loop are used to get the different bits and pieces of information from the line that we just read. Because we know, from the data file, the length of each piece of information on each line, we can do it the way I coded it. However some other types of sequential files won't allow you to work this way. For example, a Comma delimited file would usually require you to search for a comma (using the Instr() function) and getting the data between the location of the commas.
- Next we print the information we gathered (for testing purposes) to the screen. This way you can make sure that the information was read properly.
- Last line in the loop totals up the prices read. This is irrelevant to file manipulation but I just wanted to give this example program a purpose.
- Right after the loop, we print a blank line and then print the total we just added up in the loop.
- IMPORTANT: We then close the file handle. Many times This is forgotten by the programmer. But it's very important to never forget to close any and all file that you need to open. The stability of your data files will thank you.

### CREATING DATA FILES

Finally for this first installment, I'm always a firm believer that a file manipulation tutorial should show you both sides of the medal. Therefore, this next and final example will create the data file just as you saw it above in the read tutorial. After all, in order to read a data file, you have to be able to create it first, right? ;-). So here is the sample program to create the data file TEST.TXT.

>     -----------------------START OF PROGRAM-------------------------

>     ' --------------------------------------------------------------
>     '  ACQUIRE NEXT FILE HANDLE AND OPEN THE DATA FILE (WRITE MODE)
>     ' --------------------------------------------------------------
>     FileNumber = FreeFile
>     OPEN "TEST.TXT" FOR OUTPUT AS #FileNumber
>     ' ---------------------------------------------------
>     '  WRITE THE LINES, ONE AFTER THE OTHER, IN THE FILE
>     ' ---------------------------------------------------

> PRINT #FileNumber, "0001 Compute's First Book of PC Unknown 3.99" + CHR$(13)
> PRINT #FileNumber, "0002 Compute's Second Book of PC Unknown 4.99" + CHR$(13)
> PRINT #FileNumber, "0003 Compute's third Book of PC Unknown 6.99" + CHR$(13)
> PRINT #FileNumber, "0004 Compute's Fourth Book of PC Unknown 10.99" + CHR$(13)

>     ' -----------------------
>     '  CLOSE THE FILE HANDLE
>     ' -----------------------
>     CLOSE #FileNumber

>     ------------------------END OF PROGRAM--------------------------

The data file TEST.TXT should now contain the following data.

>     ------------------------START OF FILE---------------------------
>     0001 Compute's First Book of PC         Unknown            3.99
>     0002 Compute's Second Book of PC        Unknown            4.99
>     0003 Compute's third Book of PC         Unknown            6.99
>     0004 Compute's Fourth Book of PC        Unknown            10.99
>     -------------------------END OF FILE----------------------------

Well yes, I used a quick and dirty trick to create the file, I just printed each line as you can see. Of course, you could have formatted the line from different variables to form the line of data if you wanted to.

#### NOTES:

- Yes, again, I used the FreeFile function again. It's good practice, so I use it all the time. The important thing here is the the Open Statement itself. The main difference from the first example is the "FOR OUTPUT" part instead of the "FOR INPUT" part of the first example. This, of course, instructs QuickBasic to open the file in Write mode as you will be saving information to the file.
- After opening the file, the 4 lines that follow perform the actual physical saving of data into the file with the PRINT #FileNumber, "Information" statement. Here I used string literals, but a String Variable could have been used as well but I believe that this small example makes things clear.
- We then CLOSE the file handle. Like I said above, I can't stress enough the importance of not forgetting to do this. Like the old saying of "What goes up must come down!" I can say that "What gets opened must get closed too!".

And this is it for this first installment. I hope you learned something useful and be sure to look for my next installement where I will be convering Random access files.

You can contact Stephane at srichard@adaworld.com

## Pixel*Tile Scrolling Engines

### By DarkDread

> This is a "lost" tutorial from DarkDread's second RPG tutorial series, which began in QBasic: The Magazine in 2000. Of the four tutorials in this series, only two of them were ever published. Last month, we brought you part 3 of this series, and this month we bring you the fourth, and final, tutorial. Take a look!

Hail!

Welcome, once again, to another RPGs in QB tutorial. Once again, the chunk of the tutorial and the code is in the .BAS file. This text file is simply here for notes, and whatnot.

Note: this tutorial was originally written in 2001. There are no plans currently to write more tutorials.

### 1. Pixel*Tile?

What exactly do I mean when I say Pixel*Tile? Well... it is the act of scrolling the tile engine, one pixel at a time, thereby creating much more fluid motion than can be done with scrolling a tile at a time. The tile part in Pixel*Tile comes from the fact that, every time the player presses a directional key, the map is scrolled one tile in that direction, but one pixel at a time.

### 2. The code

The code, I belive is not too complicated. The one thing that I will point out, is that it uses GSLib as the graphics library. This simply means that you will need to load QB with the GSLib quicklibrary. We need GSLib, so we can have some 'virtual screen' to use as scrolling space, and so that any chance of flicker is eliminated.

First, you'll need to run this with the GSLib quicklibrary (it's included with this tut) loaded into QB. If you're not sure how it's done, simply type in qb.exe /l gslib.qlb in the directory where all of these files are located. You may need to include the full path to your copy of qb.exe, so if you have it in, say c:\coding\qb45\ then you would do this instead: c:\coding\qb45\qb.exe /l gslib.qlb . Anyway, once you have that done, you can hit F5, and walk around on a little demo map, with a demo character. Notice the nice smooth p*t scrolling? Now... do you want to know how it's done? Then read on! I've left comments in the code, explaining what each part does.

>     DEFINT A-Z
>     '$DYNAMIC
>     '$INCLUDE: 'gslib.bi'

>     DECLARE SUB LoadMap ()
>     DECLARE SUB Main ()
>     DECLARE SUB TileEngine (x1%, x2%, y1%, y2%)

Here, we declare constants and variables. Pretty standard stuff, except that you may want to note the Buffer& array. We need this for our offscreen buffer, since we're using gslib to eliminate flicker. :)

>     CONST True = -1, False = 0

>     DIM SHARED TileSet%(4040), Player%(4040), Buffer&(15999)
>     DIM SHARED ScreenMap%(-5 TO 21, -5 TO 14), TileMap%(-5 TO 45, -5 TO 45)

>     DIM SHARED PlayerX%, PlayerY%, ScreenX%, ScreenY%, PlayerDir%

Standard inits. We switch to 320x200x256 mode 13h, and initialize our graphics library. We also call LoadMap, and then go into our Main sub.

>     SCREEN 13
>     gsinit
>     LoadMap
>     Main

#### The LoadMap Sub

Standard inits and such. Here, we load the tilsets of the player and area which we will be using. We also create the default start on the map for the player, and init our screen and player x,y display coordinates.

We also load our map data from the file. It's pretty standard x,y data. Each TileMap%(x%,y%) holds a number value which corresponds to the type of tile to display. The first three bits of data in the file hold the max x and y size of the map, and the type of tileset to load. This is useful if you have more than one tileset.

At the end, we also fill the outside edges of the map array with tile number 5, which is our water tile. This is useful if the player accidentally wanders out of the boundaries somehow. :)

>     REM $STATIC
>     SUB LoadMap

>         DEF SEG = VARSEG(Player%(0)): BLOAD "wierdo.set", VARPTR(Player%(0))
>         DEF SEG = VARSEG(TileSet%(0)): BLOAD "tiles.set", VARPTR(TileSet%(0))

>         PlayerX% = 14: PlayerY% = 9: PlayerDir% = 1
>         ScreenX% = PlayerX% - 9: ScreenY% = PlayerY% - 5: PlayerMoved% = 0

>         FileNum% = FREEFILE
>         OPEN "demo.map" FOR INPUT AS #FileNum%

>         INPUT #FileNum%, MaxX%, MaxY%, MapType%
>         FOR y% = 0 TO MaxY%
>             FOR x% = 0 TO MaxX%
>                 INPUT #FileNum%, MazeData%
>                 TileMap%(x%, y%) = MazeData%
>             NEXT x%
>         NEXT y%
>         FOR y% = 0 TO MaxY%
>             TileMap%(-1, y%) = 5
>             TileMap%(-2, y%) = 5
>         NEXT y%
>         CLOSE #FileNum%

>     END SUB

#### The Main Sub

As it says, this is the Main sub. It loops through a select case statement, which polls for keyboard input, to see if the player has pressed a key. If they have, it passes the appopriate scroll data to our TileEngine sub.

The latter half of it is for the player animations, but, since this isn't a tutorial about how to properly animate a character, I'll leave it up to you folks to decide how that works. :)

>     SUB Main

>         DO

>             SELECT CASE INKEY$
>             CASE CHR$(0) + CHR$(72)
>                 PlayerDir% = 0
>                 IF TileMap%(PlayerX%, PlayerY% - 1) < 5 THEN
>                     ScreenY% = ScreenY% - 1: ShiftPlayer! = TIMER
>                     PlayerY% = PlayerY% - 1: Moved% = True
>                     ScrollY1% = -19: ScrollY2% = 0
>                 END IF
>             CASE CHR$(0) + CHR$(80)
>                 PlayerDir% = 1
>                 IF TileMap%(PlayerX%, PlayerY% + 1) < 5 THEN
>                     ScreenY% = ScreenY% + 1: ShiftPlayer! = TIMER
>                     PlayerY% = PlayerY% + 1: Moved% = True
>                     ScrollY1% = 19: ScrollY2% = 0
>                 END IF
>             CASE CHR$(0) + CHR$(75)
>                 PlayerDir% = 2
>                 IF TileMap%(PlayerX% - 1, PlayerY%) < 5 THEN
>                     ScreenX% = ScreenX% - 1: ShiftPlayer! = TIMER
>                     PlayerX% = PlayerX% - 1: Moved% = True
>                     ScrollX1% = -19: ScrollX2% = 0
>                 END IF
>             CASE CHR$(0) + CHR$(77)
>                 PlayerDir% = 3
>                 IF TileMap%(PlayerX% + 1, PlayerY%) < 5 THEN
>                     ScreenX% = ScreenX% + 1: ShiftPlayer! = TIMER
>                     PlayerX% = PlayerX% + 1: Moved% = True
>                     ScrollX1% = 19: ScrollX2% = 0
>                 END IF
>             CASE CHR$(27)
>                 ExitDemo% = True
>             CASE ELSE
>                 ' Do Nothing.
>             END SELECT

>             TileEngine ScrollX1%, ScrollX2%, ScrollY1%, ScrollY2%
>             ScrollX1% = 0: ScrollX2% = 0: ScrollY1% = 0: ScrollY2% = 0

>             IF LastMoved% = 0 AND Moved% THEN
>                     LastMoved% = 1
>                     PlayerMoved% = 1: ShiftedPlayer% = True
>                 ELSEIF LastMoved% = 1 AND Moved% THEN
>                     LastMoved% = 0
>                     PlayerMoved% = 2: ShiftedPlayer% = True
>             END IF
>             IF ShiftPlayer! + .25 < TIMER THEN PlayerMoved% = 0
>             Moved% = False

>         LOOP UNTIL ExitDemo%

>     END SUB

#### The TileEngine Sub

The meat of everything. This is the p*t scroll engine. Notice that it allows for input into how many pixel rows to scroll (These are the x1%, y1%, x2%, and y2% values). If you give all four values of 0, it will simply display the map. This is used if the player is standing still, and you want to animate stuff, like flickering torch tiles, or water for example.

Now, if this looks complicated, just look at it like a regular tile scrolling engine. This is pretty much what it is, except for the extra FOR...NEXT loops which are used to determine the scroll, and where to lay the tiles.

What we have, is a bit of a 'virtual screen' which is not displayed. This is in the x,y range of -1 to -20, and 320 to 340. Here, the engine still writes the tiles, even though they are not seen... until the tiles are scrolled.

Finally, we also determine which part of the player tileset to display here... but again, this isn't really part of the tutorial... so you can figure that out for yoursevles :)

Finally, for every time this sub runs... the results are displayed on the screen, and presto! We have p*t scrolling.

> SUB TileEngine (x1%, x2%, y1%, y2%)
> IF x1% = 19 THEN StepX% = -1 ELSE StepX% = 1
> IF y1% = 19 THEN StepY% = -1 ELSE StepY% = 1
> FOR ScrollX% = x1% TO x2% STEP StepX%
> FOR ScrollY% = y1% TO y2% STEP StepY%
> a% = -1: B% = -1
> FOR y% = ScreenY% - 1 TO ScreenY% + 10
> FOR x% = ScreenX% + 1 TO ScreenX% + 18
> ScreenMap%(a%, B%) = TileMap%(x%, y%)
> gssprite a% * 20 + ScrollX%, B% * 20 + ScrollY%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(TileSet%(ScreenMap%(a%, B%) * 202)), VARPTR(TileSet%(ScreenMap%(a%, B%) * 202))
> a% = a% + 1
> IF a% = 17 THEN a% = -1
> NEXT x%
> B% = B% + 1
> IF B% = 11 THEN B% = -1
> NEXT y%
> IF PlayerDir% = 0 THEN
> IF ScrollY% = 0 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(3 * 202)), VARPTR(Player%(3 * 202))
> ELSEIF ScrollY% >= -10 AND ScrollY% <= -1 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(4 * 202)), VARPTR(Player%(4 * 202))
> ELSEIF ScrollY% >= -19 AND ScrollY% <= -11 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(5 * 202)), VARPTR(Player%(5 * 202))
> END IF
> ELSEIF PlayerDir% = 1 THEN
> IF ScrollY% = 0 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(10 * 202)), VARPTR(Player%(0 * 202))
> ELSEIF ScrollY% >= 1 AND ScrollY% <= 10 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(1 * 202)), VARPTR(Player%(1 * 202))
> ELSEIF ScrollY% >= 11 AND ScrollY% <= 19 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(2 * 202)), VARPTR(Player%(2 * 202))
> END IF
> ELSEIF PlayerDir% = 2 THEN
> IF ScrollX% = 0 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(8 * 202)), VARPTR(Player%(8 * 202))
> ELSEIF ScrollX% >= -10 AND ScrollX% <= -1 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(9 * 202)), VARPTR(Player%(9 * 202))
> ELSEIF ScrollX% >= -19 AND ScrollX% <= -11 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(8 * 202)), VARPTR(Player%(8 * 202))
> END IF
> ELSEIF PlayerDir% = 3 THEN
> IF ScrollX% = 0 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(6 * 202)), VARPTR(Player%(6 * 202))
> ELSEIF ScrollX% >= 1 AND ScrollX% <= 10 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(7 * 202)), VARPTR(Player%(7 * 202))
> ELSEIF ScrollX% >= 11 AND ScrollX% <= 19 THEN
> gssprite 7 * 20, 5 * 20 - PlayerOffset%, VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), VARSEG(Player%(6 * 202)), VARPTR(Player%(6 * 202))
> END IF
> END IF
> gspcopy VARSEG(Buffer&(0)), VARPTR(Buffer&(0)), &HA000, 0
> NEXT ScrollY%
> NEXT ScrollX%
> END SUB

### 3. Final words

That's it. Not too complicated, is it? If you have any _specific_ questions about the tutorial, or about parts of the code, feel free to e-mail me at darkdread@funeralart.net and ask. I'll try to explain to the best of my abilities if there is something that needs to be clarified.

I hope you can make use of this... and as always, if you do take the code from here, a little 'Thanks DarkDread for the p*t scroller' in your game would be nice. :)

As an aside, yes, feel free to use the graphics from this tut as well. Honestly, I'd recommend making new ones instead tho, as these are just here to demonstrate the concept, they're hardly good. :)

Cheers!

DarkDread

### 4. Licence

THIS TUTORIAL AND ITS ACCOMPANYING FILES, MAY BE DISTRIBUTED FREE OF CHARGE BY ANY MEANS, SO LONG AS ALL FILES ARE INCLUDED AND NOTHING IS MODIFIED. THE AUTHOR SHOULD BE GIVEN CREDIT IN YOUR PROGRAMS IF YOU USE ANY OF THE CODE OR GRAPHICS CONTAINED WITHIN THESE FILES. THE AUTHOR IS NOT RESPONSIBLE FOR THE USE OR MISUSE OF THESE TUTORIALS. USE AT YOUR OWN RISK.

Download this tutorial and all source code in this archive.

## QBNow!
Part I: The Basics, Chapter 5

### Written by Neo Deus Ex Machina

> This is the third edition of Neo Deus Ex Machina's new QBasic tutorial series, QBNow! Starting in the September issue with the absolute basics of QB, this monthly tutorial series will turn a complete newbie into a seasoned veteran in no time! Every month, a new edition of QB Now! will be published in QB Express, which will build off of what you learned in the previous issue. Make sure you stay tuned!

> In this issue, we present you Chapter 5 of QB Now! Part I: The Basics, which will teach you about loops and boolean operators.

> If you'd like to catch up on Chapters 1-4, you can download a PDF version of QBNow! Part I: The Basics in its entirety right here! (This includes Chapters 1-5 and all appendices.)

> Enjoy!

> -Pete

## CHAPTER V: LOOPS AND BOOLEANS

### BOOLEAN OPERATORS

Boolean operators are operators that can paste two conditions together. You have used boolean operators often in normal life, even without knowing it. Take a look at the following example about the usage of boolean operators. In the example, you try to look for a person by checking his ASL.

>     IF PersonName$ = “Greg” THEN
>     	IF PersonAge% = 27 THEN
>     		IF PersonHabitat$ = “New York” THEN
>     			‘ you found him!
>     		END IF
>     	END IF
>     END IF

As you can see, this code doesn’t look very clean, even with identing. That’s why they invented boolean operators. Boolean operators are operators like AND, OR and NOT. See what the example will be with boolean operators:

>     IF (PersonName$ = “Greg”) AND (PersonAge% = 27) AND (PersonHabitat$ = “New York”) THEN
>     	‘found him!
>     END IF

In this code, you can immediately see what all conditions are. Also, you may know get to realize you used boolean operators often before... :). There are more boolean operators than AND. I will now show you a TF Table, what stands for True-False Table. In this table, you can see what the result of two conditions pasted together with the specific boolean operator will be. It might be hard to understand, therefore I'll not go talking to empty space, and here they come:

AND | True | False
True | True | False
False | False | False
OR | True | False
True | True | True
False | True | False
XOR | True | False
True | False | True
False | True | False
EQV | True | False
True | True | False
False | False | True
IMP | True | False
True | True | False
False | True | True
NOT | True | False
| False | True

In these TF Tables, the vertical row of true and false is the first (left) condition. The horizontal row is the second (right) condition. Well, what does all this stuff mean? Lets take the common AND operator for example. If you see in the table, AND only returns true when the first condition (vertical) is true and when the second condition (horizontal) is also true. Of course, you already knew this. :) Here’s some sample code to check when the boolean operators will be run:

>     A = 1
>     B = 2
>     C = 3
>     D = 4

>     IF (A = 1) AND (B = 2) THEN
>     ‘this IF condition will be true when A = 1 and B = 2.
>     ‘so when A = 1 and B = 2
>     ‘if any condition is false, the IF will be false.
>     ‘(AND is the logical conjunction operator)
>     END IF

>     IF (B = 2) OR (C = 3) THEN
>     	‘this IF condition will be true when B = 2 or C = 3.
>     	‘that means: it will be true when either B = 2 or C = 3
>     	‘or when both conditions are true:
>     	‘TRUE WHEN:
>     	‘B = 2 and C <> 3
>     	‘B <> 2 and C = 3
>     	‘B = 2 and C = 3
>     	‘so OR is very flexible :)
>     	‘(OR is the Inclusive OR operator)
>     END IF

>     IF (C = 3) XOR (D = 4) THEN
>     	‘this IF condition will be true when one of both
>     	‘conditions is false, and one is true. So:
>     	‘TRUE WHEN:
>     	‘C = 3 and D <> 4
>     	‘C <> 3 and D = 4
>     	‘(XOR is the Exclusive OR operator).
>     END IF

>     IF (D = 4) EQV (A = 1) THEN
>     	‘this IF condition will be true when both conditions
>     	‘are true or when both are false. So:
>     	‘TRUE WHEN:
>     	‘D = 4 and A = 1
>     	‘D <> 4 and A <> 1
>     	‘(EQV is the logical equivalence operator)
>     END IF

>     IF (A = 1) IMP (B = 2) THEN
>     	‘this IF condition will be true when the second condition
>     	‘is false and the first one is true. So:
>     	‘TRUE WHEN:
>     	‘A = 1 and B = 2
>     	‘A <> 1 and B = 2
>     	‘A <> 1 and B <> 2
>     	‘I never use IMP though
>     	‘(IMP is the logical implication operator)
>     END IF

If you’ve studied all six TF Tables, you should have noticed that the NOT operator doesn’t accept two conditions. This is due to the fact that And, Or, Xor, Eqv and Imp are binary operators and Not is a unary operator. This means that Not accepts one parameter. Not turns around the value of this parameter. In other words, True becomes False and False becomes True. Take a look:

>     IF NOT(A = 5) THEN
>     	‘this code will be run when A is not five
>     END IF

Looks simple, but keep in mind Not can also contain series of multiple conditions connected to eachother with other binary operators.

If you use multiple binary operators in one whole condition, you should place parenthesis to show to QB which condition to evaluate first. If you don’t know what I mean with ‘evaluate first’, think of just mathematical arithmetic:

> A = 7 * 8 / 3 + 2 * 4 / 9 – 3 ^ 2 * 5

Most logical errors in programs occur this way. You should put parenthesis about sections of code that have to be evaluated first. The above mathematical assignation can be e.g. like this:

> A = (7 * 8 / (3 + 2) * 4 / (9 – 3)) ^ (2 * 5)

This will get a whole lot different answer than the previous one. So if your condition gets a bit complex, put parenthesis:

> IF ((Score > 500 AND Skill < 4) OR (Score > 100 AND Skill > 9)) EQV (NOT(EnemiesKilled < 100) IMP (EnemiesKilled > 10 XOR BossesKilled < 2)) THEN
> ‘you may find out when this will be run! :)
> END IF

### LOOP DA LOOP WITH FOR AND NEXT

Now we finally are at the loops. I’ll start with the loop most difficult to learn, but very often used. This is the For loop. The For loop is a counter loop used in almost anything. You specify a lower and higher range, a step factor and For will count with your steps from the lower range till the higher range has been reached. Here’s an example:

>     FOR counter% = 1 TO 100 STEP 1
>     	PRINT counter%
>     NEXT counter%

As you can see when you run this example, the numbers 1 up to and including 100 are printed on the screen. I’ll now explain how this is possible. The first line defines a variable counter%, which gets the value 1 (the value before TO). QB will then run your program further, until it reaches Next. Then QB will jump back to the For statement, and increase counter% by your step factor, in this case 1. It will then loop again, increase again, loop again, etc. This process continues until counter% has exceeded the value of the high range (after TO), so when counter% > 100. QB will then continue with your program after Next.

I understand if this is hard for you to understand, but this loop is mostly used and by practising with it a bit you will get to know much more about it.

FOR var = begin TO end [STEP m] | This statement announces the beginning of a counting loop. At start, var will be equal to begin. After each loop, var will be increased with m. The loop ends when var has exceeded the range begin-end. Note that the stepfactor is optional. When left away, the stepfactor will always be 1 (one).
NEXT [var] | This is the end of a counting loop. When reached here, the program will go back to the FOR var to continue the loop, or just skip this statement when the loop has finished.

For is really used for doing very many things, here is another example of For:

>     INPUT “Enter your name: “, yourname$
>     FOR I% = 1 TO LEN(yourname$)
>     	PRINT MID$(yourname$, I%, 1)
>     NEXT I%

Note that when begin immediately exceeds end at the start of a loop, the For loop is never run. So For M = 1 TO 0 STEP 1 will never be looped.

### LOOP DA LOOP WITH DO AND LOOP

The second loop commands are also very often used, and should therefore be part of your knowledge as well. The loop commands are Do and Loop. A Do loop can be two things; either an infinite loop, or a loop that waits for a certain condition. Here’s the infinite loop:

>     DO
>     	PRINT “Infinite loop!”
>     LOOP

You can end a program running in QB at any time by pressing [Ctrl] + [Break] simultaneously. If you have compiled your program into an EXE, this will not be possible unless you have selected the option ‘Produce Debug Code’.

As you can see in the example, the text ‘Infinite Loop!’ is printed over and over again, until you force the program to stop with Ctrl+Break. The loop theory is the same as For, but I’ll still explain it here. When the program reaches Do, it means the beginning of a new loop. It then executes code until it reaches Loop. The program will then jump back to Do and runs the cycle again. This will never stop (infinite loop) unless your program says so (see Exit further in the chapter).

Then there was the second possibility a Do loop could be, viz. the loop that waits for a condition. Here’s an example:

>     DIM I AS INTEGER
>     I = 0
>     DO
>     	I = I + 1
>     	PRINT I
>     LOOP UNTIL (I = 100)
>     PRINT “First loop ended”

>     I = 0
>     DO WHILE I < 100
>     	I = I + 1
>     PRINT I

>     LOOP
>     PRINT “Loops ended”

As you can see, the keywords UNTIL and WHILE can be used to accept a condition. Until causes the loop to loop until the expression is true. While causes the loop to loop while the expression is true, and it will stop when the expressions turns false. Of course, you can combine multiple conditions using any or more of the boolean operators. But you already knew that didn’t you? :)

There is however a difference between putting the Until or While at the Do or at the Loop. Here’s an example that illustrates this difference:

>     I% = 1
>     DO
>     	PRINT “We are in loop one”
>     LOOP UNTIL I% = 1

>     DO UNTIL I% = 1
>     	PRINT “We are in loop two”
>     LOOP

As you can see, your program only prints we are in loop one on the screen. This is because when placing the condition at the LOOP, the loop will be run at least one time, because checking for the condition takes place after each loop. If you place the condition at the DO, the condition will be checked before each loop takes place. So if the condition is until true anyway, the loop won’t be run and the program will skip it right away, continuing at the LOOP.

To get used to Do Loop, try experimenting with it! :)

DO [WHILE|UNTIL condition] | Marks the beginning of a Do loop. When a condition is placed at the Do, this condition will be checked before running each loop. Therefore it is possible the loop will never be run.
LOOP [WHILE|UNTIL condition] | Marks the end of a Do loop. From here the programs jumps back to the corresponding Do. That is, if the condition attached to Loop, if any, is true. If a condition is placed at Loop, this condition is checked after running each loop.

You cannot use two conditions in a Do Loop. I.e. you can only place one Until or one While in the loop, either at Do or at Loop. Both having a condition is not possible.

### LOOP DA LOOP WITH WHILE AND WEND

This is the last of the loops, not often used since it is actually from an older version of BASIC. However, I’ll still explain it to you, because some people still use them. I advice you to use Do Loop instead though. Here’s an example on how to use While loops:

>     I% = 0
>     WHILE I% < 100
>     	I% = I% + 1
>     	PRINT I%
>     WEND

I don’t have to explain it actually, as it is the same as a Do While Loop (i.e. DO WHILE condition ... more stuff ... LOOP). I think the only advantage of a While loop above a Do While Loop is that it is slightly less typing... :)

Well, that were all loops for now... :)

WHILE condition | Marks the beginning of a while loop. The condition attached to While will be checked before each loop takes place. Therefore, it is possible the loop will never be run.
WEND | Marks the end of a while loop. From here, the program jumps back to the corresponding While.

### EXIT THE LOOP DA LOOP

As already implied previously, there is also a command to manually stop loops, even if they are infinite or waiting for a condition to be true. This command is EXIT and is often used. After exit you can specify what kind of loop to stop (DO or FOR) and your program will then exit the first found loop of that type. Note that it only stops One loop, and not all loops of that type. Here’s an example of Exit:

>     I% = 0
>     DO
>     	I% = I% + 1
>     	IF I% = 500 THEN EXIT DO
>     LOOP
>     PRINT “Stopped the DO loop at I% =”; I%

>     FOR I% = 1 TO 500
>     	IF I% = 250 THEN EXIT FOR
>     NEXT I%
>     PRINT “Stopped the FOR loop at I% =”; I%

You should know that if in this example EXIT hadn’t been executed, the first loop would have looped forever, until you would get an overflow of the integer (at 32767, viz. the maximum value of an integer). The second loop (if the program ever got there :) ) would have run till I% was 501. Try it...!

>     EXIT DO
>     EXIT FOR

Immediately stops a loop. It stops the first found loop of the type you specified, if any.

### CHAPTER PROGRAM

This chapter program is about prime numbers. Prime numbers are numbers that have no dividers. E.g. 13 is a prime number, as it can’t be divided by any number except 1 and itself. Here it comes:

>     DO
>     CLS
>     PRINT “Prime number calculator”
>     PRINT “How many prime numbers should I calculate?”
>     DO
>     INPUT “”, N%
>     LOOP WHILE N% < 1

>     PRINT
>     PRINT “ 2”
>     PrimesFound% = 1
>     Check% = 3
>     DO UNTIL PrimesFound% = N%
>     	Dividable% = 0
>     	FOR prim% = 2 TO INT(SQR(Check%) + 1)
>     		IF INT(Check% / prim%) = Check% / prim% THEN
>     				Dividable% = -1
>     			END IF
>     	NEXT prim%
>     		IF Dividable% = 0 THEN
>     			PRINT Check%
>     		PrimesFound% = PrimesFound% + 1
>     	END IF
>     		Check% = Check% + 2 ‘only odd numbers
>     LOOP

>     PRINT “This were”; N%; “prime numbers”
>     PRINT “Do you want to calculate some more?”
>     DO
>     INPUT “(yes or no): “, YESNO$
>     YESNO$ = UCASE$(LTRIM$(RTRIM$(YESNO$)))
>     LOOP UNTIL (YESNO$ = “YES”) OR (YESNO$ = “NO”)
>     IF YESNO$ = “NO” THEN EXIT DO
>     LOOP
>     END

### EXERCISES

Now again for some cool exercises... :)

- Exercise #1: Make a program that can calculate the factorial of a positive number the user inputs. The factorial of a number is itself multiplied with all of its predecessors. E.g. the factorial of 6 = 1 * 2 * 3 * 4 * 5 * 6 = 720.
- Exercise #2: (easy). Make a program that can calculate the sum of all numbers preceding the number, from 0. So with an input of e.g. 7 the output will be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.
- Exercise #3: (easy). Make a program that asks the user for a number. Then display a triangle on the screen which is number characters wide at the base. Each line 2 characters on the sides disappear.
- Exercise #4: (harder). Make a program that is able to calculate all combinations of numbers within a specific range and length defined by the user. So if the user tells your program to show all combinations with length 4 and range 2, the program should output 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, and that this are 16 combinations. Have the maximum range be 10 and the maximum length be 8.

## APPENDIX: EXERCISE ANSWERS

### CHAPTER V, EXERCISE #1

Exercise #1: Make a program that can calculate the factorial of a positive number the user inputs. The factorial of a number is itself multiplied with all of its predecessors. E.g. the factorial of 6 = 1 * 2 * 3 * 4 * 5 * 6 = 720.

>     DO
>     INPUT “Enter a number (0 <= n <= 170): “, n%
>     LOOP UNTIL n% >= 0 AND n% <= 170
>     PRINT n%; “! =”;
>     FAC# = 1
>     FOR I% = 1 TO n%
>     	FAC# = FAC# * CDBL(I%)
>     NEXT I%
>     PRINT FAC#

### CHAPTER V, EXERCISE #2

Exercise #2: (easy). Make a program that can calculate the sum of all numbers preceding the number, from 0. So with an input of e.g. 7 the output will be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.

>     DO
>     	INPUT “Enter a number (0 <= n <= 1 bln): “, n&
>     LOOP UNTIL n& >= 0 AND n& <= 1000000000&

>     Sum# = 0
>     FOR i& = 1 TO n&
>     	Sum# = Sum# + CDBL(i&)
>     NEXT i&
>     PRINT “Total sum is”; Sum#
>     ‘note that this is equal to Sum# = 0.5 * n& * (n& + 1)

### CHAPTER V, EXERCISE #3

Exercise #3: (easy). Make a program that asks the user for a number. Then display a triangle on the screen which is number characters wide at the base. Each line 2 characters on the sides disappear.

>     DO
>     	INPUT “Enter base width (0 < n < 40): “, n%
>     LOOP UNTIL n% > 0 AND n% < 40
>     CLS
>     Length% = n%
>     FOR I% = 1 TO INT(n% / 2 + 1)
>     	LOCATE I%, I%
>     	PRINT STRING$(Length%, “#”)
>     	Length% = Length% - 2
>     	IF Length% < 0 THEN Length% = 0
>     NEXT I%
>     SLEEP
>     END

### CHAPTER V, EXERCISE #4

Exercise #4: (harder). Make a program that is able to calculate all combinations of numbers within a specific range and length defined by the user. So if the user tells your program to show all combinations with length 4 and range 2, the program should output 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, and that this are 16 combinations. Have the maximum range be 10 and the maximum length be 8.

>     DO
>     	INPUT “Lenght: “, Length%
>     LOOP UNTIL Length% > 0 AND Length% <= 8
>     DO
>     	INPUT “Range: “, Range%
>     LOOP UNTIL Range% > 0 AND Range% <= 10
>     CLS
>     Combi& = 1
>     AtEnd% = 0
>     Combin$ = STRING$(Length%, “0”)

>     DO
>     IF AtEnd% = 0 THEN
>     PRINT Combin$
>     ELSE
>     	PRINT “These were”; Combi&; “combinations”
>     	EXIT DO
>     END IF

>     TryPos% = Length%
>     DO
>     Value% = VAL(MID$(Combin$, TryPos%, 1)) + 1
>     IF Value% < Range% THEN
>     			MID$(Combin$, TryPos%, 1) = LTRIM$(STR$(Value%))
>     		Combi& = Combi& + 1
>     		EXIT DO
>     ELSE
>     		MID$(Combin$, TryPos%, 1) = “0”
>     	TryPos% = TryPos% - 1
>     	IF TryPos% = 0 THEN
>     		AtEnd% = -1
>     		EXIT DO
>     	END IF
>     END IF
>     LOOP
>     LOOP

Next Month: Neo Deus Ex Machina returns with QBNow! Part II!

You can email Neo at arecinos@gmx.net.

## Final Word

I'm gonna be honest: putting together an issue of this magazine is a bitch. This took me all day to do -- nearly twice as long as I expected. It was a hell of a lot of work. And I didn't even have time to finish several of the articles I had planned. And now I'm dead tired. But when I see the great response and wonderful reception that each and every issue of this magazine gets, it motivates me to keep on doing it. Keeping the QB community alive and thriving is worth the time and effort.

Issue #5 should be out by the end of December. I'm aiming for a day or two after Christmas, but you know how things go. And what's gonna be in it, you ask? Well, Neo's QBNow! series will continue, starting with volume 2, and Matt2Jones' Bobby The QBasic Maniac will be back as always. VonGodric will continue the GUI series he started last month with Part 2, and we might just see continuations of both abionnnn's and Stephane's tutorial series. I'll also be returning with the next edition of Blast From The Past! -- don't you worry. Then there are a whole bunch of other articles and tutorials I'm expecting...but based on the spotty submission record I've had with the last few issues, you're just gonna have to wait and see what actually turns up. You never know what's around the corner in QB Express. Consider it a surprise!

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.