# QB Express

### Issue #29 ~ September 20, 2008

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

### In This Issue

Staff

- Pete Berg (Editor)
- Imortis Inglorian
- MystikShadows

Contributors

- Lachie Dazdarian
- Kiyotewolf
- Wallyfblu
- Brandon Cornell
- HexDude
- Moneo
- Samanddeanus
- Ebben Feagen
- Publius
- stylin

- Regular Columns
  - From The Editor's Desk
  - Letters
  - News Briefs
  - Gallery - Prompt Critical
  - Awards
  - Final Word
- Articles & Editorials
  - Mini Game of the Month - Lachie Dazdarian
  - The Kiyote On A Variety Of Subjects - Kiyotewolf
  - Before Releasing Your Game - Nalin Kanwar
  - Barren - An Interview with Lachie Dazdarian - HexDude
  - Ten Years of Pete's QB Site - Pete
  - Y2K: The Year 2000 Problem - Moneo
  - What's new with QBinux - Seb McClouth
  - Some notes on FreeBasic and QB64 - Publius (Mitchell Johnson)
- Tutorials
  - Using 7x7x16 Tricks - Kiyotewolf
  - Window Procedure - Part 2 - Wallyfblu
  - Common Gateway Interface in QB - Part 2 - Samanddeanus
  - Shuffling Algorithms - Samanddeanus
  - The PImpl Idiom - stylin

## From The Editor's Desk

### Written by Pete

Hello from the Rooftop of the World!

I'm in the middle of a 45-hour train through the snowy mountains of Tibet, two-and-a-half-months into my six month trip around the world, and I figured it was *finally* time to put together the latest issue of QB Express.

I have to admit, I haven't thought too much about QBasic of FreeBasic over the past few months. I've been having a great adventure, traveling through mainland Japan, Okinawa, Taiwan, Hong Kong, China, the Olympics in Beijing, and now Tibet. (Next, I'm headed to Nepal and India -- and then who knows after that!) Lack of Internet access and the sheer amount of things to do and see have made me neglect my QB Express duties, but I figured a two-day train ride with nothing to do but read books and listen to my iPod (until it conked out due to the high altitude), would be the perfect time to catch up on QB Express.

Also, I think it's due time to release a new issue, because in just under a month, Pete's QB Site will be celebrating its Ten Year Anniversary! I founded this site on October 12th, 1998, when I was 13 years old, and I never dreamed that I would still be running it (or that it would be so successful) ten years later. For a look back at ten years of Pete's QB Site, check out this article. Boy, time flies!

But that's not all that's not all that's in this issue. There are a DOZEN other articles and tutorials for you to enjoy, written by people from all over the QB and FB scene, along with the regular news briefs, gallery, awards and letters you've come to expect from QB Express.

It's been nearly four months since QB Express #28 was released, so I apologize if some of the articles in this issue are a bit dated. It's all still completely worth the read, but I do have an announcement to make...

It has become abundantly clear to me over the past few several issues that I no longer have the time to put together a QB Express issue every month. QB Express will now come out every few months, when we have (1) received enough content to put together an issue, and (2) when we have time to put it all together. Despite my best intentions, I am no longer going to make empty promises that QB Express will be out on a monthly basis.

I hope this doesn't disappoint any of you, our loyal readers, but I'm sure many of you saw it coming. I started this magazine when I was a sophomore in college, with plenty of free time and tons of motivation, but my free time has since wained, and I've got a lot more on my plate than I used to.

I'm also going to experiment with shifting more of the responsibility for releasing the magazine to the other editors, Imortis Inglorian, MystikShadows and some other volunteers. We're also constantly looking for more editors and helpers for the magazine, so if you'd like to contribute, email us at qbexpress@gmail.com.

QB Express is going to continue chugging along, just like this 3,000 mile train ride across mainland China and Tibet, just a little bit slower than before.

-Pete

### 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, check out the "Official QB Express Article Requests" thread! There have been quite a few articles requested -- and even if none of them strikes your fancy, we can help you come up with something that you would like to write about. 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 qbexpress@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 MystikShadows

Hello everyone, what can I say, another issue, another one for the QB Express hall of fame (27 issues belong there so far, 28 with this one hehe). There's a lot of good contents and well we'll tackle those later in this letter.

First thing I'd like to talk about is the sad news that Mac has passed away (the admin at the Qbasic Forum). I'd like to invite anyone that knew him (a little or a lot) to pay a visit to the tribute page that was created in his honor and say a little something on his behalf, maybe a memory, a little story or anecdote you know something nice and respectful. Mac has left his trace, in many helpful post on his forum but also in your forum, the QbasicNews forum and a few other places where he helped newbies the best way he could whenever he could and I think he contributed a lot of his time and knowledge throughout all his posts. If you don't know what to say, there's already a few tributes posted there to give you a few ideas.

I don't know if I'm the only one that noticed this but I think things are still moving in the QB/FB world from what I'm seeing. Not sure if you noticed but there has been a lot of things going on around the the BASIC related web. People are work hard to get FB to it's next version (something about a C emitter that will make it easier to port FB to other platform for one thing, when that's done, it should be interesting to see how it all works). It's equally important to mention that QB64 is evolving as well in it's own path. Not sure if you've kept up to date but recently support for TTF fonts has been announced, there's still work to do, but adding that should open a whole new work of possibilities, I can't wait to see where that goes as well. Bottom line things are moving forward everywhere to make sure that old and new basic programmers having something useful to program with no matter what we want to program and no matter which way we want to program it and I think that's important too.

Now about QB Express #28 itself. I'd like to point out Lachie's “eternal Struggle” article first. I have to say that it's amazing how precise the points he makes are in his article. I know cause well programming is my career. Do I tend to do things he mentions in his article? I think so yes. Building application just isn't quite the same as building a game. In programming you are exposed to standards, to keyboard shortcuts, to design standards so that a Windows application needs to look and feel like a windows application. And after a few dozen times of developing windows applications when you start at a game and suddenly you're pretty much free to do whatever you want in your game look wise and design wise, well suddenly, you fall into an unknown freedom A freedom that is great but a new freedom where making mistakes can definitely occur. If you remember my Color Triple Yahtzee game, sure the dice don't look that bad, but I'm sure I'm not the only one that thinks the scoreboard I did for it can easy be used as a grid like control to be used in many business applications he he. Ultimately nothing wrong with that per se since it's a scoreboard, but it's a trap that's easy to fall into, but well I still got a lot to learn about game development. Bottom line Lachie really made some important points in this article points that most application developers should take into consideration before tackling their first game project.

Well I think pritchard stole the spotlight on that issue didn't he? The articles he submitted here are good, informative and well written. There's just a lot of pritchard in this issue which puts a smirk on my face since he seemingly wanted QBE dead not too long ago. Nonetheless his articles were good and worth reading in my opinion. His “Steal This Game: To Clone A Game” article is short but still pretty useful to new game developers. Brings reality back to fantasy games if I may use the expression. I'm sure new game programmers thought what he described, characters are so free it must be hard to recreate something like that. And yet, they're not that free in reality. Helps make the whole gaming concept conceivable. His other articles are also worth reading as I said before. So keep on writing pritchard.

Nothecheatr's article on “Scripting Solutions For Games” proved to be very clear and to the point. I think a lot of users will benefit from that way of defining and implementing a scripting solution. I happened to have appreciated na_th_an's IF series version of a scripting engine because that's what I learned from. Knowing what I know from that series and reading this version from nothecheatr makes me things that the combination of both approaches just might be as complete a scripting solution as just about anyone would ever need. Great work there, I'm liking a lot of submissions from him lately here and on the FB forums. Great job there and I'm looking forward to what the rest of his series have to offer.

Immortis' “bitflag and you” was pretty interesting. I would have loved to learn all this the way Immortis explains it here. Back when I learned all this, I got the very theoretical point of view, how bit shifiting works among other things, but the one thing missing from my courses and most books I've read is the one thing Immortis put in his tutorial. And that thing is a use for the stuff. And I think that when readers can take the subject matter and associate to a use like is being done in his tutorial, I think it just makes the whole subject matter stick that much more. It was an interesting and informative read to say the least. I wonder what's next from Immortis' knowledge vault.

Kiyote Wolf, two submissions this issue, two very interesting ones. I like what a submission like his “Kiyote Wolf on a variety of subjects” brings a magazine like this, I think all the subjects he touched in his submission were first of all worthy of mention. One I liked a bit more is his technique for scrolling using BSAVE and BLOAD nifty little trick. His “Amazing Cheap Texture Mapping” tutorial was pretty interesting. It might be slow as he emphasized at the beginning, but it's a technique and it teaches something that can be used without any special external libraries, which is always good in my book when possible so he gets my two thumbs up for that one.

I'd like to finish this letter with a special note on Mac's article. Not so much because if it's contents, though he did take the time to explain how his forums worked, where things belonged and how things work in there. That was well explained, clear, as concise as it could be, worthy of most of Mac's contributions. But I'd like to also talk about the why of this contribution. I didn't know it back then because I wasn't aware of any situation or illness but now that Mac is gone, I understand the full meaning and depth of his contribution. I think we all know Mac to some different extent. And I think none of ys can deny his importance in the QB Community, how he helped newbies learn, his dedication to his goals in his forums and all over the internet. Maybe he wasn't a fan of FreeBASIC, but I don't think that lessens his contributions to the Qmunity by a single ounce. I think many people could learn from his dedication to make a newbie's starting experience to on line communities a great one. And from the time he took to make sure questions were answered.

I'd like take a quick note to invite anyone that knew Mac to contribute to the tribute page I mentioned above. His family is reading it and so far have enjoyed just about every contributions. So if you know him, if you have a tid bit to share that you experienced with him, feel free to go ahead and post a contribution and make your own tribute to Mac.

So yes indeed, another great issue, I had fun and interest reading everything that made issue #28 what it is and I am looking forward to read more in the issues to come. Great work to everyone, seems I never seem to stop being surprised at the subjects covered in each issue and the quality at which everything is covered.

MystikShadows
Stephane Richard

> Thank you so much for the letter!

> I'd like to thank you for the kind words you said about Mac. He was truly a pinnacle of the QBasic community, and he did more to encourage new programmers and keep the Qmunity alive than most of us combined. He will surely be missed.

> When Mac submitted his article to QB Express #28, none of us ever expected it to be his last. He was always such a steadfast and prolific contributor to the Qmunity -- to QB Express for sure, but even moreso to the QBasic Forum -- that we all thought he'd be around forever.

> I think it's really fitting that Mac wrote one last article for QB Express before he passed on. Even in his last months of life, when was quite weak and sick, he still found time to help others in the Qmunity. That really says a lot. He will be greatly missed.

> As for the rest of your letter, thanks as always for all the fantastic feedback! I'm sure all the authors appreciate the positive comments. :)

> -Pete

### Letter From Kiyotewolf

Dear Readers,

I know we all look forward to having our daily helping of QBExpress every month, but let's face it, we all cannot find the best deal on hosting all those files, have the sense to make all that random data people email in turn into something with grammer and notation, and be able to package everything into a single ZIP file that people can download forever until the end of the internet.

I do agree completely with Pete, that once you pass the reins of something over to new owners, they will make it either their agenda, or their least important thing period. I think we should all take a step back and appreciate the time and effort Pete goes through, and his staff, to make these issues come out, Period. If these people did not take the time to gather all this together and do the enormous job of reformatting it to make it readable and portable, we all would be just a bunch of voices in the wind, and nobody would be able to pass all this useful technique and trickery over to the next generation of programmers.

I did want to say, that people complaining about posting code in either the forum or the magazine itself, should take a deeper look at what it takes to make a program. You never know everything about a computer, no matter how much you think you know, and a helping hand either from a new memory address, or an unknown opcode in a CPU which can save cycles, anything that helps one programmer//hacker out from another programmer//hacker, is a step forward, and bickering about where something came from is irrelevant. What you should do, in cases like that, is document where the original source came from, as if you were writing a term paper, because if someone picked apart your code in reverse using either a disassembler or browsing your source code, you will probably offend someone if you ""borrow their code without noting them as the originator.

Let's all play nice, and I don't care how many people out there have disowned Qbasic, I still love it, and will program in it till the day I die. I do not like Freebasic as much as I thought I would have because it reminds me of Turbo Pascal for Windows, (forgot what it's really called..), and it loses something in translation for me. I have since been able to get a fully assimilated XP windows laptop to bow down and revert back into original DOS for me, without having to change a thing, (USB floppy and a DOS boot disk for the curious people), and have also been taking random dead computers and giving them new life with my trusty DOS install disks which I still have. DOS is limited to 2G only, but to a QBasic'er, it's a huge amount of space, since my last real DOS computer only had 80MB of hard drive space. If anybody wants help with doing something like that, either forum me or something,..

Long story short, Qbasic is glued to me, and will never be able to be ripped out of me, unless some alien brain surgury or something,.. And don't forget to thank Pete once in awhile some of you, and his staff, for all this work they do.

Kiyote!

> Thank you so much for the kind words. It's true that we put in a lot of work collecting all the various "voices in the wind" and turning them into a coherent magazine. But on the other hand, we'd have nothing to collect if there weren't those "voices" out there in the first place. (Voices like your own!)

> On the subject of "passing on the reigns," I really, truly, hope that I can take a step back and QB Express can continue alive on its own. It has been on life support the last few years because I haven't been keeping up with it, and I'm hoping that it can regain its former glory soon. And if not, it will continue, chugging along, just a bit more slower than it did a few years ago.

> -Pete

### Letter From Seb. McClouth

Hey Pete

Good to see you still working on QBE! I heard you gonna gonna go on a trip around the world, cool, and if you're near some members, do stop by!

Well, I haven't travelled around the world but, as a native Dutchmen, having seen most of Europe, e.g. the UK, France, Spain, Italy, Danmark, Germany, Austria, etc, and my farest trip, Atlanta, GE included, can say that travelling is fun.

Hope you have a good time!

Grtz

Seb. McClouth

> Thanks for the kind words! After two and a half months of traveling, I have to say that I am having the time of my life, and am learning so much about myself and the world.

> <soapbox>

> Each and every one of you out there owe it to yourself to travel -- to explore different parts of the world and experience new cultures. It will really change the way you think (for the better), and open your eyes. Plus, it will be an experience that you never forget!

> Don't make excuses -- money, jobs, obligations at home, personal phobias -- none of it is nearly as binding as you think. (Trust me, I delayed this trip for years for exactly those reasons.) But if I had never decided to travel, I would be regretting it for the rest of my life.

> Travel! See the world! (And if you can, do it while you're young!)

> </soapbox>

> (Sorry for that blatant soapboxing there, but I really do think traveling is something that every person owes it to themselves to do. And now I rest my case!)

> -Pete

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

## News Briefs

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

### Site News

Pete's QBasic Site celebrates ten years!

  On October 12th, 2008, Pete's QB Site will celebrate its tenth anniversary!

  As one of the longest-running QBasic sites on the Internet, Pete's QB Site holds an important place in QB history, for being the first QBasic game reviews website; its founding policy of daily updates; maintaining the largest collection of QBasic tutorials anywhere on the Internet; and for founding the longest-running QBasic/Freebasic magazine, QB Express.

  But enough about that here -- I've written an article further down in this issue with a brief history of Pete's QBasic Site over the past ten years.

  On a personal note I hope you've all enjoyed my little website for the last ten years, and hopefully there are many more decades to come!

  News Brief by Pete

The QB community mourns the loss of QBasic Mac

  Hilliard Moffett "Mac" McLamore, longtime member of the QBasic community and moderator of The QBasic Forum, passed away on June 14th, at the age of 72. He was well-known for helping new programmers with their QBasic problems, and being a fair and dedicated moderator at the popular Network54 QBasic forums. Mac was also a regular contributor to QB Express, and even submitted a final article to the last issue, just weeks before he died.

  Here is Mac's obituary, which was provided to us by his daughter:

  > Hilliard Moffett McLamore, 72, died on June 14, 2008 at 6:30 p.m., at his home in Vienna, Virginia. Only five months ago, he was diagnosed with cancer (metastatic carcinoma of unknown primary). He was born on April 2, 1936 in Lubbock, Texas. He spent the majority of his school years in Texas, but also attended Kramer Junior High School in Anacostia for the spring and fall semesters of 1949.

  > “Mac” McLamore served in the Army from 1953 to 1956, and he was stationed for two years in Germany. He specialized in radar operation, radio operation (Morse code) and cryptography. After his honorable discharge, he attended the University of Texas, and earned membership in Phi Beta Kappa. He studied mathematics and electrical engineering, and graduated summa cum laude in 1959. He was also a Master Mason of the Grand Lodge of Texas.

  > As one of the first computer programmers, Mac started working for IBM in 1959 in Kingston, NY and he was quickly promoted and transferred to the Washington D.C. area, where he met his future wife, Gudrun Larsen of Denmark. In 1967, Mac moved overseas to work for Investors Overseas Services (IOS), and later, World Health Organization (WHO) in Geneva, Switzerland. In 1974, he moved back to the Washington DC area for good, and worked as a database administrator for Boeing Computer Services (BCS). Throughout his career, Mac kept time with the rapid-fire changes in computing, and upon retirement, he devoted himself to a Q Basic Forum. No matter how much he knew, he was always willing and able to learn more.

  > His humility and good humor will never be forgotten. He is survived by his wife, Gudrun McLamore; his son, Lars Hilliard McLamore, of Burke, Virginia; his daughter, Christina McLamore, of Miami, Florida; two grandchildren; and two half-sisters.

  Pete of the QBasic Forum (not Pete Berg), has taken over Mac's role as moderator, and he also set up this tribute post for Mac. Members of the community expressed their sympathy for Mac's family and called him "a legend" and "a friend."

  Mac was a true leader in the QB community, and he will be missed.

  News Brief by Pete

Twelve new games added to the FreeBasic Games Directory

  Since the Freebasic Games Directory opened its doors last year, it has been the best barometer of how active the Freebasic gaming community is. Well, the past few months have been quite fruitful, with TWELVE new additions to the directory. Here's the list, with ratings:

  > - Explode - 12/20
  > - Dungeon of Doom - 12/20
  > - Rotation - 9/20
  > - Penguin - 10/20
  > - FB Tic Tac Toe - 8/20
  > - Barren - 16/20
  > - Boondog - 14/20
  > - Fluid Wars - 12/20
  > - O.H.R.RPG.C.E - 16/20
  > - Emeritius Pong - 12/20
  > - Simon - 10/20
  > - A Fascinating Discovery - 09/20

  There's quite a variety, from puzzle games to action games to point-and-click adventure games to RPG makers there. And Lachie Dazdarian only adds finished projects to the FBGD, so these are all 100% done projects. So...get gaming!

  News Brief by Pete

QB45.com brought back to life once again

  QB45.com is like a cat with nine lives: no matter how many times it dies, it just keeps on coming back!

  The website, famous for having the largest QBasic files archive in the Qmunity, has been restored from some old database archives, and is now running on a simple content management system, with all of the programs intact. The only other notable feature is a discussion board where a few old QB45.com regulars are now posting. The site was restarted by Todd Seuss (of Data Components) and Marcade, who bought up the QB45.com domain name when it expired.

  This marks the latest in a long line of QB45.com websites. Like a Buddhist monk caught in an endless cycle of life, death and rebirth, QB45.com just keeps getting reincarnated.

  Here's the history as I remember it (though just as the mists of times have made our memories reincarnated monks foggy, my memories might be a bit foggy as well): Back in 1996, the site began as Future Software (founded by Jorden Chamid), which grew to a much larger and more popular site called QB45.com, where it flourished for a few years. Eventually, around 2000, the founders abandoned the site and it was subsequently taken over and converted to a CMS called PostNuke by Mike Doise...which caused QB45 to crash and shut down. A while later, it was then replaced by a simple message board, until in 2004, the site was rebuilt from scratch by Jofers and took on its "Bigfoot" design. Meanwhile, Mike Doise created a competing site at QB71.com, using the same exact QB files database, though it was never the "official" website. Three years after the Bigfoot redesign, the QB45.com domain name expired, and Bigfoot QB45 shut down. Marcade snapped up the domain and installed another simple message board, which stood in place until last month, when QB45.com was restored using back-ups made from the end of the Future Software era. Whew!

  Anyway, disregard my spotty, senseless history lesson...just check out the site: QB45.com!

  News Brief by Pete

Is FreeBasic stagnating / dying?

  Ciplogic recently started a thread on Freebasic.net asking the question: "is Freebasic stagnating / dying?" It started a lively little debate among members of the community and the dev team that might be worth a read. I found it to be very interesting myself.

  News Brief by Pete

The GUIs Rise Again

  Brandon Cornell sent in the following news item about his new QB GUI site:

  > Anyone who is interested in GUIs, knows the name "Jacob Palm", the admin of the most popular GUI site for some time. He closed his site over a year ago and everything fell apart. Three or four of us stayed in contact at Todds site, The QB GUI Blog, but it had a very poor forum, an old Blog, hacked up to have a minichat. A few months ago I became co-admin and tried to help it but I didn't get very far until, I started a GUI contest. It was to be a two week contst to decide on a new admin. Lucky Todd agreed, very nicely, and it was off. But once the contest was other there was only two GUIs and it made for a poor contest. Me and the other coder decided and election would be best, and I won easily. My first act was to get a new CMS. I searched and Joomla! seemed like a good idea, and with FireBoard IIt could have a busling forum, that makes any good QB site. Shorty after the site was put up another GUI was released, and the active member count is at 5 or 6!!

  > Check it out at: http://qbguiblog.xetaspace.net

  News Brief by Brandon Cornell

### Project News

Lachie Dazdarian finally releases Barren

  Anyone that's been reading QB Express for the past four years should be familiar with Barren, formerly known as Legend of No-name General / LONG. It is Lachie Dazdarian's point-and-click adventure game that he started in 2002 in QBasic, and has been working on on-and-off for the past six years.

  Well, Barren was FINALLY released at the end of May. Here's some info from Lachie:

  > Barren is classic point and click adventure game played through the eyes of the player (scene by scene movement). It's placed in a SF-phantasmagoria type of setting where you play a person of unknown origin stranded in a strange dreamlike place. It’s a relatively short adventure game, but features a fair of amount of cut scenes and cool atmosphere.

  > The project was started long time ago during 2002 (as a QB program) without a clear goal, which resulted in several aspect of the game being quite clumsy. The source code passed through several overhauls, and the final version of the scripting system was a nightmare to manage. Probably a wiser game dev would kill this project long time ago. But not me. I'm a nurturing mother-like game designer. :)

  > I love my children. While others would abort it, I bore this monster in my womb, gave birth to it, and taught it to crawl, then walk, and then speak. Others would walk away from it, I didn’t. So you will forgive certain improper features my child has. ;)

  The was a massive undertaking, and Barren had significant contributions from other Qmunity heavywheights like Josiah Tobin, Zamaster and Na_th_an. To download it, visit the game's official website. Lachie truly deserves a round of applause for finishing this project!

  News Brief by Pete

Zogies Labyrinth aMAZEs children and QB coders alike

  KDAG, creator of Astral Worlds, has released a new QBasic game called Zogies Labyrinth, which was specially designed for the author's children. Players must work together guide a "Zogie" through a maze to collect a diamond, and then escape. The game originally was made for two players working together simultaneously, but KDAG has recently released a single-player version as well.

  Here are a few screenshots (thanks, Lachie!):

  The game is available for download at the QBasic Station. Don't get lost in the maze!

  News Brief by Pete

Freebasic v0.20.0b Released

  Coderjeff and the FreeBasic team released v0.20.0b of the compiler in August, which includes many new features and increased stability. The most notable addition are AndAlso/OrElse short-circuiting operators, but there were also many new features added for graphics functions such as BLOAD.

  Get the latest version at: FreeBasic.net.

  News Brief by Pete

CAD in FreeBasic?

  Yes! A chap named Owen Reese is designing a CAD program in FB to help bring all your architectural ambissions to fruition...(plus this free app is a whole lot cheaper than the pro CAD programs out there).

  There is a very active post on Freebasic.net which you can check out for all the details, but I'll leave you with the programmer's goals for the project:

  > A cad program developed by freebasic programmers written in Freebasic for the pupose of :
  > 1. Learning how to code in Freebasic
  > 2. Creating a free basic cad program for all to use (freely)
  > 3. Learning and understanding math
  > 4. Inspiring Creativity.

  I never thought I'd see the day when an FB programmer would try to tackle a CAD program, but this really shows the versatility of FB as well as the ambition of the FB community.

  News Brief by Pete

KristopherWindsor demos UltraBreaker

KristopherWindsor has posted a demo and many screenshots of UltraBreaker is a Breakout clone with some crazy graphical effects and a ton of new twists:

> Most awesome game features:
> - support for 1000+ bricks, 100+ balls, and 20+ paddles
> - level editor and skinable graphics
> - gravity orbs
> - paddles on all four sides of the screen (optional)
> - Bricks can be freely positioned and scaled; they don't need to be on a grid

This sounds like a really exciting game, and you should definitely give it a look!

News Brief by Pete

Lots of FB Minigames! Here's a look at some of them...

  There have been a ton of FB minigames released over the past few months. Here's a look at some of the highlights:

  #### FISHi by H3trunn3r

  "FISHi is a classical digital pet. Watch him grow, feed him, clean him, and more."

  #### Boondog by mambazo

  "A little like prince of persia, a little like sokoban, a little like a lot of things really. Boondog is a versitile, customizable, expandable puzzle game (and engine, I suppose!) with a built in Levelpack editor, overridable sprites and scripted levels."

  #### Galacting Empire by AlZe

  "The goal of this game is to defeat your opponents by taking over all their planets."

  #### Explode! by nkk_kan

  All kinds of things EXPLODE!

  #### ZapZapZap by mambazo

  A space shooter that mambazo made as a personal 24-hour challenge with himself.

  #### Fluid Wars by duke4e

  "There are two players - white one and red one. Players aim and shoot at each other automatically, but they also modify the surrounding fluids making it hard to directly hit the other player."

  #### Shoot by Xerol

  "Instructions: Shoot."

  News Brief by Pete

Vincent DeCampo ports '80s classics to FreeBasic

  Vincent Decampo has spent the last few months porting some of his favorite quarter-sucking '80s arcade games to Freebasic, including Berzerk and Missile Command. (There may be others in the works as well!)

  You can find Berzerk 2.0 here, Missile Command is available at this link.

  Added Vincent: "I hope this game brings back the memories of when you played these games in the arcade. If you're too young for that, then I hope you can appreciate and enjoy playing my renditions."

  News Brief by Pete

FreeBasic Extended Library releases v0.2.2

  A news update from Ebben Feagan:

  > Version 0.2.2 of the FreeBASIC Extended Library was released awhile back. This release is the culmination of several months of work to enhance the features and usability of the Library. New features in this version include: Single and Multi-threaded versions, refinement of existing containers, new graphics commands and many bug fixes.

  > Users can download the library at http://code.google.com/p/fb-extended-lib/ and may browse the documentation online at http://hmcsoft.org/ext/docs/.

  > I believe this is the best version of the Library to date and I'd like to thank the rest of the dev team for putting so much time into it. Also many thanks to our contributors, testers and users; without whom we could not do this. Anyone who would like to help, be it contributing code, discussing features or implementation, or whatever can join us in #freebasic-ext on the FreeNode IRC network, or can join the fb-ext-lib group on google groups at: http://groups.google.com/group/fb-ext-lib

  News Brief by Ebben Feagan

QBasic Digger Clone and Simple Ascii Dungeon Clone

  Though most minigame development we're seeing these days is being done in FB, QBasic is still alive and well in the minigame department.

  - K.S. released a fun little game called Digger Clone, where you must search for gold buried underground while avoiding monsters called "nobbins" and "hobbins" (think Dig Dug). The game has a custom level editor, created by Sid6.7, and also comes with an unfinished spin-off called Arctic Mine, which is set in the winter and involves a Christmas Tree.
  - w1nt0p released a text-based dungeon game, similar in style to most old-fashioned Roguelikes called Simple ASCII Dungeon Game. You're an "@" sign trapped in a dungeon -- collect treasure and escape! (It's pretty much exactly what you'd expect, but fun nonetheless.)

  News Brief by Pete

### Competition News

The FBGD Retro 2008 Competition

  The FreeBasic Games Directory is hosting a retro mini-game competition, which has received many entries and spurred quite a bit of interest.

  Organized by Lachie Dazdarian, this competition challenges coders to create a game in Freebasic using only 640x480 resolution and 8x8 pixel blocks for graphics, a maximum of 16 colors -- something on par with the Atari 2600. Here's a mock-up of what entries might look like:

  If you want to enter this competition, you're going to have to hurry! The deadline for entries is September 21st -- today. (The competition began on August 28th.)

  If you'd like a sneak peak at what some of the entries look like, check out the threads at FBGD and Freebasic.net. In the next issue of QB Express, we will feature the results of this fun little competition!

  News Brief by Pete

Got news you'd like us to report? Email it to qbexpress@gmail.com!

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

### Prompt Critical by Syn9

It seems like every few issues, we feature a project by Syn9 in the Gallery here at QB Express. There's a reason for it: Syn9 makes perhaps the best looking games of any FreeBasic programmer, and the Gallery is all about the graphics!

Syn9's latest project is a space shooter mini-game called Prompt Critical, and it has Syn9's trademark vector graphics flashy effects. Although the details about the game are spare, it looks to have standard space shooter gameplay -- stages, power ups, bosses, the works. Syn9 has spent about two weeks developing this project so far, and he hopes to release it "any day now." And don't worry, this doesn't mean that his other blockbuster project Aphex has been canned...this is just a mini-game to get Syn9 back in the groove of programming, after spending four months at sea with the Navy.

The only info about this project is this post at FreeBasic.net, but it includes a link to a VIDEO PREVIEW of the PreBeta version. Take a look:

:

And if you're not so keen on videos, here are some screen captures from the September 15th build:

Keep checking back at Freebasic.net or Syn9's Hideout to get Prompt Critical as soon as it's released!

Visit the Official Site for more information.

## Mini Game of the Month #1

### Written by Lachie Dazdarian (June, 2008)

###
Introduction

With this article I'm trying to start a monthly/bi-monthly editorial featuring mini games of the month (or two months, depending on the release of the previous issue). All games will be rated from 0 to 5 stars and rated as mini games. Also, I will award the best mini game for the past or past two months. Of course, the success of this series depends on how much mini games the community will deliver. If you think I missed your game and you consider it mini, let me know and I will try to correct this in the next issue of "Mini games of the month". Since the last issue, I've selected 3 games I consider mini. Here we go.

###
Penguin

From the developer of upcoming and very promising Moon Project comes this cute and addictive game entitled Penguin, a variation of the classic Frogger game in a way.

Your objective in Penguin is very simple. You control a small penguin (naturally) with a goal to cross the river over small moving icebergs from one side to the other, scoring points for faster times between crosses. To stop you in your mission is a nasty but cute looking bear (:P) who likes to stand on the passing icebergs for some reason.

The game features this very good premise and solid execution. The gameplay perhaps is not fun as it could have been. The choice of movement algorithm (object position = mouse cursor position) is perhaps a too simple solution, and can also allow cheating on lower FPS values. Also, bear to penguin collision is rather poor, which surprises as box bounding collision of two objects couldn't be a simpler programming problem. The last flaw would be the inability to input your name in the high score table (only the score is saved), and the very final score not being highlighted to the player once the game is loss. Nevertheless, the game becomes quite exciting on higher levels (game speeds).

Other pluses are cute graphics, pleasant music, and very spiffy looking main menu.

A side note: AlexZ claims he made Penguin for his girlfriend. Are we to believe this?

RATING:

Download: Penguin.rar (1769 KB)

###
FB Tic Tac Toe

A very basic Tic Tac Toe game by arenth. It's a two players only game and for network play only. It's adequately executed, with nice looking X and O sprites, but the lack of a more coherent design, AI and offline mode are quite notable flaws.

Very good connect/host interface.

RATING:

Download: fb_tto.zip (262 KB)

###
Rotation

A challenging ASCII puzzle game where you need to align numbers in a rectangular playfield in order. This is accomplished by rotating a box of 4 numbers (2x2). The game can be played in 3 playfields (4x4, 5x5, 6x6), and in 3 difficulties (scramble ratio), but I'm not sure how much that feature actually effects the difficulty. Anyway, nice design, but far from topping the possible limits of this type of game, even in text-based mode. There could have been a time limit mode, various scoring and high score tables, and more interesting colors.

RATING:

Download: rotation.zip (58 KB)

###
The Mini Game of the Month

Congratulations to AlexZ for making the first Mini Game of the Month - Penguin

## The Kiyote On A Variety Of Subjects

### Written by Kiyotewolf

### Legacy support and you, what it means to go DOS again.

Like I said in my letter, it is possible to take a fully assimilated computer, yes, a laptop, and get it to boot back into real good old fashioned DOS. If you are fortunate to have DOS disks, or a disk with DOS boot files in the root of the floppy, IO.SYS..MSDOS.SYS,.., you can buy one of those external USB floppy drives, and put the boot disk in, and if your BIOS is configured to search for bootable media in the proper order, it will use legacy compatability to actually boot from the external USB floppy drive. If you are lucky enough to have a laptop with an LPT1: port, you might be able to load up the GUEST.EXE driver for an external ZIP drive through the parallel port, and be able to manage 100MB of data while playing around in DOS booted from a floppy. If not, you could install an EMS/XMS/RAMDISK driver set into memory and expand a ZIP file of your program into memory and run under those conditions. If not, a small quaint demo of your program squished and squeezed down into 1.44MB minus other files, so you can at least show off your creation on any random computer that does not have a floppy drive of it's own.

One thing I did run into, copying my DOS install disks, there was a weak copy protection on the disks. They were named in the Disk label, DISK[SPACE x 6]1, etc.. and trying to format a disk with the DOS shell on it and setting the volume label with spaces in it only caused an error in the DOS format command. What I had to do, was use my USB drive to change the volume name after it was formatted with the /S command, and the WinXP environment let me put spaces back into the volume name without arguing with me. Cheap copy protection, broken! I could have never done that with DOS alone. I tested out my copies of my DOS install disks to see if they would really pass a real REAL test of them on a brand new system. It's very good I did, cause I figured out how to bypass the copy protection in the process.

### Hardware and more hardware -- playing with your tools.

I have a dead oversized computer, that I was able to put DOS back onto, but the cage did not match up for the drives, both the floppy and the hard drive. So, instead, I built a cage using Erector Set pieces. You might think this is childish and stupid, but actually it wasn't a bad way to go. It is rather secure, and much safer than trying to rest the drives on random things in the case without properly being secured down. Another reason for the funny mounting is the front panel for the floppy drive is in an odd kind of spacing. I used the custom cage to make the drive reachable from the front.

Also, wiring in the case, clear duct tape makes great electrical tape. It does not have any of the conductive silver trace in it, (do not use silver duct tape ever), and is very very sturdy and grips good. I have been out to buy real electrical tape and found the glue is horribly weak and falls right off after a few days. It's very sad.

### 7x7x16 colors in EGA

I have came up with radical ways of making the color palettes do over and under techniques for sprites and backgrounds, but a much easier path to try this all out is in EGA. Plus, once you grasp the idea in EGA, understanding the VGA and SuperVGA versions will make more sense.

Take the LSB bits and make them your 4 colors, and take the MSB bits and make them the other 4 colors, (of course one will be shared, the background color), then make the intersections of the colors what they should be when they mix. If you want, set the intersecting colors to be a blended color, or keep the colors as either the same as the MSB or LSB, depending on how you want the over-under technique to react for you.

>     ...........LSB........:
>     .0000  0001  0010  0011
>     .
>     .0100  0101  0110  0111
>     .
>     .1000  1001  1010  1011
>     .
>     .1100  1101  1110  1111
>     :MSB

If you take the color 0000 (Binary), and set it the background color for the whole set, you can then take 0001, 0010, 0011 and set those as 3 colors.

If you take 0100, 1000, 1100 and set them to the other 3 colors, you can plainly see the colors will overlap, but not affect each other.

You now have two sets of colors. To make them work in the over-under fashion, you simply go either horizontal or vertical, taking the MSB or LSB colors and copying them across the adjacent colors, so that when the Lefts intersect with the Ups, if the Ups are going vertical through the matrix, the Ups will stand out over the Lefts even if they share the same space on the pixel screen.

>     0000 = Black
>     0001 = Gray
>     0010 = Dark Blue
>     0011 = Light Blue

>     ...........LSB........:
>     .0000  0001  0010  0011
>     .
>     .0100  0101  0110  0111
>     .
>     .1000  1001  1010  1011
>     .
>     .1100  1101  1110  1111
>     :MSB

Now, to get those other colors right, set 0101 to Gray, 1001 to Gray and 1101 to Gray.

Set 0110 to Dark Blue, 1010 to Dark Blue, and 1110 to Dark Blue.

Set 0111 to Light Blue, 1011 to Light Blue, and 1111 to Light Blue.

Now, draw a background screen using 0000, 0100, 1000, 1100 as something like black, gray, dark red, light red, and then put your sprites all over the screen as LSB colors, once you PUT XOR or PUT OR, the bits will overlay each other, but not collide, and once the palette settings come through, the color displayed on the screen becomes, what the final bit result is mapped to.

I know I tried to explain all this in my last few submissions, but sometimes the simpler examples are the easiest to follow.

Plus, Bonus, EGA has those extra pages for doing off screen double buffered animation, so if you like Super-Gameboy color stylings in your games, you can take this idea and run with it.

Frankly, you don't see alot of 100% full color games make it very far or very long unless they are coded in C++++++++ with gobs of 3D and all kinds of stuff. For those of us coding for the rest of the crowd, sometimes the most catchy games are the ones that have a style about them, not taking full advantage of everything, but using what is there in a way that catches your attention.

### Rules and the Retro

What do all gamers love. RETRO! What is Retro? Well, to put it simply, rules, and strict rule following.

Want to take a game you are designing and make it instantly recognizable as an attempt to go back in time to, (what do we wanna hear?), RETRO?!?, well..

Go back to Apple colors, not GR, but HGR.

We Apple programmers were limited to 7 colors, 8 if you were lucky.

Black, White, Green, Magenta (Purple), Orange, Blue and sometimes Yellow. Yellow was tricky, and I only saw REAL yellow mixed into a Might and Magic (tm) game on the Apple, but needless to say, it became "" officially a color in the HGR mode to me once I saw that.

What is rather nice, is my VGA technique of the 7x7x16 colors will take an apple color scheme rather nicely. You can drop in 7 colors (black being already in the 0 location), and do up another 7 in the MSB direction, and have an instant Apple styled game ready to go. What is even more interesting, is you can double those colors on both the LSB and MSB directions, and this time, invert the bars running across the matrix and you can have background elements with double the interactivity. You can run in front of some background elements while passing behind others. I will code an example of all this and post it next issue for people to look at.

Commodore? Well, Sprites in multi color had 3 colors, 2 which were shared between all 8 sprites, and one indivudual color that could be selected for each sprite. So, you have to colorize your sprites using 2 colors through them all, and also double width the pixels, and that gets you becoming creative.

Nintendo? 4 colors per 8x8 block.

Atari? 8x8 pixels, one color per scan line, double or quadruple width depending on the use of the missle (sprite).

If people take those rules they had when they were coding on older platforms and carry them over into their new projects, we can all have "" RETRO! computer games again, and I'm sure people would most likely question you if that was an actual old system game you were touting, especially once you posted screen shots of your work.

### Visual Basic doing QBasic handywork.

Visual Basic is not the easiest thing to code in. But, with a little bit of backing and some explanations, I think alot of the front end stuff people struggle with could be handled by a VB script easily and much more smoothly.

Visual Basic, by itself, has many flavors, coming in this release and that, but the one I understand and like is the Macro VB language found inside of Excel.

VB under Excel runs on threads, ALONE,.. that means there is no running executable code unless you have a timer thread going to trigger something. Also, being able to store data is an issue in-program, because variables are usually confined to the locality of where they are created. This, of course, is not an issue, because you can use the Cells of the Excel program as non-volatile memory. An even bigger plus, if you store all your data in-house, in Excel Cells, once you [X] out your program, (saving changes of course), the data comes back once you re-open the project.

There is a very particular way to get your VB code to self-run upon opening up your Excel file, which I will document for you next issue, and there are also things in dealing with variables that must be explained.

Cells do not store random bits of data, they store information in what is called, "" Variant type data.

>     im HelloKitty as Variant
>     HelloKitty = CVar("String stuffs")

Whenever you go to put data into a Cell in Excel, it is wisest to put it into a wrapper by converting whatever data type it is, into a variant type such as that.

You HAVE to declare every variable you use, and $ in strings is not allowed, although the $ in the command MID$ is allowed. All your strings and other data types are simply alphanumerics, no delimiters allowed.

When you are joining strings, you are wisest to use the & symbol, (joining), instead of the + symbol, especially if you have conflicting data types. Using the & will tell the interpreter to attempt to join string data, while the + operator will try to calculate a value from the expression.

To find all this wonderful VB stuff in Excel, press ALT-F11 on a blank Excel spreadsheet and you will find the editor. It uses forms and buttons, and other stuff like that, and must be explained a little further.

Oh, if you address a Cell, you have to put Sheet1.Cell(y,x)=....

It addresses the cells like LOCATE would, where Y is first.

Sheet1, is of course the name of the sheet you are using to store the data. If you do not put the name of the sheet in there separated by periods, you might end up having to later, because I used to code with just "" Cell(1,1)=..., but it gave me an error one day and the cure as to add the name of the Sheet to the Cell addressing. If you delete or rename a sheet, your VB code will come up with an Object Missing error, and you must rename another sheet to what the code reflects. This is sometimes difficult, just keep deleting sheets and adding and renaming until it lets you. It is difficult about doing that for some reason.

When you code the initial boot program it goes into a Module, and your programs go into Userforms. If you create an object, like a button, do not use reserved names. It will warn you if you try to. If you double click on the name of the userform, it will appear in the editor, and if you create a button and double click on that, it will generate a SUB for you with the name of the button with _ONCLICK added to the end. This is where you stick your code to react to the thread activation. Thinking on a thread only basis is a very big head spin, since getting my diary program in VB//Excel was a big learning curve for me at first.

I will document this further, and there is also very easy to use code that will let you do a file search and return the entire file path as well as the file, which is valuable for any real project.

There is code by one of the masters that lets you create and modify 24bit BMP's using GET and PUT commands, which you can use to edit graphics in your VB code, and there is also code to access a DOS shell within VB so you can trigger your edited image to view in an external program like PAINT, or whatever.

Alot of making thread based code work is to take a page out of Java scripts for web pages. You only activate based on your entries the code to parse your information by hitting a "" SUBMIT button. In my diary program, I can edit a diary entry, but I will lose my edit unless I hit SUBMIT to save the data into the Excel Cell for me.

Really, going from a constantly running coded program to a thread based response only kind of coding, will take a change in thinking, but it will prime you for other programming as well. Alot of modern code is done using thread only based methods, and this will give you a taste of how to orchestrate a program to run concurrently, with completely isolated pieces, working across a mutually accessable plane of data sharing, (the cells), and hopefully push you further into better programming.

Oh, when I name my buttons, I usually add the lil word Momo on the end, so whatever name I come up with does not accidentally be a reserved word. Momo -- "" Momentary Switch.

### Good Sprite Animation

I have found an unwritten rule about sprite animation, that should help anybody that is learning to do animated pixel art, aka game sprites.

" Do not change the number of pixels in your sprites."

How do we do this? Well, the way you do that is write your own image editor, that lets you take and swap the pixels locations, two at a time, instead of drawing and erasing. Of course you need to get the base sprite done first with erasing, but once you go to take and add in fluid motion, your eye will notice the drop in pixels subconciously, and it will look "" off, to you. The proportion changes both actually, and your eyes subconciously pick up on it as well. Once you break the fluidity of having the same number of pixels on the screen, your animation looks broken and very odd, even maybe disturbing. Yes, there ARE cases where you Must add more pixels period, but doing the inbetween animations, take and wiggle the pixels around, don't hack and slash your way through doing those fine tuned animations. Your eyes will thank you and so will your fans.

### A virtual 3rd button for your mouse.

An awesome trick I found using a shareware program called MVP, was the addition of a 3rd button, without actually mapping the middle button on the mouse. How?? You poll the right button, and once the button is pressed down, you poll to see if the user clicks the left button next while still holding the right one, or lets go of the right button.

This simple way of adding a third option to your programs is invaluable and saves a ton of overhead. Cause eliminating even one extra menu can cut down on a ton of extra lines of code. This will let you drop all that down into a simple polling loop to see what the user does with the other button while you watch the first one.

### Printing listings on any printer in a readable format.

Open document in Notepad, copy paste to Word pad, SELECT ALL, set to "" Courrier New Font, and manually type in the font size as 5 .

When you go to print, one you will save a ton of ink, and two, if you can read that small, you will be able to see those long long long lines of code with very little line wrapping on the ends.

>     'Simple program to fix the Linux naming problem.

>     OPEN "MYPROG.BAS" FOR INPUT AS #1
>     OPEN "MYPROG2.BAS" FOR OUTPUT AS #2
>     WHILE NOT EOF(1)
>      A$=INPUT$(1,1)
>      PRINT #2,UCASE$(A$)
>     WEND
>     CLOSE #2
>     CLOSE #1

I saw that letter about coding in Linux and how files with uppercase and lowercase will not find each other, so I coded that short sweet answer to that problem.

Kiyotewolf

Download a copy of this article: kiyoteonaverietyofsubjects.html

## Before Releasing Your Game

### Written by Nalin Kanwar (June 2008)

### Introduction

Hi! i'm nkk. Most of you on FBGD maybe knowing me. I thought i'd write a tutorial about how to give your game a good polish/finish. Many people forget simple things which if included in a game can avoid annoyance to the gamer. I've seen that loads of FB games lack the professional look(incuding mine. I recently acquired this knowledge). This is some basic things which people mostly overlook. Also, My english isn't that good.So bear with me :P. Now, Let's rock~!

### Getting Started

First, Let's sort out the features.
1. Functionality and support
2. Game features
3. Polish & Presentation
4. Installation

Ofcourse this list isn't complete. But this is what i'm going cover in this little tutorial.

### Functionality and support

Being programmers, Many of us would be a heavy multi-taskers. So, you must be aware how annoying it is when switching is disabled in a game. Do not disable this option! Disabling it will prevent many gamers from playing the game. Another similar feature is Windowed/Full screen mode thingy. Even if it is a mouse controlled shooter or something. If it is, then clip it to the window. Similarly, You should also allow the user to quit the game at any instant. And don't forget to unload the textures/memory before you quit. In FB, you can catch the close button press using inkey buffer (chr(255) + "k") and it's not that hard to implement. Another simple feature that should be added is Music "and" Sound control. Yes, Music and Sound are different things and you should allow the user to turn up/down individual volmes (Dont just put On/Off!).

Enough of this simple but needed crap, The next feature i'm telling you is generally added in EA games. You should add the machine compatibility tests. Ofcourse, this doesn't matter for small games but you should include it if your game is graphic intensive or processor/math intensive. Also, Checking for OpenGL compatibility before starting an OpenGL is necessary. People often ignore this one. But adding machine compatibility tests make your game more professional and though it seems useless, it tells the user whether your game will work on their pc or not instead of them waiting for the game to load when their pc is not fast enough to run it. Also, This helps in technical support and debugging.

Another important feature is to allow redefinable keys. Gamer should be allowed to change to the keys they are comfortable with. For example, Some people like to play "wasd" instead of arrow keys in some games. Adding Joystick/Keypad support is good but not neccesary.

The last thing i'd like to add in this is a website. Making a website of your game always helps publicizing it or even a page at your site. Website from where people can download the game, give feedback, Post screenshots and if its worth it or game is a large project, a forum.

### Game Features

Lots of people slack when doing the things which i'm about to mention. Having music in a game always helps. Put sound effects for every possible event. Including those mouse clicks or menu options.

Highscore tables are effective way of keeping people interested in playing the game. An Online highscore system is really effective as the gamer can know how good his/her friends are playing. Really, its is more fun than it sounds.

Including beginner modes/tutorial levels is a good idea. It allows gamer to settle down with the game atmosphere. Ofcourse, Adding difficulty levels could counter this feature. Still creating tutorial levels is better than putting help screens or help files. Nothing is better than experience. In game hints/help are also fun to play with. Little popup/Chat captions work really nice and can explain games features. Including a strategy guide along with this is a nice idea. It works excellently with Rpg and Rts games.

Another option that many games lack is Pause option. It is really required, I don't know why many people don't put it in their games. Imagine this, You're playing an intense game and someone is at the door. but there's no pause in the game! (that poor person outside the door :P). Multi-taskers would understand what i mean.

Co-Operative/Double player mode is really fun and sometimes more interesting than single player mode. Nothing more satisfying than beating your game opponent! How much ever do you improve the AI, you're never going to make it as good as human brain. The real challenge is always when you play against a player.

Level Selection/Save games must be present. Although i think both should be present. Level selection with password is good enough. Allows gamer to skip through already played levels. A handy feature if you want your games to be played again and again. Level/Scenario is a sure shot way to increase the game replay value! Add some secret bonus levels and make sure they're worth playing the game again!

### Polish And Presentation

I admit that the stuff i'm going to list out is far from complete but this are some of the most important things. Smooth screen transitions using alpha always rocks. Fade in and Fade out. Use it properly though, some times those alpha transitions can be annoying.

Another things which most of the FB games lack is screens! Loading screens can be useful to see if the game is loading or has frozen. High score screens are also a must. If your game is professional then you can put screens about what will be included in full version. Don't put nag screens though! They annoy the hell out of anyone. That'll detract some potential customers.

Adding screenshot support is a good feature though not always necessary. But it allows the gamers to show off their tricks/scores/achievements thus gives you more publicity. This works nice when you make a Rpg, Rts or Arcade game.

Most of the computers in world use English as primary language. But many people use different languages. If your audience is a specific community/region, Multi lingual support is nice feature and your game will spread farther than if you'd just used English.

For an Rpg/Campaign based game, A game progress indicator is a really good feature. Like maps with roads that have been played or marking out how much route has been covered.

Lastly, You can add skins and personalisation support. Like allow user to change the background, music, colours, choose/make his symbol, choose NPC's names etc. And last but not the least, Credits! Credits to all of your contributors!

### Installation

Almost 99% games in FBGD lacks this! Most of them are just zipped. A good installer installs the game properly and gives options like link on desktop, program group with a meaningful name, option to run the game after installation is complete etc. Also, Your game installation must also include an EULA which stands for End User License Agreement. Read more about it here

Now that you got your installer done, only one thing remains. Yes, A good uninstaller as well. One that doesn't leaves any remains. Also, All the registry entries must be removed too. An option to remove player settings or not is necessary.

### Closing

There you go! Many people might disagree on what i said in above paragraphs. But remember that this is all to make your game professional and polished. Ofcourse, These are optional features. But if you are serious about your game, you should follow this. Also, you may find this tutorial to be FreeBasic related but it also applies for games in any language.

Anyways, this was my first rant about anything :P. Hope you like it. And Sorry if my english was horrible. Cheers and keep creating excellent games!

This tutorial was written by Nalin Kanwar. You can mail him on nkk_kan@yahoo.com or visit his code cache.

Download a copy of this article: Before_Releasing_Your_Game.html

## Barren - An Interview With Its Author

### By Hexdude

By the time I'd arrived on the QB/FB scene, Lachie Dazdarian was already a prolific game developer with several projects under his belt. In the intervening years, he has continued to output a large number of games and demos, his name becoming synonymous, at least in my mind, with extremely hard work and, often, merciless self-criticism. Through the FreeBASIC Games Directory, he has risen to prominence in the FB game scene as a supportive and encouraging force in the community.

Barren is a game with almost legendary status due to it's long (no pun intended) on and off development time. When this story arc of Lachie's life as a game developer so far came to a close, I wondered where it fitted, in the creator's mind, in the larger context of his work, and, with this behind him, where the future might lead....

Interviewer: When did you start the project?

Lachie: Well, it was sometime during 2002 when I got online for the first time and discovered that QBasic could load GIF and BMP images. Till then I played with LINEs and CIRCLEs. I even didn't know how to use subroutines. Anyway, I just wanted to make something interactive using GIF images.. Humble starts.

I: Do you feel a little sad that an era so long has come to an end?

L: Not really. I'm glad I got this monster off my back.

I: How much of that time were you working on the project?

L: It's really hard to say, because the development was interrupted so many times. I would say some 6 months of development time, but that's a wild guess. It could be more.

I: How do you think it compares to your previous projects, and how do you think it will impact your future ones?

L: I find it difficult to compare Barren to my previous projects, because Barren is quite different from my other works, in all aspects. From the genre to long development process. Perhaps it's the first game of mine that features a really involving and cool atmosphere (not bragging, but this is like a unanimous judgement). The positive comments regarding that are quite motivating for me on a certain level. Glad to know I can deliver this aspect in games. How will it affect my future projects? I really can't tell. I doubt it will affect them much as Barren was a residue of my game design past and roots. Working on Barren was an ordeal in a way for the most part, and it ended up being nothing more but a small adventure game. So I don't see myself working on a longer adventure game soon and without becoming very skilled in pixel art first (or finding a skilled artist willing to work on my ideas - fat chance).

I: What were the biggest challenges you faced?

L: Graphics, mostly.. I think 2D adventure games are the most challenging games to develop in the graphics department. You really can't recycle much graphics in adventure games. Each new scene is a new challenge and must be drawn from scratch. I am quite happy with how I managed to execute certain segments of the game, but without the help of Na_th_an and especially Josiah quite few parts of the game would appear very weak.

I: Do you think it has been a worthwhile experience?

L: Again, difficult to say. Perhaps too much effort was invested for the end result, but as the game moved toward the end and with the quality graphics and music I started to receive from Josiah, it became a pleasant experience completing the game. The way Barren was developed probably represents the complete opposite from the ideal game development process. So any dissatisfaction I might have does not result from the end product, but from the delayed and poorly planned development process.

I: What was your inspiration for making Barren?

L: It was a Paintbrush image I did probably before 2000 showing the 4 main game scenes with an ominous faceless figure in front of all that.. The way that image turned out always excited me and made me contemplate about how making a game out of it would be cool, although I had no idea what kind of game I wanted to make. This resulted in Barren being such an unfocused and random game. BTW, I think I have that image online somewhere. Oh yes, here:

Funny that site still being online.

I: How does the end result differ from your original vision?

L: Actually, not much. Josiah helped a lot bringing this project to the point I sketched out long before in 2003. There were few things I pondered about during the dev process, but I never found the motivation to create and put them in the game. One involves a room with a TV and a person from it talking to the player obscene stuff (mostly inspired by my own dark thoughts), but I thought that sort of character would reveal too much of my own daemons. The second idea involved another scene. It should have been placed on the roof of one of the buildings, featuring a nice panoramic overview of the valley..

I: What made you stop the project, and why did you start again?

L: It was various things, mostly being distracted by other projects, college or work, and in the same time feeling quite discouraged with not being able to execute certain segments of the game. In most cases the project picked up when someone offered to help or when I tricked someone to work on it (:P). And at one point the constant motivator to continue developing the game became the fact that so many work hours were invested in the development already.

I: Why did you change the project's name?

L: Heh, it was mostly the result of "Noname" being grammatically incorrect and "No Name" looking fugly in the title. Also, I was not able to decide if "The" should go in front of "Legacy of Noname General" or maybe one more "the" should be in front of "General". Funny thing is, for some time I wanted for the new title to be"Barren - The Legacy of No Name General". Don't know what happened to that idea. :P

It was Zamaster who suggested Barren for the title.

I: Who joined the project, and what part did they play?

L: Oh, boy. This is a long story. The first person showing interest in LONG, as it was called back then, was Na_th_an somewhere in 2003. He got intrigued by a demo that I made available, featuring the main 4 scenes and one extra scene with few click boxes. He motivated me to rewrite the code which was a nightmare of unimaginable proportions and write down the game plot line. I remember relsoft, who helped me a lot in programming back then, calling the first LONG code "sophisticated" out of courtesy. Oh, the good old days. Anyway, back then Na_th_an did a lot of work, mostly related to three game scenes. Two ended up only being retouched in Paint Shop Pro, while the other (which was one of the later game characters) was somewhat redone by me. His biggest contribution was the fake OS appearing in the game (I just have to make this minor spoiler), which really adds a lot to the quality of this product. Because of some artistical differences we split, and not until late 2007 nobody joined the project. First it was Zamaster (Christopher Brown) offering me a joint project. Before that I persuaded him to make few music tracks for Barren, after which he disappeared completely, abandoning me on our joint project too. Later I got an email from him saying he got burned out or something, and feeling bad on leaving me. Oh, well. The next person to join the project was Vincent DeCampo, again on the same manner. First by wanting to work with me on a different (any) game project. He ended up doing two cool scenes for the game, and the main game banner (on the main menu). He also disappeared shortly after that. Maybe I'm a difficult person to work with. :P

The last person who joined the project was Josiah Tobin, and he practically saved it with several music tracks and a huge amount of sound effects. Also, his graphics contributions, mostly appearing at the end of the game, are just awesome. It was a huge pleasure to work with him on this project and he's a team member you can only wish for. Skilled, ready for his work to be altered, and always available.

I: Are you satisfied with how Barren turned out?

L: I answered to this question partially when talking about the project being a worthwhile experience. Anyway, I would say more or less. The fact is that this project was started rather clumsy, without a clear goal, and was continued to be developed despite that. The biggest flaws of the game are my poor pixel art skill, graphics style incoherence (because several people worked on the project), and unplanned gameplay and script. Which is a lot, I know. Anyway, a great deal of development went into patching these weak aspects of the game, and on the end I must say I'm quite satisfied how they ended up being patched. ;)

I: How has the reception been in the community and elsewhere?

L: I would say fair. Very nice and positive in the community (more that I expected and could wish for). I would only like to see the game reviewed by someone. That would be nice. Outside the community? Well, not so great. It's difficult to find a place to show off your retro 2D game nowadays (unless it's outstanding, then other people will promote it for you). I got several positive comments in the www.create-games.com community and a review (although the game got mutilated in their "game of the week" poll), but without that site and our community it would come down to a handful of comments (not counting "Wee, this looks like a nice game!" posts which only annoy). I wish there was a freeware community full of avid freeware game players willing to comment and dissect your game. Maybe such community exists, but I haven't found it yet. Anyway, happy with the feedback I got, not by its volume. I guess I never am. :P

But this kind of situation makes me want to reconsider my motivation for making games. Maybe I should put more value in just being happy with releasing something quality. The volume of feedback you might get is always a gamble.

I: You have said that you plan to take a break from game programming for a while, what are your motivations for this?

L: Well, Barren was a project I dragged since ever, so it's quite naturally I feel a need to make a small break after completing something like that. Anyway, lately I'm quite busy with my new job so I have little of free time available. No need to kill my free time with another project so sudden. Beside that, I should concentrate on administrating FBGD for a while now. I also hope some plans regarding its better future will realize. ;)

I: Do you have anything planned for your next project, or a vague idea?

L: Of course I do. ;)

I really want to make a gameplay driven platform game, something like Giana Sisters. Some of you remember me trying to compile a platform engine a while back and that will probably be the first thing I'll attempt when I get back to programming. I will try to finish the darn engine and compile some level editing tools. I still see my pixel art skill as an obstacle, but now I'm ready to spend months only on getting better in that aspect. I really don't feel a need to rush another release at this point of my game dev life which is really good.

As of other projects, I have enough of them to fill 3 lives. One includes a game with the Star Cage engine, but I'm not so motivated to use it as the feedback I got on that engine wasn't that good. Another one includes a story combining fantasy, humour and SF, made in a screen by screen scrolling engine. All in all, you can expect new stuff from me. Eventually. ;)

I: Thanks for your time

L: Cheers!

Visit Lachie's website to download Barren: http://lachie.phatcode.net

## Ten Years of Pete's QB Site

### Written by Pete Berg

It was a rainy day in October of 1998. I was 13 years old.

Having spent the past year of my life playing around with QBasic in every instant of my spare time, you could say that I was a genuine QBasic addict. I would pass my days hacking together little text adventures and crappy mini-games made with LINE and CIRCLE statements, which puzzled my parents and wowed all my middle school buddies. (One of my games, Tower.bas, became a big hit in my 7th grade computers class, and my friends and I would compete to see who could make the better QB game.)

Sometime in 1997, I first typed "qbasic" into Yahoo! and discovered the QBasic community. That's what really hooked me. I visited every website I could find (mostly hosted by GeoCities, and with obnoxious animated starfield backgrounds and Comic Sans font), and downloaded every program I could find (mostly games just like my own, hastily created with LINEs and CIRCLEs). Now, rather than sharing my games just with kids from school, I would log on to the NeoZones Productions QBoard, or the QBasic Top 50, and share my creations with thousands of people from all over the world. I thought it was the coolest thing ever.

By the fall of 1998, I had decided that I was going to learn HTML and start my own QBasic website. So that rainy morning in October, I signed up for a gigantic 10MB hosting account from FreeYellow.com, and began Pete's QBasic Site.

Never would I have expected that ten years later, this website would still even exist, or that I would ever be updating it while riding a train across Tibet's permafrost, on my little Asus Eee PC laptop. But here I am, a 23-year-old guy, now a whole lot taller, college-educated and bearded, still typing HTML code by hand to update this little thing called "Pete's QB Site." It's funny what we hold on to when we get older.

### Milestones of Pete's QB Site

A decade is a long time, and my QB site has gone through a lot of changes over the years. Here's a look back at the past ten years, with a list of some milestones over the past ten years:

#### October 1998 - "Pete's QBASIC Site!" launches

On that rainy day in 1998, I put together a crappy little text-only website on my free FreeYellow hosting account. It was basically a "hello world" kind of site, with hardly any content...other than a few "news" posts about all the big plans I had for the site.

At the time, I hardly knew any HTML and didn't even have any links on the page because they were beyond my grasp. But within a few weeks, I figured out how to split my page into multiple sections (complete with hyperlinks!) and put in a simple graphical logo, but it was still very primitive.

One thing the site did have, though, was a dedicated webmaster. I'd work on the website every single day, and "daily updates" would be the trademark of Pete's QB Site. (I would update Pete's QB Site every single day for over a year.)

#### November 1998 - Pete's QBasic Site opens its doors to the world

For the first few weeks, I was a little embarrassed about my QBasic site, and only shared the link with my closest friends in the QBasic community. It wasn't until November 1st, 1998, that I joined the QBasic Top 50 (the definitive QBasic directory of the time), spammed my link all over the Internet, and began requesting other QB websites to link to me.

Most of my content at the time was stolen directly from other sites, but I did start writing a series of original QB tutorials for beginners, which have been spread wide and far throughout the QB community over the past decade. Many people have told me that they were first introduced to programming by my tutorials...pretty good for tutorials by a 13 year old kid with no real writing skills! Another big project was my QBasic Links Archive. I would scour long and hard and would link to the most obscure and forgotten QB sites on the 'net, and soon I had a directory of over 300 different QB sites.

Early on, I dedicated a huge amount of time and information on my website to my Untitled QB RPG Project, which (like all other QB RPGs at the time), promised to be the biggest and best RPG ever made. (We're talking even bigger than Michael Hoopmann's Dark Ages -- the gold standard of QB RPGs back in 1998!) Of course, nothing ever came of that project, and I abandoned it quietly a few months later.

#### March 1999 - Game Reviews!

By early 1999, I had updated my site every single day for well over 100 days. (Well, not exactly -- sometimes my "update" was merely updating the news stream, or I'd have my mother post some pre-written text when I went away for the weekend on a Boy Scout camping trip or band trip, but for the most part, I added new content every single day.) I learned quite a bit of HTML and gave the site a much more attractive design -- a green and black makeover that was a huge improvement over the old look. For the first time, people were taking my site seriously, and my traffic started shooting up with each passing month.

But my site was still nothing unique. Every QB site offered programs for download, links, tutorials, etc., and all of the good ones had a much bigger and better collection than me. I needed to come up with a unique hook -- a niche -- that would keep people coming back.

Around the same time, I had been writing reviews of Game Boy games for a small website called DMG Ice, and I thought "hey, why don't I do the same thing for QB games?" So I started writing QBasic game reviews -- which became my site's focus almost overnight. The image to the left is the first ever review I did. The game reviews really set my site apart from the others, and pretty soon, I had a queue of hundreds of games that had been submitted for review.

#### April 2000 - Record traffic and reviews

In early 2000, my site passed 100 reviews, and Pete's QB Site was growing by leaps and bounds. By April, my website was one of the most-visited QB sites, and was at the top of all the QB Top Sites lists. I was getting 500 or more hits per day, a figure that I've never been able to match since then.

My site also inspired other QB Reviews websites -- specifically V Planet! (which took the QB reviews process to a whole new level), and GB Games, which also had a lot of success during that golden age of QB.

Unfortunately, it was also in mid-2000 that I realized that daily updates were unreasonable. I had updated the site nearly every day for a year and a half, and I was getting bored with the site. My frequency of updates wained significantly, just as I started to receive lots of review submissions from readers. With less time to keep the site up to date, I took on a few more webmasters to help me maintain the site -- Indigo Fox and WisdomDude.

#### 2001 - Pete's QB Site goes dormant

Although my site was getting record traffic in 2000, I was getting very sidetracked by high school, and my number of updates dropped from a handful to almost none. Pretty soon, it was only Indigo Fox and WisdomDude updating my site.

In early 2001, after I had stopped updating for a few months, Indigo Fox started a neon-green redesign of the site. Halfway through it, he got sidetracked as well, and the updates stopped completely on January 22, 2001. Pete's QBasic Site was abandoned.

Nobody touched it again until...

#### Fall of 2003 - Rebuilding Pete's QBasic Site from scratch

Despite two and a half years passing without an update, my site was still getting very steady traffic. It stayed online, as a library of QB content, and managed to garner 150 to 200 hits a day even with nothing new ever appearing on the site.

In 2003, I had renewed interest in web design, finally learning how to actually use SQL databases, JavaScript, CGI coding and other interactive elements. I designed a few other sites for fun, and then one day, while hanging out in my dorm room at Ithaca College, decided to redesign Pete's QBasic Site from scratch. I made a whole new design, created a custom interactive back-end (that would allow visitors to submit content to all parts of the site), and started a forum. The only thing I didn't do was open it to the public, because despite the overhaul, the site wasn't quite done.

It sat hidden online for a few months, and then someone at NeoZones.com discovered it. Soon, tons of visitors were visiting this unfinished website, and I decided that I had to finish it.

#### July 2004 - Pete's QBasic Site Officially Relaunches

In between the days I spent at my miserable internship the summer of 2004, I finally finished redesigning Pete's QB Site. I officially relaunched it in July, and the brand new site was received very enthusiastically by the waining Qmunity.

Leading up to the "official" relaunch, I spent several weeks scouring the Internet to collect tutorials, links and content from QB sites that had long been abandoned. The rationale was that since the free hosts that these sites lived on were shutting them down by the day, I had better preserve them while they were still around.

I collected the Qmunity's largest collection of tutorials as well as the most exhaustive archive of QBasic Magazines on the web.

#### August 2004 - First issue of "QB Express" magazine

Since I first read QBasic: The Magazine in 1998, I'd been toying with releasing my own QBasic periodical, and I spent much of the month of August tracking down and creating an archive of QBasic magazines and reliving the past through this treasure trove of QB history.

I decided that I had to start a new QB magazine. I spent two weeks begging people for submissions, working out a bulletproof layout and style, and on August 23rd, 2004, QB Express #1 was released. The magazine was received very enthusiastically, and I made it my goal to release a new issue every single month.

#### August 2005 - One year of QB Express, Pete's QB Site begins covering Freebasic

QB Express really caught on, and within a few issues, I was receiving more submissions than I knew what to do with. With each successive issue, there were more readers and more content was submitted. Each issue of QB Express tended to be over 250 pages long -- about 3 to 4 times larger than any QB magazine had ever been in the past. When Freebasic was released in the fall of 2004, QB Express began covering Freebasic as well.

All the success made me work really hard on the magazine and keep on a steady monthly schedule. QB Express #12, our one year anniversary issue was the biggest one ever, and when I released the thirteenth issue, QB Express exceeded the famous run set by QBasic: The Magazine back in 1999.

#### 2007 - QB Express becomes the longest running QB magazine of all time

After its successful first year, QB Express began to slow down, and I would occasionally miss a month or two in between issues because of "real life" obligations. Still, each issue was large and polished, and submissions still came flooding in with each passing issue. (I got so busy during 2006 - mid-2007, that QB Express went about ten months without an issue, but I revived the magazine and have been releasing issues every few months since then.) During this period, the content of QB Express shifted markedly toward Freebasic content, and I almost changed the title to "FB Express" at one point.

In late 2007, QB Express passed the on-and-off BASIX Fanzine to become the longest running QBasic magazine of all time, and of course holds the distinction of being the largest Freebasic magazine out there.

#### October 2008 - Pete's QB Site celebrates Tenth Anniversary!

...which brings us to October 12th, 2008, the tenth anniversary of my little QB site.

When I started this site, I really didn't know what I was getting myself into. I certainly never imagined that I would ever put in so much time, love and dedication for so long...who would have guessed it would still be active in a decade!? I didn't even think the QBasic community would still be around in five years when I began Pete's QB Site, so you can imagine my surprise.

Pete's QB Site has had its ups and downs over the years, but I can safely say that I'm awfully proud of this website. At the very least, I think it's achieved its goal: to share QBasic / Freebasic programming knowledge and promote and unify the QB commuunity.

Thank you all for ten amazing years!

Visit Pete's QB Site: www.petesqbsite.com

## Y2K: The Year 2000 Problem

### Written by Moneo

> Edward F. Moneo, May 2008
> Edited by Stephane Richard

The dust has pretty well settled on the Y2K issue, but I thought I'd write this article to give you programmers some insight into what was going on in the 1990's, and what problems we faced..

### THE HYPE:

During the 1990's, there was a tremendous amount of negative press given to the Y2K problem, and the general public as well as computer people, were very concerned. The Y2K problem was considered the biggest single information project the world has ever faced. People were led to believe that in the first minutes of January 1st, 2000, all the computers in the world would go haywire.

### THE BUSINESS:

During the years of 1995 to 1999, computer departments were scrambling around trying to find Y2K solutions. Many well-known consulting firms and software houses, then known as Y2K solution providers, quickly put together some general solutions. Due to the hype, the computer departments of companies which could afford it, contracted these solution providers.

These solution providers saw the tremendous opportunity to realize a windfall business. The costs in the USA for Y2K conversion and compliance had been estimated as $300 billion dollars. These outfits not only brought in their software solutions, but also a team of highly paid consultants and programmers. They also brought in tons of "paper tiger" documents to dazzle the customer: Contingency Planning Guide for Year 2000, Remediation/Replacement Contingency Plan Template, Year 2000 Impact Evaluation, Plan 2000 Procedures, and more. None of these documents described how to identify Y2K problems in a program or file, and much less how to correct these problems.

In 1997, I was on the Y2K project for a large international bank, and witnessed the software solutions and performance of the consultants and programmers. The last time I looked, the bank had already spent $60 million dollars. The main consulting firm was the most highly-touted Y2K outfit at the time, and yet their software solutions were inadequate, in my opinion. I personally had to make modifications to expand the Y2K software detection logic. The programmers assigned to the project were very young and extremely inexperienced. They were just "bodies" thrown into the project to generate more consulting fees.

During the above Y2K project for the bank, I was asked to attend a big Y2K conference in Phoenix, Arizona. All the most important Y2K solution providers were there, including:

> AIC (Analysts International Corporation)
> Andersen Consulting
> CACI
> Comsys
> CTA, Inc.
> Gartner Group
> Keane, Inc.
> KPMG Peat Marwick
> Litton Computer Services
> Mastech
> Matridigm
> Peritus
> PKS Information Services, Inc
> . Shell Services Company
> Viasoft, Inc.
> Walker Interactive Systems

I was very excited to be able to exchange my Y2K ideas with these experts. At the opening cocktail party, just to break the ice, I asked ten people if they thought that the year 2000 was a leap year. Only one person answered correctly, i.e., yes. "And these are the experts?" I asked myself. The next day, at the general conference, after several hours, I came to the realization that the entire conference was about doing business, making customer contacts, and selling the packaged solutions; not identifying or solving any Y2K problems. I couldn't believe it. The guy sitting next to me was the CEO of a major nationwide Y2K software house. After my bringing up of a few Y2K technical issues, he turned to me and said: "You have your head full of trivia." I was shocked, but managed to answer: "That's because I have to program what you call trivia."

### IN-HOUSE SOLUTIONS:

Many companies could not afford to contract the Y2K solution providers. Some companies chose to ignore the Y2K issue entirely, adopting a wait and see attitude, that is, fix anything later that manifests itself as a problem. Other companies did some quick fixes to things that had already shown up as a problem.

In late 1997, I left the above bank project to join the IT department of an international book publishing company. They were running a large ERP book publishing system, and had all the source code for the system. During 1998, the issues of Y2K were discussed, and it was decided that a complete Y2K conversion be performed. The Y2K conversion began in November 1998. I wrote a table-driven search program which scanned all the source code and identified lines of code which were suspect of containing Y2K problems. The great advantage that we had was that the programs were being modified by the actual programmers responsible for them. We scanned about 8000 programs, and at the end of the project in January 1999, actually modified only 50 programs. When the year 2000 rolled around, we never had a problem.

### THE TECHNICAL ISSUES:

The majority of problems which are considered to be Y2K problems, are merely date handling problems.

The following are some date handling problems which are not Y2K problems:

> - Erroneous calculation of leap year.
> - Erroneous calculation of days per month.
> - Erroneous calculation of the week number for a given date.
> - Erroneous calculation of the day of the week for a given date.
> - Erroneous calculation of a person's age based on his date of birth.
> - Erroneous calculation of the number of days between two dates in the same century.
> - Erroneous validation of an input date, allowing invalid day, month, or year.

The above problems, or bugs, have been around in programs for many years, and have nothing to do with Y2K issues.

### True Y2K Problems:

Y2K problems have to do with date logic, where the year is represented as a two-digit number, and different dates can have years in different centuries.

A program which handled dates with two-digit years from the 1800's during the 1900's, had this type of problem, though strictly speaking it was not called a Y2K problem.

The root of the Y2K problem is the continued representation of years as a two-digit number. If you attempted to search or sort dates in different centuries using only two-digit years, this obviously would not work. Internally, for searching and sorting, many Y2K solutions converted the two-digit year to four digits by applying some arbitrary algorithms beforehand. For example, if the particular system was developed in 1970, they converted two-digit years less than 70 to have a century of 20, and the others to have a century of 19. Obviously, this won't work beyond the year 2070. Another risk is that some programmers might use the two-digit year of 69 or 71 as the pivot year, instead of 70.

Of course, many IT departments used different solutions for continuing to handle two-digit years. This was an attempt for not expanding all their dates on data files to four digits, and for not converting all their keyed input date logic to four digits.

The bottom line to a complete Y2K conversion, is precisely converting all dates to have a four-digit year, both on the data files and in the programs. Based on the fact that suspect lines of code must be identified and converted, the programming effort to do this is basically the same as applying arbitrary conversions using two-digit years. Plus, the testing is greatly simplified. Many Y2K conversions also wisely fixed the non-Y2K problems listed above.

### Y2K AWARENESS IN THE FUTURE:

Nothing much has changed in software development since the year 2000 regarding Y2K issues. Standards similar to SDLC are applied to a certain degree, but these standards do not address proper date handling and validation. Unit Testing, Integration Testing, and User Acceptance Testing do not include specific testing for the Y2K type of problems.

We weathered the Y2K storm, but have lowered our guard. Many problems found before 2000 were not adequately corrected, just a quick workaround was applied. Many of these quick fixes included so-called date algorithms for converting 2 digit years to 4 digit years. Many of these algorithms will not work in the next several decades.

Having been burned, most IT organizations are now insisting that years be stored as 4 digits. However, date handling awareness, in general, has not undergone a significant improvement since 2000.

Most programmers today still have difficulty determining if a year is a leap year. Some think that a year has 52 weeks, and extremely few know that a leap year beginning on a Saturday will span across 54 weeks. Others cannot correctly compute the number of days between two dates.

If we want to diminish Y2K-like problems in the future, we must educate our programmers and our test departments on these issues.

Download a copy of this article: Y2K.doc

## Whats new on QBinux?

### Written by Seb McClouth

Well, first and all, I made my first backup. After moving to a new develop-station, something went wrong and I lost all the files. So I had to rewrite the whole thing from scratch. Luckily I had the source code of Novix on one of my many mail accounts, thank you Yahoo! and Z!re.

I’ve currently got a core, with a bug, which I can’t locate at the moment. The core is only like the Linux-kernel, so no QBash, or other stuff. Pre-alpha-tester MystikShadows is checking the core at the moment and looking for the bug. So hopefully something comes out from there and we can fix so there can be a new release soon.

For the rewrite, I returned to Linux version 0.01 and Basic4Gigabyte has been reintroduced to the source. Some of the code I worked on with several members, are still on the forums, so I get those from the forum, which saves me a lot of work.

There’s an interview taking place at the moment with PCOPY, so check it out, when the new PCOPY comes out.

At the moment live is busy, due to some physical problems and the fact that I’m gonna be a father for the second time.

For QBinux, keep checking the new site: mcclouth.zoastertech.com and for other stuff you can still e-mail me at McClouth.Software@gmail.com

Grtz

Check out Seb's website mcclouth.zoastertech.com for the latest on QBinux.

## Some Notes on FreeBasic and QB64

### Written by Publius (Mitchell Johnson)

> Here are several "notes" on FreeBasic and QB64 submitted by Publius. You might find them a bit controversial, but that's all part of the fun. :)

> -Pete

### Notes on the FreeBASIC Programming Language

What is FreeBASIC? Well, let's see...

FreeBASIC is a free/open source, 32-bit BASIC compiler for Windows, and Linux.

It is sort of kind of compatible with QuickBASIC. I think that there are several problems with the way FreeBASIC development is going:

> (1) It has that horse logo which looks ugly.
> (2) The developers seem to be unable to decide what the goals of the project are.
> (3) The solution currently in use is to create several different dialects, where each dialect allows different types of code and code written in one dialect will not work in another dialect without considerable modification. This prevents the use of say, object oriented features, in QBASIC mode.
> (4) The feature set in the main dialect has users conform to a set of "modern" practices that not everyone agrees with, yet people must use the main dialect in order to use most of the new features added to the language.

### Notes on the QB64 PROGRAMMING LANGUAGE:

QB64 is a programming language which is a dialect of BASIC. This dialect of BASIC should die horrible death. It has several problems with it:

(1) QB64 is Bloated

A small test program compiles to a 745Kb executable, requiring an aditional sdl dll of 312 KB. The hello world program generates the following C code:

>     S_0:;
>     S_1:;
>     tqbs=qbs_new(0,0);
>     qbs_set(tqbs,qbs_new_txt_len("Hello, World!",13));
>     if (new_error) goto skip1;
>     if (qbg_cursor_x!=1){
>     if ((tqbs->len+qbg_cursor_x-1)>qbg_width_in_characters){
>     qbs_print(nothingstring,1);
>     }}
>     qbs_print(tqbs,0);
>     qbs_free(tqbs);
>     qbs_print(nothingstring,1);
>     skip1:
>     qbs_cleanup(qbs_tmp_base,0);
>     if(qbevent){qbevent=0;
>     while(suspend_program||stop_program){Sleep(10);if(stop_program) end();}
>     if(new_error){fix_error();if (error_retry){error_retry=0;goto S_1;}}
>     }
>     print_holding_cursor=0; qbg_cursor_x=1; qbg_cursor_y=qbg_height_in_characters;
>     if (qbg_width_in_characters==80){
>     qbs_print(qbs_new_txt("Press any key to continue "),0);
>     }else{
>     qbs_print(qbs_new_txt("Press any key to continue "),0);
>     }
>     do{
>     SDL_Delay(0);
>     if (stop_program) end();
>     }while(qbs_cleanup(qbs_tmp_base,qbs_equal(qbs_inkey(),qbs_new_txt(""))));
>     close_program=1;
>     end();
>     return NULL;
>     }

clearly, QB64 is extremely bloated.

(2) It stops at the first error rather then continuing to attempt to compile the file as GCC does.

(3) It uses an ugly underscore hack rather than using namespaces or a command line option.

(4) It will never be fully compatible with QBASIC. C++ is fundamentally different from QBASIC in many ways. Example: The C++ standard does not specify things like the order of evaluation of function arguments while QBASIC specifies left-to-right evaluation. Technically it could be completely QBASIC compatible, but that would require writing a DOSBOX style emulator, resulting in a severe performance hit.

(5) Despite translating to C++, it does not offer object orientation features available in C++. QB64 could have been written just as easily in ordinary C.

(6) It uses the SDL library for text IO rather than then normal console, disallowing piping and redirection.

(7) It is dependant on the Windows Operating System and is unlikely to be ported to Linux in the near future

(8) It will be disgarded as FreeBASIC was because won't be completely compatible. (see #4)

### PROPOSAL FOR AN IDE FOR QB64

QB64 code is written on a coding form which is really a wax tablet. The code is then punched on punch cards made of papyrus. The punch cards are fed into the card reader and the computer (which is made of stone and is the size of a building) outputs binary punch cards containing the machine code for your program.

I also propose that QB64 switch its output format for numbers to Roman Numberals.

By now you probably guessed that this is not a serious proposal. However, it does show that QB64 emulates stone-age technology. QB64 also does a bad job of it.

Have some notes of your own to contribute to QB Express? Submit them to: qbexpress@gmail.com!

## Awards

### Written by Pete

### Site of the Month

> The New QB45.com
> http://www.qb45.com
> Webmasters: Todd Seuss and Marcade

> As I wrote in the News Briefs, QB45.com is like a cat with nine lives. No matter how many times it "dies," it just keeps coming back to life. And that's is a VERY GOOD thing. QB45.com has been famous in the Qmunity for having one of the largest and most diverse collections of QB programs in the world -- perhaps the largest. It's an indispensible resource for coders. So when Todd Seuss and Marcade restored the former Future Software this month, it was a VERY GOOD thing.

> Granted, none of the content on the site is new, and it's all been available on QB45 and other websites for years. The "New" QB45.com's layout is barebones, and there's nothing there aside from file downloads and a Discussion Board. But the fact that the content is available in a simple, easy-to-use format alone is worthy of an award. Todd Seuss and Marcade (and everyone else that contributed over the past twelve years, going all the way back to Jorden Chamid) deserve quite a bit of praise for keeping this valuable archive available.

> For continuing to be a an indispensible asset to the QBasic community, The "New" QB45.com is the QB Express Site of the Month!

### Programmer of the Month

> Mambazo
> http://www.bazosoft.com

> Mambazo has been an active member of the FreeBasic community for quite some time, but in the last few months, his programming contributions have been especially admirable. And it's mostly because of his awesome action/puzzle game, Boondog. Boondog is "a puzzle game, where you progress from level to level by jumping and grabbing ledges, moving blocks, lifts, avoiding level hazards and activating switches!" It's Mambazo's first finished game project in years, but it sure hit with a bang. People at the Freebasic.net forums met the game with rave reviews, praising its great graphics and animation, spot-on play control, and fun and exciting puzzles. I've played the game myself, and I must say that it's one of my favorite Freebasic games ever released. (Hopefully we can do a review of it in the next QB Express issue.)

> But that's not all Mambazo's been up to. He also released a space shooter game called ZapZapZap, which he developed as a personal challenge for himself: make the best FB game he could within a 24 hour period. Not only is Mambazo a talented and creative programmer, he has quite a bit of spirit for the FB games scene, which is very admirable.

> For creating a phenomenal FB game and for his spirit in game programming, Mambazo is this issue's Programmer of the Month!

## Using 7x7x16 tricks -- A practical working example

### Written by Kiyotewolf

With a concise explanation of how the inner workings should act, I thought I should slap together a quick and simple example of the kinds of special effects you can accomplish with these techniques.

When you use this in your programs, you have a few options. You can make the backgrounds independent of the sprites, or you can make your background dramatically affect your sprites when they stand//pass over them.

Sample game idea, Pack-Mann (clone), but with deadly traps. A forcefield//heated floor//lifezapping-tiles.. part of the maze.

If you set your colors on the one direction to be shades of a certain color, and carry the shades across, your sprite will take on a set of colored hues, as if a gel color filter was placed over your character.

In my example, I took the shortest and quickest way to get the colors to stand out when they overlap, without having to calculate an actual mixing of the colors. I simply did a color fill routine, and then shuffled the colors around randomly, so that the colors in the sprite when filtered would take on a radical change when over one another.

Another good idea for this technique, might be after the activation of an alarm, the level changes from being lit in normal lights, to emergency lights only, and all the action becomes hued in your particular choice of color.

I chose red.

>     DEFINT A-Z
>     SCREEN 13
>     RANDOMIZE TIMER
>     REDIM Reds(15)
>     FOR Z = 0 TO 15
>      Reds(Z) = Z * 4 + 3
>     NEXT Z
>     FOR Z = 0 TO 15
>      SWAP Reds(INT(RND(1) * 16)), Reds(INT(RND(1) * 16))
>     NEXT Z
>     FOR x = 1 TO 15
>      FOR y = 1 TO 15
>        PALETTE x + y * 16, Reds(x)
>      NEXT y
>      PALETTE x * 16, Reds(x)
>     NEXT x

>     DATA "000FF000"
>     DATA "000EE000"
>     DATA "000E0000"
>     DATA "0BAAAB00"
>     DATA "B0AAA0B0"
>     DATA "00A0A000"
>     DATA "00404000"
>     DATA "44404440"

>     RESTORE

>     FOR y = 1 TO 8
>      READ Sprite$
>        FOR x = 1 TO 8
>          Pixel = VAL("&H" + MID$(Sprite$, x, 1))
>          PSET (x, y), Pixel
>        NEXT x
>     NEXT y

>     REDIM RRam(8, 8)

>     GET (1, 1)-(8, 8), RRam

>     PUT (1, 1), RRam

>     LINE (0, 10)-(30, 40), 16, BF

>     SprX = 50
>     SprY = 20

>     Once = 0

>     DO
>      key$ = INKEY$
>      IF key$ <> "" THEN
>        IF LEN(key$) > 1 THEN
>          SELECT CASE RIGHT$(key$, 1)
>            CASE CHR$(&H4B)
>              SprX = SprX - 2
>            CASE CHR$(&H4D)
>              SprX = SprX + 2
>          END SELECT
>        END IF
>      END IF
>      IF SprX < 0 THEN SprX = 0
>      IF SprX > (320 - 8) THEN SprX = (320 - 8)
>      PUT (SprX, SprY), RRam, XOR
>        t! = TIMER: WHILE TIMER - t! < .1: WEND
>      PUT (SprX, SprY), RRam, XOR

>      IF Once = 0 THEN
>        LINE (0, 10)-(30, 40), INT(RND(1) * 15) * 16 + 16, BF
>        t2! = TIMER
>        Once = -1
>      ELSEIF (TIMER - t2!) > 2 THEN
>        LINE (0, 10)-(30, 40), INT(RND(1) * 15) * 16 + 16, BF
>        t2! = TIMER
>        LOCATE 22, 1
>        cnt = cnt + 1
>        PRINT cnt;
>      END IF

>     LOOP

The code is a simple demo, but the effect is quite dramatic.

I know, alot of you are probably saying, "" I couldn't handle dropping from 256 colors down to only 16,... or even worse.. 7!! colors???!

Don't worry, I am going to cover the managing that issue in another submission.

It cycles between colors, so you could make a changing block of red zone. This is of course, overkill, because I could single it down to a single color on the left, as long as the colors which I shuffled are distributed across the rest of the palette in one horizontal shift, covering the intersection points.

What that means, is you can use the MSB color spots to create multiple zone colors, which ALL affect the player in that same manner. You can change the color of the MSB zone palette index individually, at different rates, to make the zones stand out even more. And if you do that, your character will have a kind of halo effect around them when they step in it if you are cycling the zone color. The character will have static color shifts but the rest of the zone pad around them will pulse with the speed you are cycling the zone index color with.

If anybody has further questions about this technique, please put a post in the forum and I will try to respond asap.

There is not a whole lot more about this topic to write about, except for stretching your 16 colors back into a simulated larger color palette, using dithering techniques I originally made for EGA.

Dithering colors in VGA (MCGA 320x200), is rough and is not very pleasing to look at, so I recommend is setting your master palette of either 7 or 15 colors to something that will stand out.

Remember, Gameboy games used to only use 4 shades of gray, which was really, white, black and two shades of gray, and they still had awesome gameplay. Get creative and figure out colors you can re-use and mix around to see what kind of cool signature scheme you can create.

Kiyotewolf!

Download a copy of this article: 7x7x16_tricks.html

## Window Procedure: 2nd part

### Written by Wallyfblu

### Introduction

In the first issue, I showed you a simple way to manage the windows messages using functions pointers to choose the right proc to call. Now my goal is to expand this method to every single message, or at least, to a group of messages and put all them in a library. I will explain this method using some examples. Attached you can find the library code and an simple example of its use. I commented both library and example to avoid to write a long article ?

The Library

In the first example I used this function to handle the WM_COMMAND message:

>     Function OnCommand(ByVal hWin As HWND,ByVal uMsg As UINT,ByVal wParam As WPARAM,ByVal lParam As LPARAM) As Integer
>     	Select Case HiWord(wParam)
>     		Case BN_CLICKED,1
>     			Select Case LoWord(wParam)
>     				Case IDM_FILE_EXIT
>     					SendMessage(hWin,WM_CLOSE,0,0)
>     					'
>     				Case IDM_HELP_ABOUT
>     					ShellAbout(hWin,"MyApp","",NULL)
>     					'
>     			End Select
>     			'
>     	End Select
>     	Return false
>     End Function

You can see a likeness between this function and the WndProc function: you have to select some code to execute based on some input parameters (HiWord(wParam), LoWord(wParam), etc.). So I decided to use a struct (type) and an array of this type to store the information about messages:

>     #Define NumWidget 32
>     #Define NumMess 32
>     #Define N_WxM Numwidget*NumMess

>     Type GlbMsgMgm
>     	id As Integer		'who is?
>     	addr As Any Ptr	'what want to do?
>     	msg As Integer	'which message is?
>     	code As Integer	'which notify?
>     End Type

>     'the array to process the "events"
>     Dim Shared As GlbMsgMgm Events(N_WxM)

and use some function that make the work:

>     'in an object point of view it would be an Event/Method
>     Declare Sub OnClick(id As Integer,proc As Any Ptr)
>     Declare Sub OnChange(id As Integer,proc As Any Ptr)
>     Declare Sub OnActivate(ID As Integer,proc As Any Ptr)
>     Declare Sub OnInit(ID As Integer,proc As Any Ptr)
>     'in an object point of view it would be a Property. Yet to be implemented
>     Declare Sub Align(id As Integer,cAlign As Integer,WType As Integer)

We take the Onclick Sub :

>     Sub OnClick(id As Integer,proc As Any Ptr)
>     	Events(ccount).id=id
>     	Events(ccount).addr=proc
>     	Events(ccount).msg=WM_COMMAND
>     	Events(ccount).code=BN_CLICKED
>     	verify_N_WxM
>     End Sub

Here we fill the type fields using the control ID (or menu), the proc that will be called and the message and notify message for next verify. Now we need a proc to process this type of messages and, as you can see, it’s very closed to WndProc:

>     Private Function MngCommand(ByVal hWin As HWND,ByVal wParam As WPARAM,ByVal lParam As LPARAM) As Integer
>     	Dim As Integer code,id,k
>     	Dim ChSub As Sub()

>     	code=HiWord(wParam)
>     	id=LoWord(wParam)

>     	If code= BN_CLICKED Then
>     		If id=IDCANCEL Then EndDialog(hDlg,0)
>     	EndIf

>     		For k=0 To ccount
>     			If Events(k).msg=WM_COMMAND Then
>     				If Events(k).code = code Or code=1 Then
>     					If Events(k).id = id Then
>     						ChSub=Events(k).addr
>     						ChSub()
>     						Exit For
>     					EndIf
>     				EndIf
>     			EndIf
>     		Next

>     	Return TRUE
>     End Function

I used a variable to store the messages/widgets I’m used:

>     Dim Shared As Integer ccount=0

And this aux. func. for a simple error check:

>     Private Sub Verify_N_WxM
>     	If ccount < N_WxM Then
>     		ccount+=1
>     	Else
>     		MessageBox(NULL,"Too many item in the array","FB - Fatal error",MB_OK)
>     		End 1
>     	EndIf
>     End Sub

I don’t explain all lib because I think you can understand it from the source. You can extend the library following the framework I used, so if you need to manage the WM_SIZE message, you need a MngSize function and a Align “property” and obviously a way to store the size of widgets. I’m sure I could choose a “object” style code, but my intention was to show a method. Translate this library using type as object should not be difficult and could be an exercise.

The example

For this example I add some “GUI” proc to the library to hide the internal details. See the library code.

The sample code

>     ' Program start

>     OnInit(IDD_DLG1,@IDD_DLG1_Init)
>     OnInit(IDD_DLG2,@IDD_DLG2_Init)
>     OnClick(IDC_BTN1,@IDC_BTN1_Click)
>     OnChange(IDC_LST1,@IDC_LST1_Change)

>     hWnd=CreateForm(NULL,ClassName,NULL,IDD_DLG1)

>     'select the list
>     SetFocus(GetDlgItem(hWnd,IDC_LST1))
>     'select first item in the list
>     SendDlgItemMessage(hWnd,IDC_LST1,LB_SETCURSEL,0,0)

>     RunForm(NULL)

>     ExitProcess(0)
>     End

Here you can see how to use the function included in the library. For a complete (short) list of this functions see the wndproca.bi file, included in the first code line.

>     'the library interface
>     #Include "win/wndproca.bi"

### Conclusion

With this second article, I show you my way to hide the windows programming details and write, maybe, a readable code. This is just a starting point for a usable library although I am aware that there are many product that do better. My only goal is to learn windows GUI programming (I don’t use Linux ?) updating the library when I need new features. I hope to help someone to start code Win32 GUI app in a simple manner but with the knowledge of how it works.

Attached file:
wfb.zip
wndproc.zip WndProcA.bi

Greets to:
All article writers and Pete

If you have any idea , suggestion or disappointment please mail me to:
wallyfblu@libero.it

Download a copy of this article: Window_Procedure_lib.doc

## Common Gateway Interface in QB - Part 2

### Written by Samanddeanus

In the previous CGI tutorial (see QB Express #27), I described how to use the CGI get method. This tutorial will cover the CGI post method, setting cookies, and other information.

### POST method

The post method is basically the same as GET except that it puts the query string to STDIN. The number of characters to read is in the environmental variable CONTENT_LENGTH which you can access with ENVIRON$(CONETENT_LENGTH). The query string is in the same format as with get -- spaces become plus signs and special characters are URL-percent encoded (percent sign followed by ASCII value in hexadecimal):

>     name=value&name2=value etc.

To use the POST method, merely change

>     <form method='get' ...

into

>     <form method='post' ...

### Setting HTTP status code and Redirects

To specify an HTTP status code, simply print the status line before the Content-type line:

>     PRINT "Status: 302 Found"

Redirects are done with the Location header with the status code set to 302 Temporary Move or 301 Permanent Move:

>     PRINT "Location: http://newdomain.com/newlocation"

### Cookies

Cookies are done using the Set-Cookie header:

>     PRINT "Set-Cookie: {cookie name}={value}; expires={date}"

The date is formatted as:

>     Wed, DD-Mon-YYYY HH:MM:SS GMT

This means like:

>     Sat 03-May-2008 19:54:49 GMT

The weekday can be calculated using Zeller's rule: http://en.wikipedia.org/wiki/Zeller's_congruence

### Example 1: Random Quote

Given a database of quotes in this format

>     This is the first quote --
>     Blah blah blah
>     %
>     Second quote yeah
>     blah blah
>     %

This program creates a binary database of indices:

>      CONST percentsign = 37
>      CONST linefeed = 10
>      one = 1
>      DIM a AS STRING * 1, olda AS STRING * 1
>      INPUT "Filename? ", file$
>      INPUT "Output filename? ", data$
>      OPEN file$ FOR BINARY AS #1
>      OPEN data$ FOR BINARY AS #2
>      PUT #2, , one
>      DO WHILE SEEK(1) <= LOF(1)
>      position = SEEK(1)
>      olda = a
>      GET #1, position, a
>      IF a = CHR$(percentsign) AND olda = CHR$(linefeed) THEN
>      PUT #2, , position
>      END IF
>      LOOP
>      CLOSE

This CGI program can then display the random quotes:

>     RANDOMIZE TIMER
>     file$ = "quotes"
>     data$ = "quotes.dat"
>     OPEN data$ FOR RANDOM AS #1 LEN = 4
>     OPEN file$ FOR BINARY AS #2
>     OPEN "temp.tmp" FOR OUTPUT AS #3
>     i = INT(RND(1) * (LOF(1) / 4 - 1)) + 1
>     GET #1, i, start
>     GET #1, , endd
>     IF start = 1 THEN start = 0
>     i$ = SPACE$(endd - start - 1)
>     GET #2, start + 1, i$
>     PRINT #3, "Content-type: text/html; charset=utf-8"
>     PRINT #3,
>     PRINT #3, "<!DOCTYPE html PUBLIC " + CHR$(34) + "-//W3C//DTD XHTML 1.0 Strict//EN" + CHR$(34)
>     PRINT #3, CHR$(34) + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" + CHR$(34) + ">"

>     PRINT #3, "<html xmlns='http://www.w3.org/1999/xhtml'><head><title>Random Quote</title></head><body>"
>     PRINT #3, "<h1>Random Quote</h1>"
>     PRINT #3, "<pre>"
>     FOR i = 1 TO LEN(i$)
>     j$ = MID$(i$, i, 1)
>     SELECT CASE j$
>     CASE "<"
>      PRINT #3, ">";
>     CASE ">"
>      PRINT #3, "<";
>     CASE "&"
>      PRINT "&";
>     CASE CHR$(1) TO CHR$(8), CHR$(11), CHR$(14) TO CHR$(31)
>      PRINT #3, "^" + CHR$(65 + ASC(j$));
>     CASE CHR$(9), CHR$(12)
>      PRINT #3, "&#" + LTRIM$(RTRIM$(STR$(ASC(j$))));
>     CASE CHR$(128) TO CHR$(159)
>      PRINT #3, "?";
>     CASE ELSE
>      PRINT #3, j$;
>     END SELECT
>     NEXT
>     PRINT #3, "</pre>"
>     PRINT #3, "<p><a href='" + ENVIRON$("SCRIPT_NAME") + "'>Another Quote</a></p>"
>     PRINT #3, "<p>"
>     PRINT #3, "<a href='http://validator.w3.org/check?uri=referer'><img"
>     PRINT #3, "src='http://www.w3.org/Icons/valid-xhtml10-blue'"
>     PRINT #3, "alt='Valid XHTML 1.0 Strict' height='31' width='88' /></a>"
>     PRINT #3, "</p>"

>     PRINT #3, "</body></html>"
>     CLOSE
>     SHELL "cat temp.tmp"
>     KILL "temp.tmp"

### Example 2: Voting Poll

Data file (choices.txt):

>     McCain         0
>     Obama          0

QB Code:

>     DIM VOTES(1 TO 2)
>     DIM CANIDATES(1 TO 2) AS STRING
>     I$ = INPUT$(VAL(ENVIRON$("CONTENT_LENGTH")))
>     I$ = UCASE$(I$)
>     CHOICE = VAL(MID$(I$, INSTR(I$, "CHOICE=") + 7))
>     X$ = ENVIRON$("HTTP_COOKIE")
>     X$ = UCASE$(X$)
>     IF INSTR(X$, "VOTED") THEN
>      PRINT "Content-type: text/html; charset=us-ascii"
>      PRINT "Set-Cookie: voted=true; expires=Sun, 01-01-2012 00:00:00 GMT path=/"
>      PRINT
>      PRINT "<!DOCTYPE html PUBLIC " + CHR$(34) + "-//W3C//DTD HTML 4.01//EN" + CHR$(34)
>      PRINT CHR$(34) + "http://www.w3.org/TR/html4/strict.dtd" + CHR$(34) + ">"
>      PRINT "<html><head>"
>      PRINT "<title>Vote Recorded</title>"
>      PRINT "</head>"
>      PRINT "<body>"
>      PRINT "<p>Your vote has been recorded</p>"
>      PRINT "</body>"
>      PRINT "</html>"
>      END
>     END IF
>     OPEN "CHOICES.TXT" FOR INPUT AS #1
>     LINE INPUT #1, NULL$
>     FOR I = 1 TO 2
>      INPUT #1, CANIDATES(I)
>      VOTES(I) = VAL(LTRIM$(MID$(CANIDATES(I), INSTR(CANIDATES(I), " "))))
>      CANIDATES(I) = LEFT$(CANIDATES(I), INSTR(CANIDATES(I), " ") - 1)
>     NEXT
>     CLOSE #1
>     VOTES(CHOICE) = VOTES(CHOICE) + 1
>     OPEN "CHOICES.TXT" FOR OUTPUT AS #1
>     FOR I = 1 TO 2
>      PRINT #1, CANIDATES(I), VOTES(I)
>     NEXT
>     CLOSE #1
>     PRINT "Content-type: text/html; charset=us-ascii"
>     PRINT "Set-Cookie: voted=true; expires=Sun, 01-01-2012 00:00:00 GMT path=/"
>     PRINT
>     PRINT "<!DOCTYPE html PUBLIC " + CHR$(34) + "-//W3C//DTD HTML 4.01//EN" + CHR$(34)
>     PRINT CHR$(34) + "http://www.w3.org/TR/html4/strict.dtd" + CHR$(34) + ">"
>     PRINT "<html><head>"
>     PRINT "<title>Vote Recorded</title>"
>     PRINT "</head>"
>     PRINT "<body>"
>     PRINT "<p>Your vote has been recorded</p>"
>     PRINT "</body>"
>     PRINT "</html>"

HTML code:

>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>     <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>     <head>
>     <title>Cast Your Vote</title>
>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>     </head>
>     <body>
>     <form action="cgi-bin/CHOICE.EXE" method="post">
>     <p>
>     <label for="mccain">
>     John McCain: <input name="choice" type="radio" value="1" id="mccain" />
>     </label>
>     </p>
>     <p>
>     <label for="obama">
>     Barack Obama: <input name="choice" type="radio" value="2" id="obama" />
>     </label>
>     </p>
>     <p><input type="submit" /><input type="reset" /></p>
>     </form>
>      <p>
>        <a href="http://validator.w3.org/check?uri=referer"><img
>            src="http://www.w3.org/Icons/valid-xhtml10-blue"
>            alt="Valid XHTML 1.0 Strict" height="31" width="88" style="border: 0;" /></a>
>      </p>
>     </body>
>     </html>

### Example 3: Web Based Forum

- http://samanddeanus.no-ip.org/forum.htm
- http://samanddeanus.no-ip.org/reply.bas
- http://samanddeanus.no-ip.org/start.bas

Download a copy of this article: CGI_Part_2.rtf, or see Part 1

## Shuffling Algorithms

### Written by Samanddeanus

> "Algorithm -- a formal term for Al Gore getting his groove on."

There are different ways to randomly permute an array (shuffle a deck of cards).

One method -- Fifty-two pickup shuffle:

One way: write out all the numbers on punch cards. Someone drops the punch cards on the floor and then picks them and puts them in the card reader without sorting them.

Clearly, this is not the best method.

Bad method:

>     DIM A(1 TO 52)
>     FOR I=1 TO 52
>      A(I)=I
>     NEXT
>     FOR I=1 TO 52
>      N = INT(RND(1)*52)+1
>      SWAP A(I), A(N)
>     NEXT

This method is bad because not all permutations are equally likely: there are n^n different execution paths but only n! permutations (where n is the number of cards). n! is not a divisor of n^n so not all permutations are equally likely.

The simplest method is to assign a random number between 0 and 1 to every card and then sort the deck based on these random numbers. It is easy to see why this works: each number is equally likely to go to any position in the array. However, there is a faster way [O(n) vs O(n log n)]:

>     DIM A(1 TO 52)
>     FOR I=1 TO 52
>      A(I)=I
>     NEXT
>     N=52
>     DO
>      K = INT(RND(1)*52)+1
>      IF K<>N THEN SWAP A(K), A(N)
>      N=N-1
>     LOOP UNTIL N<2

Note that the first method might be slower then O(n log n) if the programmer uses a O(n^2) algorithm like bubble sort or insertion sort.

However, for a 52-card deck, it probably doesn't make much of a difference.

Download a copy of this article: Shuffling_algorithms.rtf

## The PImpl Idiom

### Written by stylin

> This article was originally posted on the c0de forums a few months ago. Stylin gave QB Express permission to republish all of his tutorials, so I figured I'd toss this one in for good measure!

> -Pete

Here's another technique that a few of you may be able to relate to: the PImpl Idiom.

The PImpl (Private Implementation) Idiom has the effect of separating an object class' implementation from its interface. A typical header file for a class T (T.bi) might look something like the following:

>     # include "StuffNeededForT'sPublicInterface.bi"
>     # include "StuffNeededForT'sPrivateMemberData.bi"

>     type T
>     public:
>     	' .. public member procedures ..
>     private:
>     	' .. private member data ..
>     end type

T exposes some public member procedures that need information from a header file. It also has private data that depends on information from another header file. Now consider if T's private member data changes for some reason - for example, it uses a set of pointers rather than a fixed-length array. What happens is the binary interface has now changed (T objects no longer have the same size). This means that modules that use T objects (include this header) must be recompiled to be compatible with the new changes.

The PImpl Idiom eliminates this worry, separating T's implementation from its public interface. Here's the above header using the PImpl Idiom:

>     # include "StuffNeededForT'sPublicInterface.bi"

>     type TPImpl as TPImpl_

>     type T
>     public:
>     	' .. public member procedures ..
>     private:
>     	m_pimpl as TPImpl ptr
>     end type

T now stores a pointer to an incomplete type TPImpl as its only private data member. This works because types whose definition is not known (incomplete types, TPImpl) can still be referenced (pointers of varying types are still the same size). The implementation (T.bas) might look like this:

>     # include "T.bi"
>     # include "StuffNeededForT'sPrivateMemberData.bi"

>     type TPImpl_
>     	' .. T's private member data ..
>     end type

>     constructor T ()
>     	m_pimpl = new TPImpl
>     end constructor

>     destructor T ()
>     	delete m_pimpl
>     end destructor

>     ' .. other public member procedure definitions ..

T objects create a new pimpl object upon instantiation, and destroy it when they are destroyed. Access to member data happens through the pimpl pointer. Utilizing the PImpl Idiom has a few benefits:

- implementation detail is further encapsulated where it should be - in the implementation. Users can make no assumption about how an object class is supposed to behave other than what it exposes publicly (and the egg-cellent documentation included).
- header files for private member data do not need to be included by user code. It's not really nice to force users into including something that they shouldn't even be concerned about.
- binary compatibilty remains constant through changes in the implementation. Pointers are the same size, so a change to an object class' implementation does not break binary compatibility - code that uses T objects need not be recompiled; as long as the interface remains the same, user code will still work.

This tutorial was originally posted on the the c0de Forum.

## Final Word

Well, that's it for another splendid little issue of QB Express! Sure the issues don't come out as frequently as they used to, but each and everyone is still just as good. It's a real testament to the QB and FB community that QB Express is still alive after four years -- easily the longest running and most productive QB magazine in history. You guys keep on submitting, and we have no choice but to release new issues!

Which brings me to my next point: We need submissions!

This magazine lives on tutorials, articles, reviews, editorials, interviews, comics, news briefs, letters to the editor, random little rantings, and the like...and without them, it can't exist.

This month, for the first time in QB Express' history, we're not going to have a deadline for submissions, and see how many of them still come in. In the past, we've always set a specific deadline, and it's provided motivation for people to get their articles finished and submitted. This time around, we're going to try a less definitive approach, and see if submissions still arrive. If not, we'll set a deadline and post it in all the forums around the QB/FB scene...but I'm hoping readers will see the value in submitting and do it without all of our constant nagging!

Thank you all for reading. As I pass by this herd of Tibetan yaks and heavy-cloaked herdsmen, who have never even dreamt that something like FreeBasic exists, I realize just how unique and special our little community is. And just like the Tibetans, and all the other tiny and unique communities around the world, we need to do everything in our power to keep the QB Scene alive for years to come.

Keep on codin'...END.

-Pete

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