Wayback Machine
Previous capture 26 Next capture
2007 2008 2009
4 captures
21 Aug 08 - 24 Jun 09
Close Help

PCOPY! Issue #70 ~ June 3rd 2008
Covering All BASICs

In This Issue:


 Regular Columns:
  From Our Editing Desk (Da Editors)
  Submitting to PCOPY! (MystikShadows & E.K.Virtanen)
  Letters To The Editors (Mixed Contributors)
  In The News (Mixed Contributors)
  Exit Issue (MystikShadows)

  Extreme Programming Evaluation And Review (MystikShadows)

  Interview With Roy Scott (E.K.Virtanen)
  Interview With Galleon (E.K.Virtanen)

 Tutorials & HowTo's:
  The DEF of the XBLite Programmer (Guy "gl" Lonne)
  Programming Simulations - Part 2 Real World Example (MystikShadows)
  Marrying YaBasic And Ubuntu (E.K.Virtanen)

 E.K. Virtanen
 Guy (gl) Lonné
 Roy Scott
 Date May 26th 2008


From the Editors: by Da Editors

Hello to one and all, here it is, at long last, Issue #70 fresh off the press!

Yes indeed, we're well aware of how long it's been since the last release of PCOPY! There was more than one reason for this delay. The first was contents both things we wrote and things contributed by others. We're thinking that spring isn't one of the best seasons for contributions. The other one, was a possible new template and style for this magazine (more on that later). But at long last, it's here.

In this issue E.K. really got busy and prepared us two interviews one from Roy Scott (who seems to be renowned all over the BASIC web, pretty much) and another from Galleon (who is getting renowned as we speak with his QB64 project). E.K. also managed to create a how to article about running YaBasic on Linux. Guy Lonné has his second instalment about the ABCs of XBLite (entitled DEF of XBLite, very fitting title hehe). I start my second part in Simulation series.

As a special note I'd like to thank Petr Schreiber for his efforts in correcting some of the submissions for spelling and other errors. Great work if I do say so myself.

Feel free to sit down at your favourite computer chair (yeah the one you're probably sitting on right now hehe) and let the reading begin!

PCOPY! Editors & Contributors

Submitting to PCOPY!: by Stephane Richard & E.K.Virtanen

As you probably noticed, we have a list of contributors. Everyone that submits something gets his/her name added to this list for the particular issue the submission appears in. We can't claim to know every single BASIC dialect out there nor can we claim to know how to program in all of them. There are just too many of them. Hence, this is an official invitation to those of you that do know a specific BASIC dialect well enough to write about it. Help us make PCOPY!, the most complete BASIC magazine there can possibly be by sending us submissions about them.

When we say submissions we mean anything that pertains to the specific BASIC dialect in question. Submissions can range from simple news item (a new version comes up, a new library is available and the likes), they can be personal reviews of a given BASIC interpreter/compiler, they can be tutorials, tips and tricks that shows readers how to accomplish a given task in the BASIC of your choice. The choice is yours. Submissions will help make PCOPY! even better than it is and the end result of that is that readers will have better BASIC related material to read in every issue that comes up.

So don't be shy, you know something others don't about a given BASIC, let us know about it, send us your submissions and we'll take it from there. If you're not sure how good writer you are don't worry, if needed, we'll edit and format the submission accordingly. So please, submit whatever you have time to write.

All submissions can be sent to pcopy.stuff@gmail.com and will typically be added in the issue that is currently being worked on at the time the submission is sent to us.

Letters To The Editors: By Mixed Contributors

Letter from E.K.Virtanen

Short Statement From The Editor Of The Last Issue.

For start, I apologize that I didn't do that .css what I did promise in last issue. I Know it would take maybe three or four hours to finish it, but I still haven't made it. Why so? Past months have been a real change for me. My loved one did born our firstborn for us, I finally got the spark and plan how I can fulfil one of my long lived dream osBasic and for last, I got total burn out with PCopy! e-zine. I know that last two reasons might not be good enough to fall with your promises but if I would go any deeper with these reasons, I would need to go way deeper than I am ready to do in this kind of public brief.

Anyway, this is first release after issue #20 which I haven't read before it is actually released, so I am really going to enjoy about this, hopefully you all too Smiley


Hello Mr. Virtanen.

There's something to be said about newborns. The first of which is that any amount of planning done before the child is born needs to be redone after the child is born. It never works hehe. A child basically makes its own schedule up and then the parents have to fit their time around that schedule best they can. Hehe.

So yeah, it's a very good reason indeed. So tell me, tell us all, when do you plan on teaching your newborn about HTML and CSS style sheets? Inquiry minds want to know! Hehe.


In The News:(Mixed Contributors)

sdlBasic 2'nd April 2008: Alcor 0.7 is out. Alcor is the next step of sdlBasic development this is a snapshot of the current preliminary and unstable version.

ASCII-World suffers for a bad karma. Currently all files hosted there are offline and hosting company seems unreachable. E.K.Virtanen is still trying but is ready to soon move everything to different hosting company.

SmallBasic and specially Palm version of it seems to worry some users at http://smallbasic.sourceforge.net forums.

thinBasic is about passion what we can see easily when we look at the released updates. thinBasic version released at 2008.05.15

osBasic demo2, a clone of classic tinyBasic written in FreeBasic released at 16'th May 2008. See post at Basic Programming forums

QBExpress #28 was released at 11'th May 2008. As commonly known, QBE has many interesting contents and it is worth of checking even if you don't use QB/FB. See more at petesqbsite.com

Brutus2D V1.8.3 released May 7, 2008.

22-Mar-2008 was the date when Basic4GL Version 2.5.3 released.

31-Mar-2008 we got more news about Basic4GL. Russian translation of Basic4GL help files was released.

FreeBasic 0.18.5b released at April 18th, 2008

John Spikowski posted about ScriptBasic 2.2 Release Goals at Apr 26'th, 2008

RunBASIC.Net opened. Site gives an easy way to bring RunBASIC applications online.

AutoIt(freeware BASIC-like scripting language) v3.2.12.0 released 16'th May, 2008

FREE Basic Script Language v4 topic started at May 13, 2008.

Ocean Basic project is back online! Bit old news since site has been up since January 20'th, but better late than never.


Extreme Programming Evaluation And Review: by MystikShadows


If you're in the field of software development and/or software engineering you've probably heard, one way or another, about Extreme Programming. Extreme Programming can be considered more of a work ethic than an actual Programming paradigm in that it instates many control process in every day programming tasks.

Extreme Programming is one of the newer software engineering methods (Founded in 2001) developed by Kent Beck (One of the original 17 signatories in the Agile Manifesto). Its track record, after eight years of usage scenarios, is actually quite successful. Many companies attribute to the XP Principles which are geared towards customer satisfaction and rapid response to change.


Extreme Programming is a software engineering discipline that is designed, from the grounds up, to allow flexibility in design, programming and testing in such a way that it can respond quickly to the changing requirements of customers. This can even happen late in the life cycle of a software development project and doesn't promote the creation of the classic notion that is patch development.

At the same time, Extreme Programming follows the principle that two heads are often better than one in that paired programming is highly encouraged in software development efforts. It has roles for users, designers, developers that allow them to work closely with each other which help in the way the methodology responds to changes in a design and in the resulting application.


Extreme Programming is entirely governed by a set of preset rules which when used together is designed to optimize the time spend on every aspect of software development. The rules are broken down into four phases as follows:

  • PlanningA
    Of course, the planning stage is the beginning of any software development project. In the classic sense of the word, the planning phase is where meetings take places, needed forms, documents, dossiers are collected for the purpose to be understood and implemented (further down in the design and coding phases). This is where it all begins. The Extreme Programming rules for this phase are:

    • User Stories are written.
    • Release planning creates the schedule.
    • Make frequent small releases.
    • The Project Velocity is measured.
    • The project is divided into iterations.
    • Iteration planning starts each iteration.
    • Move people around.
    • A stand-up meeting starts each day.

  • Designing
    At the design phase, most needed information is acquired, catalogued and referenced for the purpose of being taken, one at a time. At the design phase, there are usually two or three parts to consider. The first being the data entry forms. This is where data validation rules are determined for example as well as the data types that are to be used for the processing of the values. The second is the actual work (processing) to be done with the information provided. Does it need to be saved, is it used in search criteria on another form, is there any relationship between this form and the previous/next form in the list and so on. The last (not applicable to all forms necessarily) is the expected output of a given form. Is it input data for another process, is it a record in database file (or multiple database files). All these are accomplished using one or more design tools such as Data Floe Diagrams (DFD), Perhaps UML if OOP is to be used and so on. The rules that imply to designing are:

    • Simplicity.
    • Choose a system metaphor.
    • Use Class, Responsibility and Collaboration (CRC) Cards
    • Create spike solution to reduce risk.
    • No functionality is added early.
    • Refactor whenever and wherever possible.

  • Coding
    Again, in the classic sense of the word. All the charts, diagrams, DFDs are done at this phase, it's time to implement the solution using the programming language and programming paradigm that has been defined prior to the start of the coding phase. In XP it means that two coders will be working on the solution. Paired programming is the fastest way to get a unit out the door. One codes it, one tests it and reports problems. This team work goes on until the end of the project. More than one pair of programmers can of course work which means that different parts of the program can get done faster. The rules for the coding phase are:

    • The customer is always available.
    • Code must be written to agreed standard.
    • Code the unit test first.
    • All production code is pair programmed.
    • Only one pair integrates code at a time.
    • Integrate often.
    • Use collective code ownership.
    • Leave optimization till last.
    • No overtime.

  • Testing
    It's true that at least some testing has been done at the independent unit level during the pair programming session. Because in XP the test units are written first and then the actual module is run against the test units to evaluate if it works as expected at the coding phase. Since these 4 phases apply to smaller iterations of the big project a final test against the test units are done at the end of coding phase just to be sure that an integrated iteration is causing a problem somewhere else in the project. The rules for the testing phase are:

    • All code must have unit tests.
    • All code must pass unit tests before it can be released.
    • When a bug is found tests are created.
    • Acceptance testing is run often and the score is published.

As you can see here this rather short list of rules (compared to some other methodology) is actually surprisingly simple. Likewise, the relationship between each step in each part of the development phase as well as the relationship between each of the phases themselves all contribute to providing a fast changing working environment that can easily, when all elements are present, adapt to any new situation, change, additions because everything and everyone as so closely related to the outcome of the software development process.

Based on experience and projects that were created using Extreme Programming, projects that are object oriented in nature are typically better managed because the object often represent a great complete functional iteration that is self sufficient and easy to create test units for as independent iterations. However, modular projects when organized accordingly can play the same role so Extreme Programming is good for all kinds of projects.


Extreme programming is roughly about 8 years old (at the time of this writing) and although computers and computer programming are usually rapidly changing to adapt to new reality of the hardware and the increasing needs of the users, in the software engineering world, 8 years makes extreme programming rather new compared to other methodologies. As such, Extreme Programming has accumulated rumours along the way as it tries to make its way into the software engineering methodologies. In the last revision of the SWEBOK (The SoftWare Engineering Body Of Knowledge) Extreme Programming was not added to the body of knowledge. Perhaps it will make it into the next revision as it continues to be used successfully in more and more types of projects.

Let's take a look at some of the more widespread rumours about Extreme Programming that might explain why it was not voted in the SWEBOK reference:

  • Extreme Programming lacks some major organization:
    To the eyes of software engineers this is the most widespread, because of the tight practices of extreme programming it is often accused of not seeing the bigger picture of the project because programmers seem to be working on all parts of the project which they believe makes it hard to keep track of what exactly gets done. However, Extreme Programming is all about measuring actual work done, about giving fast feedback to the customers so that they can see what's going on more often and be able to play a role in what's to be done. If something needs to be changed, having the customer right there helps in knowing that in the first place as well as what the changes should be. Often a reality can change right in the middle of a project, not because of the customer per se, but rather because standards and other factors influence or categorically change what is expected of a current functionality. The ability to change to accommodate this new reality is one of Extreme Programming strength.

  • Extreme Programming is not good for every project:
    What software methodology is? When this rumor was raised, Extreme Programming was but a few years old. It wasn't used in many projects because it was a brand new method. This rumor today is proving to be wrong. Indeed Extreme Programming practices seem to offer concrete advantages on more and more different types of projects. This includes games, compilers, business applications, tools and utilities, reporting techniques and more. Is Extreme Programming the perfect methodology for all types of projects? Only time will tell, but it's clear that Extreme Programming today is making its way towards that goal more and more with every project that it is used for. This is independent of industry as well. Scientific, medical, telecommunications, stock market are all fields extreme programming as been used with a rather good rate of success. And all this is helping it become more and more popular, which then gives it better reasons to be used in upcoming projects as it makes its reputation one project at a time. We'll see where Extreme Programming stands in another five years.

These are the two major rumours. There are more of course, Also, many existing rumours were created because Extreme Programming was not known or used. Hence, people didn't understand what it was all about. Extreme Programming has failed in some projects. However, the story doesn't say that extreme programming itself failed or if the group of developers that tried to use it failed at using it the right way (since some of the notions of extreme programming are very different from the conventional programming practices it's quite possible that some of it was too different and therefore the people trying to use it couldn't part themselves that far away from the ways of software engineering they already knew). After 8 years of existence, I'd be curious to see how Extreme Programming would do if it was to be used on the exact projects where they were deemed a failure especially now that extreme programming rules and principles are probably more understood than it was when these projects failed.


The best advice I can give you is to use the reference links I provided below and read about Extreme Programming. See what you can make of it, create your own conclusions and make your own opinion about it. As far as I'm concerned I like what Extreme Programming is all about. Not just because it's a brand new methodology (a new methodology is probably long overdue in the software engineering field) but because of the way that even if a rather big group of people are involved in a given project, Extreme Programming really seems to allow to shift the project around, remove or change existing functionality with minimal impact on other existing functionality since testing is performed before, during and after each of these changes.

All in all, Extreme Programming is proving itself successful on big projects. Since these big projects are the projects that represent the biggest time and money investments it's only natural that this be the first place where the rate of success can be quantitatively measured and seen. If you have 2 or more people (an even number of programmers works best for pair programming) any project, whether commercial or personal should benefit from the same advantages that the bigger projects have seen. In fact, in a smaller group of developer it is probably easier to maintain a tight control over the development of rugged test units and functional code for a given project. But don't take my word for it, take a look around, read and learn about Extreme Programming, find it where it's been successful, where it failed and why. And then decided of extreme programming is for you.


Here are links of websites I've used throughout this evaluation document. You can find a whole lot of details, explanation and examples concerning the Agile Methodologies and more specifically about Extreme Programming.

  • The Agile Manifesto
    This is the main website of the original and maintained Agile Manifesto. Where you can learn about the Agile Methodologies of software engineering as well as the founders of the Agile method.

  • Extreme Programming
    This is the website where learning about Extreme Programming begins. They cover what Extreme Programming is, when it can and should be used as well as many definitions of everything that Extreme Programming entails.

  • The Software Engineering Body Of Knowledge
    This website is where you can read about and get the guide to the SoftWare Engineering Body Of Knowledge reference. This represents one of the greatest efforts at taking everything there is to know about Software Engineering, categorizing and cataloguing them all into one central reference.


Interview With Roy Scott: by E.K.Virtanen

Roy Scott probably doesn't need much of an introduction in the world of basic compilers and interpreters today. Sooner or later you've come across his website and/or posts on some forums somewhere at some point if you program in BASIC. He's most renowned for his Roy Scott Free Site. Bottom line, Roy Scott is a veteran micro developer that knows his way around many languages and many types of programming projects. Here is an interview I did with Roy to help you learn a bit more Roy Scott as a programmer and as an individual.

Q: Let's start with the "stats". Who, what and from where?

A: My name is Roy Franklin Scott. I was named by my father for his two favorite people--Roy Wollomes his longtime boss and a county supervisor. I got the Franklin from President Franklin Roosevelt who was in office when I was born. I am 70 years old and live in Bakersfield California where I was born in 1938.

I had a varied career in the newspaper, publishing and printing trades for most of my life. In 1975 I became interested in personal computers when Tandy Radio Shack came out with their TRS-80 Model I. This was a cranky and quirky little beast the appeared on the market sometime after the original Apple computer. I used this to computerize my business. This was a printing business located in Newport, Tennessee where I was living at the time.

When I sold this business and returned to California I worked for awhile in the printing trade and then went into the computer field working with an IBM System 38 for the daily newspaper here in Bakersfield. When this newspaper began to expand their use of networking and personal computers using the original IBM PC, I was placed in charge of this part of their operations. I learned repair and maintenance by doing it on these machines and was schooled as a Novell Network Engineer. I was soon handling a network of 450 PCs.

When the company jumped on the popular downsizing bandwagon, I took a buyout and started my own PC repair, maintenance and sales business that I operated until I retired. My first customer was to contract back these operations (except sales) to the company that I had worked for.

Q: You maintained original Programmers Haven website and you are still hosting a site about articles you had there. Is it Basic programming or programming in general which is close of your heart?

A: During my professional programming career I used Turbo Pascal as my programming language of choice. I wrote several large program systems and many small one, some of which are still in use today. Now that I am a hobby programmer, I use BASIC and BASIC like languages since Turbo Pascal is no longer really supported.

I had earlier in the 1970s used various BASICs at the start of my interest in programming. So when I switched back to Power BASIC as my main language it was not a hardship to relearn the use of it. For Windows programming I prefer RapidBatch. Although this began as a compiled batch language system, today it is much more and very BASIC like in many ways. I have maintained my interest in Batch languages and programming since the 1980s.

My current web site, although it does contain downloads of the articles from my former web site, is actually oriented toward languages and compilers that I have free distribution rights to. By the way the name of my former web site was "Basically Programming" of which "Programmer's Haven" was the forum part of the operation. Basically Programming (note the lower case spelling of basic) was oriented toward the "basics" of programming--not specifically the BASIC language.

As a retired administrator of the current Programmer's Haven forum, I maintain an active interest in it and many other forums oriented toward BASIC and other languages. I keep track of many freeware, open source and small commercial programming projects, languages and compilers as well as I can.

Q: In generally, when you compare the whole computer industry back from 70's and 80's to modern day, has evolution gone in right direction? Before we had more choices (Commodore, Atari, MSX, Spectrum etc.), today we have practically PC and Mac only. Is this a good move or do you think less platforms is less developing and innovations?

A: The following information should be taken with the proverbial "grain of salt". The opinions expressed are personal and very subjective that have been formed with 33 years of experience in the field.

In general my feeling for some years now is that we have been taken down a dead end road with Windows. While there is no doubt that Microsoft is probably the greatest sales organization that the world has ever seen, my opinion of their ability to program and provide an operating system that works consistently and well is much less favorable.

I feel that many better operating systems and much better computer hardware systems that were available to the general public have fallen by the wayside--crushed by the wheels of "progress". It is also my opinion that the straight jacket of using the Windows API has stifled programmer creativity to a degree that I would not have thought possible only a few years ago.

Twenty years ago, as programmers, we were demanding standardized methods of doing programming tasks. Now we have it and I for one do not like it. It is proof of the old saying, "Be careful what you wish for--you may get it."

On the other hand, for the more casual to intermediate user, Windows has been a boon and in general increased their productivity greatly despite the annoyance provided by "glitches" in the operating system.

The Mac system is widely used and well liked in the publishing and graphics fields. Users of this system are so rabid in their support that it almost appears to be a religion. This system though does not appear to provide a viable alternative to the PC system either in number of users nor the ease of use for the general public.

Linux, an excellent operating system, appears to have found its home as internet servers. I do not believe that it provides a viable competitor to Windows on the desktop.

Personally I mourn the loss of the many excellent hardware and software systems that have disappeared from the world. It has greatly limited our freedom of choice in the field.

Q: What kind of dangers do you see in a fictional, world that has only a single computer- and operating system? Something good too perhaps?

A: A single computer type and single operating system world would not only be dangerous in that there would only be one source for each, but would also be very boring and limit innovation in both fields. The only good thing about it that I can see is that there would be no problem with cross platform compiling of programs.

Q: Time to time there is talk in the air about how there are too many programming languages. Do you see there is too much different type of programming languages, or you think there is room for even more new languages?

A: I have no problem with new or the current number of programming languages. There are several reasons for variety in programming languages. Different languages serve different purposes for programmers and they also are chosen by programmers for their suitability to the individual programmers style of working. I am perfectly happy to let the market decide what languages will be the most popular.

Q: From your point of view, what was/is/is going to be, a computer revolution? Or is there more than just one perhaps?

A: The first computer revolution was in word processing and typesetting. The personal computer in a very short time during the dawn of their use completely replaced the typewriter and shortly thereafter typesetting for publications.

The second revolution was when the Mac computer took over the graphics world. Artwork creation, photo editing and graphics setups for publications and TV advertising.

The third revolution was with the public advent of the internet. This made world wide information storage and retrieval a reality for everyone that had access to the net.

The next revolution is now brewing in a science lab in Switzerland. Called "the grid", this new system has the possibility of increasing internet speed by a factor of 10,000 if early reports are true. It may however be several years before this will be usable by the general public. It will require a tremendous investment in new hardware and most of the present cabling will need to be replaced to take full advantage of it.

Q: For some reason, I have wanted to ask this from you for a long long time. Now I got opportunity for it: What kind of feelings and thoughts does names "David Ahl" and "Creative Computing" bring in to your mind?

A: Although these names are familiar to me of course, I have never had any interaction with either of them.

Q: I have also received two questions for you from third person. I'll paste them here too.

1Q. It's obvious technology moved forward, computers can do more things faster with more ram bigger hard drivers faster internet and the likes. No denying that. But some people feel that the rest of the computer industry (software, hardware manufacturers, and so on) are going backwards, they're not taking all this technology in the right direction. Looking at computers how they were back in 1970s and how they are today, is there anything he would have done differently and where would he like to see all this technology go in the future?

1A: In my opinion, the technology we are so fond of has developed at such a breakneck pace that no particular part of it has ever been fully exploited or properly utilized before "leapfrogging" to the newest and greatest thing on the horizon. I feel that this has resulted to a tremendous waste of money and resources in the field.

2Q. Today many hardware manufacturers seem to make windows exclusive hardware (the winmodem for example works only in windows, many video cards and sound cards as well). Do you think having this windows only hardware is an actual advantage to Microsoft (IE does it help windows work better or is this something that could have been done without needing to have windows specific hardware)?

2A: My feeling is that the creation of Windows specific hardware is done for commercial reasons.

Such hardware is cheaper to manufacture and quite possibly allows a greater profit margin for the maker. It should also be of benefit to the OS maker since it allows them to create drivers more easily to a specified interface.

It seems to me that the problem arises due to bundling of the OS to PCs sold. If the PC maker bundles Windows with their units and uses Windows specific hardware in the PC then the buyer is locked into the Windows system unless they want to replace both the OS and all the hardware that is Windows specific. This limits the choices of the buyer. The same could be true of other OS bundles that use OS specific hardware.

I much prefer more generic types of hardware that can be utilized with almost any OS that the user may prefer.

Q: If you now look back a bit, is there some certain basic dialect that has special place in your thoughts?

A: I have used many varieties of BASIC from the first ROM BASIC furnished with the Radio Shack TRS-80 Model I that began my experience with personal computers. (I believe that this was one of the early ones written by Bill Gates and associates.)

My favorite and one that I still use is Power Basic for DOS version 3.5. I have also used the Windows and console version of this BASIC. There are also several very interesting add on libraries for PBDOS. We have been promised a version 4.0 of this BASIC. However, with the long time that has elapsed it is beginning to look like the chances for this are very dim.

Q: In generally speaking, how you see Basic genre and programming with all those dialects today? What do you think that "BASIC" is or it should be?

A: I think that BASIC is as it should be with some improvements possible as we go along. As it stands today there are many fine varieties available that meet the needs of almost any programmer.

Q: We know there are your friends reading this interview too. You want to say "hi" or something for them? Any greetings?

A: The friends that I have gained in hobby programming on the internet are too numerous to mention here so I will just say Hi to all of them. I am very grateful for their support and help now and during my tenure as a web site and forum administrator. They are the one who made it successful.

Interview With Galleon: by E.K.Virtanen

I'm not sure how many of you have heard of Rob (Galleon is his nickname). But you might know of some of his projects, the current project is called QB64 and aims to present programmers with a QB clone language that is capable of running in all modern Operating Systems (Such as Windows XP, Vista and Linux). This project can be followed in this sub forum on The QBasic Forum Community. Here I interviewed Galleon to present this individual to you and let him talk about himself. As the old saying goes, you can only get the truth about someone by asking that person the questions, which is what I did, right here.

Q: Let’s start with the "stats". Who, what and where?

A: What?
QB64 is a programming language designed "from the ground up" to be 100% compatible with QB4.5/QBASIC. It will also extend upon this compatibility to support: -Using all available memory
-External libraries
-New data types (64 bit integers, etc.)
-Better graphics (.bmp, .jpg, etc. and 3D via OPENGL)
-Better audio (wav, midi, mp3, etc.)
-Better input methods (mouse, joypads, web-cams, etc.)
-Networking (TCP/IP, etc.)
-Unicode support
-and more!

The QB64 compiler converts BASIC code into C++ code, and then uses a third-party C++ compiler (GCC) to compile the C++ code into an executable file. C is an "enduring", processor independent language and ensures QB64 will be compatible with most OSs for many years to come. The actual compiler is written in BASIC! So QB64 compiles itself (self-compiles), also ensuring future compatibility.

I, Rob (aka. Galleon), from Sydney Australia am developing QB64 independently atm, however I am lucky to have the support/help of the QBASIC community who report problems and provide guidance/ideas. Later this year QB64 will become fully open source (atm only the inbuilt C++ code/functions are, not the compiler itself) after I have included user defined types and other critical essentials.

1. Running QBASIC programs is becoming increasingly difficult on modern OSs. DOSBOX is fantastic; however it runs programs slowly and provides little/no possibility of extending/upgrading programs to take advantage of modern systems.
2. The preservation of the QB language and its many many programs.
3. More speed.
4. Portability. QB programs are not easy to run on Linux or Mac/OS X. QB64 uses multi-platform C libraries which make this easy.

Q: Uh! You just answered in to my next 5 questions at once :) World is full of Basic dialects what can do same than you just told. Some of them are very close of QB syntax. When you are working with QB64, do you feel like you are doing the job for hardcore QB fans or/and possibly extending life of this legendary compiler?

A: QB64 is about the past, present and future of QBASIC. It is designed to run all existing programs, provide avenues for QB fans to distribute their work and provides a range of new, easy to use high level commands for use with modern technology. It's not just for hardcore QB coders, it's also for those who find a QBASIC program on the net and want to run it without any hassles. One important goal of QB64 is to run all QBASIC programs without any modifications required to the original code.

Q: There is a bunch of QB'rs waiting for this software to get finished. You ever feel that pressures are too high?

A: Pressure? I don't really think of it as pressure, probably because I'm just as excited about getting QB64 to each new milestone as everybody else. I think progress is important, but sometimes perceived progress and actual progress can differ, and when that's the case I try to throw in a few "fun" things. I also think cutting corners is extremely dangerous when developing a programming language; ultimately they lead to having to recode lots of things again. Being only human, other priorities pop up from time to time, but I am very passionate about this project. After the QB64 compiler's source is released later this year my role in QB64's development will undoubtedly change significantly.

Q: Have you ever thought a future, life after releasing QB64 as open source? Is there motivation to program smaller projects (such as games) or is developing QB64 all and everything?

A: I doubt my work and input into QB64 will ever be finished, though as years go on the intensity of that work will slow down. I've already got plans to port a (C++) MMORPG I wrote into QB64 to make it more manageable, but this is dependent on the implementation of many advanced features in QB64 first. As for QB64 being all and everything for me, it certainly feels like that at the moment.

Q: I have received three questions from a third person for you. I’ll paste them here.

1. Does he already have a plan made for an IDE for QB64 or is he open to suggestions? Does he have requirements IE does it have to be made in qb64 (It would be interesting if it was, but is it a prerequisite) :-).

A1: I will be developing an IDE for QB64. Essentially, it will be 2 modules which can optionally be built with the compiler itself. The first module will control how the IDE looks and the interface, the second module will be used to communicate between the "interface" module and the compiler itself. The benefits of doing things this way is a) As the compiler advances, the IDE need not be continuously updated to recognize new features. b) The IDE and the compiler can interact throughout all stages of compilation (including pre-compilation & syntax checking). c) Multiple IDE "interfaces" can easily be made (I intend to write a "classic" one which will look and feel like QBASIC). Of course, it will still be possible to use general IDEs designed to compile a variety of languages with QB64's compiler.

2. What does he believe it will represent (work wise) when he starts porting this to other OSes? Did he make efforts so far to keep the code as portable as possible and can he pinpoint where the concerns are in the code base?

A2: QB64 will port very easily to Linux and Mac and many other OSs. For starters, there is no assembly code, it is pure C++. Secondly, only multi-platform libraries which support Windows, Linux and Mac have been chosen. There are some minor changes that will have to happen (like MessageBox, which displays an error message in a separate window being a Windows specific command), but we are just talking about a few #ifdef changes. There's debate over the SHELL command and whether its parameters should be interpreted or not so that a Windows DIR command would work on a Linux/Mac machine.

3. What kind of first big program or game would he like to do or see done when QB64 hits the mainstream? Would he want that done as a sign of QB64's capabilities? Or just out of personal challenge?

A3: At first, I'd be very happy to see many existing QBASIC programs/games being improved to take advantage of the new possibilities QB64 offers, this would of course showcase QB64's capabilities (Net Nibbles anyone?). As for the first large project in QB64, I'd like to hope someone else will produce that. QB64 is after all, my "Magnum Opus". In terms of what I'd like to see that person produce, I hope it will be the sort of program which is unique and easy for new programmers to "tweak" and learn from.

Q: In generally speaking, how you see Basic genre and programming with all those dialects today? What do you think that "BASIC" is or it should be?

A: I began programming in GWBASIC after a friend (whose father was a computer programmer) showed me a program that displayed a cake and played happy birthday. My grandfather had recently purchased a new PC which came with a GWBASIC manual too (you don't get those with your OS today!) and this allowed me to self-teach myself programming at a very young age. The school micro-bees also got a good work out, whether they had a green or orange screen. For me that's what BASIC should be, so simple a child (with the right amount of enthusiasm) can program in it. With this in mind I feel that more modern versions of BASIC (like Visual Basic) are far too complex for beginners. VB confronts you with a zillion options and it can be difficult for new programmers to understand how to get the toolbar-selected objects to interact with each other. There are of course, many derivatives of BASIC each with a particular focus. QB64's focus is on QBASIC compatibility and extending this capability. Which BASIC you use depends on what you want to achieve.

Q: You want to send any greetings to someone(s) now at the end of this interview?

A: I'd like to thank everyone who has helped in the development of QB64 so far. To name a few; MystikShadows, Qbguy, Mac, Rpgfan, Dav, Roy, Mennonite, The PhyloGenesis, Pete, Computerghost, Clippy... there are of course many more. QB64 development could not have progressed as quickly as it has without your enthusiasm and encouragement. QB64 could not have been this stable without your testing and feedback. Nor could it have run on all versions of Windows if I was not alerted to several incompatibilities between windows versions. I love your INPUT! Finally, thank you E.K.Virtanen for giving me the opportunity for this interview. It is the efforts of people like you who truly keep BASIC alive!

It was nice to interview you Galleon, thank you.


The "D.E.F." of the XBLite Programmer: by Guy (gl) Lonné


This article is the sequel of the article "The ABC of the XBLite Programmer": the exposed concepts are pushed one step further. However, you need to read first the "ABC” article otherwise this "DEF” article will not make sense to you.

Math statements

As seen previously, the division is the more complex arithmetic operator to put in use because of the divide-by-zero risk and also because it gives both a result and a remainder.

With what we already know, the remainder is computed as follows:

result = number / divider
remainder = number - (result * divider)

However, if result can be discarded, the same can be achieved with the operator MOD:

remainder = number MOD divider

In my recent developments, I used MOD in these 2 cases:

Example 1: Make a running index wrap around Stepping thru an array, I had to wrap around when exceeding the upper bound.
I first coded:

INC index
IF index >= indexSup THEN index = 0

Then, I replaced it by:

INC index
index = index MOD (indexSup + 1)

Gotcha: index off by 1

Since MOD returns a number between 0 and divider minus 1, you have to use index MOD (indexSup + 1), otherwise index will never reach indexSup but (indexSup - 1) (the "off-by-1" bug).

Example 2: Is yyyy a leap year?

A leap year has a 29 day March, when the others have only 28 days in March. In the Gregorian calendar, a leap year occurs generally every 4 years, skipping secular years.

Is leap a year, which is:
1. a multiple of 4, if not ended by "00",
2. a multiple of 400, if ended by "00".

This is when MOD does a great job:

reminder = yyyy MOD 4
IF reminder THEN ' not a multiple of 4
  bLeapYear = $$FALSE ' not leap
  reminder = yyyy MOD 100
  IF reminder THEN ' not a multiple of 100
    bLeapYear = $$TRUE ' leap
    ' multiple of 100 (secular year)
    reminder = yyyy MOD 400
    IFZ reminder THEN ' multiple of 400
      bLeapYear = $$TRUE ' leap
      bLeapYear = $$FALSE ' not leap
    END IF

Question: Was 2000 a leap year? (Answer: yes!)

Gotcha: Never divide by zero (the old nasty bug) Always guard from dividing by zero. In doubt, test for a zero divider:
IFZ divider THEN
  ' error: division by zero
  remainder = number MOD divider

Decisions: Short forms of IF
XBLite's short forms of operators make more compact programs and faster coding.
Here are these time-savers:

- IFZ <=> IF 0 ==
- IFF <=> IF $$FALSE ==, or IF NOT

My rules of thumb regarding Short Forms of IF

I always use IFZ, but never IFF: testing a zero value seems "natural" to me but not to test a false condition; if I have to, I use IF NOT instead of IFF since it stands out and yells "Warning, false condition!" in a code review when IFF barely draws attention.

Decisions: Complex conditions (&& and || operators)

To build a complex condition, combine the individual conditions with the logical operators: logical and (&&), logical or (||). You can easily spot the logical operators because they are doubled: &&), ||, and even == (always shortened = in practice).

Example: Is yyyy a leap year?

bLeapYear = $$FALSE ' not leap
IFZ (yyyy MOD 4) THEN ' multiple of 4
  IF (yyyy MOD 100) > 0 THEN
		bLeapYear = $$TRUE ' leap
		IF ((yyyy MOD 400) = 0) THEN bLeapYear = $$TRUE ' leap

Gotcha: Never use the bitwise operators to combine logical conditions

You have to use && and || in an IF (complex condition) THEN. AND is the bitwise and operator, OR is the bitwise or operator.

Idiom: Using addition instead of && for testing a resulting zero condition
XBLite makes it easy to test a zero value with IFZ:

bLeapYear = $$FALSE ' not leap
IFZ (yyyy MOD 4) THEN ' multiple of 4
  rem100 = yyyy MOD 100
  IF rem100 THEN bLeapYear = $$TRUE ' leap
  IFZ rem100 + (yyyy MOD 400) THEN bLeapYear = $$TRUE ' leap

Multiple Decisions: SELECT CASE TRUE

A series of IF's are better replaced by an equivalent SELECT CASE TRUE (for my taste). This statement is specific to XBLite and is incredibly handy to handle sequential conditions.

Example: Is yyyy a leap year? (final version)

  CASE yyyy MOD 4 ' not a multiple of 4
bLeapYear = $$FALSE ' not leap
CASE yyyy MOD 100 ' not a multiple of 100
  bLeapYear = $$TRUE ' leap
CASE yyyy MOD 400 ' not a multiple of 400
  bLeapYear = $$FALSE ' not leap
CASE ELSE ' multiple of 400
  bLeapYear = $$TRUE ' leap

Gotcha: The conditions are sequentially tested

the conditions are applied one by one, from the first condition towards the last, until there is a TRUE condition:

1. the first condition is tested; if true, process and exit the SELECT CASE
2. the second condition is tested; if true, process and exit the SELECT CASE
... n. the CASE ELSE (if any) is processed since none of the above conditions were TRUE.


Array declaration

XLONG myLongArray[upper bound]
STRING myStringArray[upper bound]

Gotcha: DIM redeclares an array and resets its contents

At run-time, DIM clears an array and redefines its upper bound:
DIM myArray[new upper bound]

If you want to preserve the array contents, use instead:

REDIM myArray[new upper bound]

Idiom: Test if an array is empty

IFZ myArray[] THEN ' array is empty!

This is the short for:

upp = UBOUND (myArray[])
IF upp < 0 THEN ' array is empty!

Gotcha: empty array

An empty array has an upper bound of -1.
A non-empty array index starts at 0 (never 1) and runs up to its upper bound, inclusively; its upper bound shows between the brackets: myArray[upper bound].

Idiom: Testing if array myArray[] is empty

IFZ myArray[] THEN ' array myArray[] is empty!

This is the short for:

upp = UBOUND (myArray[])
IF upp < 0 THEN ' array myArray[] is empty!

String Operations

XBLite's string handling is both complete and convenient. A string can be manipulated both as an array of characters and as zero-terminated for C's compatibility.

However, I never manipulate a string as a character array: XBLite offers a rich set of string functions and these functions will never cause a program crash.

Explicit String Declaration

STRING myString ' string
STRING myStringArray[upper bound] ' array of strings

I always prefer to use implicitly declared strings (text$ = "some text"), but you must declare explicitly the arrays:

STRING dayOfWeek$[6] ' declares an array of day's names
dayOfWeek$[0] = "Monday"
dayOfWeek$[6] = "Sunday"

You might prefer the all run-time alternative:

DIM dayOfWeek$[6] ' array of day's names
dayOfWeek$[0] = "Monday"
dayOfWeek$[6] = "Sunday"

String functions

Let's do some string operations:

myString$ = "12345"
? "myString$ is "; myString$

prints "myString$ is 12345”

Note: ? is the short form of PRINT.

- LEN (myString$): length of string myString$

? "Length is"; LEN (myString$)

prints "Length is 5"

- LEFT$ (myString$): first character of string myString$

? "First character is "; LEFT$ (myString$)

prints "First character is 1"

- LEFT$ (myString$, cChar): cChar leading characters of string myString

cChar = 3
? cChar; " leading characters are "; LEFT$ (myString$, cChar)

prints " 3 leading characters are 123"

- RIGHT$ (myString$): last character of string myString$

? "Last character is "; RIGHT$ (myString$)

prints "Last character is 5"

- RIGHT$ (myString$, cChar): cChar trailing characters of string myString$

cChar = 2
? cChar; " trailing characters are "; RIGHT$ (myString$, cChar)

prints " 2 trailing characters are 45"

- LCLIP$ (myString$): clips off the first character of string myString$
LCLIP$ (myString$) is a short form of RIGHT$ (myString$, LEN (myString$) - 1)

? " 4 remaining trailing characters are "; LCLIP$ (myString$)

prints " 4 remaining trailing characters are 2345"

- LCLIP$ (myString$, cChar): clips off cChar leading characters of string myString$
LCLIP$ (myString$, cChar) replaces RIGHT$ (myString$, LEN (myString$) - cChar)

cChar = 2
? LEN (myString$) - cChar; " remaining trailing characters are "; LCLIP$ (myString$, cChar)

prints " 3 remaining trailing characters are 345"

- RCLIP$ (myString$): clips off the last character of string myString$
RCLIP$ (myString$) replaces LEFT$ (myString$, LEN (myString$) - 1)

? " 4 remaining leading characters are "; RCLIP$ (myString$)

prints " 4 remaining leading characters are 1234"

- RCLIP$ (myString$, cChar): clips off cChar trailing characters of string myString$
RCLIP$ (myString$, cChar) replaces LEFT$ (myString$, LEN (myString$) - cChar)

cChar = 2
? LEN (myString$) - cChar; " remaining leading characters are "; RCLIP$ (myString$, cChar)

prints " 3 remaining leading characters are 123"

- subString$ = MID$ (myString$, pos): extracts a sub-string from myString$ starting from character at position pos.
MID$ (myString$, pos) "replaces" RIGHT$ (myString$, LEN (myString$) - pos + 1) or LCLIP$ (myString$, pos – 1).

pos = 2
? LEN (myString$) - pos + 1; " remaining trailing characters are "; MID$ (myString$, pos)

prints " 4 remaining trailing characters are 2345"

- subString$ = MID$ (myString$, pos, cChar): extracts cChar characters from myString$ starting from character at position pos

pos = 2
cChar = 3
? cChar; " characters starting position"; pos; " are "; MID$ (myString$, pos, cChar)

prints " 3 characters starting position 2 are 234"

- pos = INSTR (myString$, searchFor$): look for a sub-string in myString$ starting from the first character

searchFor$ = "45"
pos = INSTR (myString$, searchFor$)
? "Sub-string "; searchFor$; " found starting position"; pos; " ==> "; MID$ (myString$, pos, LEN (searchFor$))

prints "Sub-string 45 found starting position 4 ==> 45"

searchFor$ = "8"
pos = INSTR (myString$, searchFor$)
? "Sub-string "; searchFor$; " not found (position ="; pos; ")"

prints "Sub-string 8 not found (position = 0)"

- pos = INSTR (myString$, searchFor$, start): look for a sub-string in myString$ starting from the character at position start

searchFor$ = "45"
pos = INSTR (myString$, searchFor$, 2)
? "Sub-string "; searchFor$; " found starting position"; pos; " ==> "; MID$ (myString$, pos, LEN (searchFor$))

prints "Sub-string 45 found starting position 4 ==> 45"

start = pos + 1
pos = INSTR (myString$, searchFor$, start)
? "Sub-string "; searchFor$; " not found when searching from position"; start

prints "Sub-string 45 not found when searching from position 5"

- prefix R (RINSTR): reverse search

pos = RINSTR (path$, ".") ' look for the file extension

- suffix I (INSTRI): search case insensitive

pos = RINSTRI (path$, ".bat") ' look for a batch

These functions are safe: you will never crash even if you go outside string's boundaries.

- lowCase$ = LCASE$ (myString$): changes all characters from myString$ to lowercase

myString$ = "WAS UPPERCASE"
newString$ = LCASE$ (myString$)
? "original string: "; myString$; ", new string: "; newString$

prints "original string: WAS UPPERCASE, new string: was uppercase"

- uppCase$ = UCASE$ (myString$): changes all characters from myString$ to uppercase

myString$ = "was lowercase"
newString$ = UCASE$ (myString$)? "original string: "; myString$; ", new string: "; newString$

prints "original string: was lowercase, new string: WAS LOWERCASE"

Idiom 1: test if a string is empty

IFZ myString$ THEN ' empty
this is the short for:
IFZ LEN (myString$) THEN ' empty

Idiom 2: scan a string

FOR pos = 1 TO LEN (myString$)
SELECT CASE MID$ (myString$, pos, 1)
CASE "1": ...
CASE "2": ...
NEXT pos

Idiom 3: find a sub-string

IF INSTR (myString$, "sub-string") THEN ' found!

Idiom 4: check Yes/No answer, whatever is its case

IF INSTRI ("yes/no", resp$) THEN ' found!

(Note the slash to invalidate "sno" or similar invalid strings)


CASE "yes", "no" ' found!

Putting your new knowledge in action

As a brain teaser, here is one that I invented in 1978, after reading a science fiction book. In the SciFi book, it was called "The KAPREKAR Algorithm", and it was supposed to produce a "mathematical pit".

A year later, I spoke to the youngest of my four sisters (she is the brainy One in the family). She told me that she read about it in an article from François LE LYONNAIS, an inventive French Mathematician and a very good chess commentator. Well, it shows that while my sister was reading math articles, I was read SciFi books…

At the time, I coded this algorithm in FORTRAN as a final project for my first year of my computer degree and my sister told me that the teachers used this very algorithm for the final exam of a later promotion.

Here is the challenge: Hello Mr KAPREKAR!

A math pit is a non-zero 4 digit number, which remains unchanged after the following manipulation:

Iterate until all digits are equal

1. Sort the 4 digits as (a, b, c, d), a <= b <= c <= d (a being the smallest)
2. Make a new 4 digit number: dcba
3. Make a new 4 digit number: abcd
4. Compute the difference: dcba - abcd: this difference is a math pit candidate
5. Test if the difference is the same number as the previous iteration
6. Extract from the difference the 4 digits (a, b, c, d)

It took me 3 hours to code the KAPREKAR algorithm in XBLite. The answer is a single mathematical pit: 6174 found after at most 8 iterations.

What about trying this challenge?

Here is my solution. I welcome all comments on it.

PROGRAM "kaprecar"
VERSION "1.00b"
' kaprecar - KAPREKAR Algorithm
' GPL 2007 Guy "gl" Lonne, dedicated to my dear sister Francoise
' Source code released under GNU GPL
' ***** Description *****
' kaprecar is an implementation of the KAPREKAR Algorithm, which produces
' a "mathematical pit".
' A math pit is a non-zero 4 digit number, which remains unchanged after
' the following manipulation:
' Iterate until all digits are equal
' 1. Sort the 4 digits as (a, b, c, d), a <= b <= c <= d (a being the
' smallest)
' 2. Make a new 4 digit number: dcba
' 3. Make a new 4 digit number: abcd
' 4. Compute the difference: dcba - abcd: this difference is a math pit
' candidate
' 5. Test if the difference is the same number as the previous iteration
' 6. Extract from the difference the 4 digits (a, b, c, d)
' There is a single mathematical pit: 6174 found after at most 8 iterations.
' ***** Versions *****
' gl-05mar07-v1.00a: creation.
' gl-05mar07-v1.00b: optimized.
  ' mathPit[i1000, i100, i10, i1] is a 4-dimensional array
  DIM mathPit[0]
  DIM acIterMax[0]
  cPit = 0
  cTries = 0
  FOR i1000 = 0 TO 9
    FOR i100 = i1000 TO 9
      FOR i10 = i100 TO 9
        FOR i1 = i10 TO 9
          seed = (i1000 * 1000) + (i100 * 100) + (i10 * 10) + i1
          SELECT CASE seed
            CASE 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999
            CASE ELSE
              ' -PRINT "processing"; seed
              INC cTries
              d = i1000
              c = i100
              b = i10
              a = i1
              n4digits_old = 0
              cIter = 0
              bMathPit = $$FALSE
                INC cIter
                ' sort the digits ascending as (a, b, c, d),
                ' a <= b <= c <= d (a being the smallest)
                  bSwap = $$FALSE
                  SELECT CASE ALL TRUE
                    CASE a > b : SWAP a, b : bSwap = $$TRUE
                    CASE b > c : SWAP b, c : bSwap = $$TRUE
                    CASE c > d : SWAP c, d : bSwap = $$TRUE
                  END SELECT
                LOOP UNTIL !bSwap
                dcba = (d * 1000) + (c * 100) + (b * 10) + a
                abcd = (a * 1000) + (b * 100) + (c * 10) + d
                ' -PRINT "sorted descending "; dcba
                ' -PRINT "sorted ascending "; abcd
                n4digits = dcba - abcd
                IFZ n4digits THEN EXIT DO    ' 0000 is not a math pit
                IF n4digits = n4digits_old THEN
                  bMathPit = $$TRUE
                  ' -PRINT "it's a math pit "; n4digits
                  EXIT DO    ' it's a math pit!
                END IF
                n4digits_old = n4digits    ' save current value
                ' extract the digits
                d = INT (n4digits / 1000)
                remind = n4digits - (1000 * d)
                c = INT (remind / 100)
                remind = remind - (100 * c)
                b = INT (remind / 10)
                a = remind - (10 * b)
              IF bMathPit THEN
                SELECT CASE TRUE
                  CASE cIter <= 2
                    ' print the minimum
                    s$ = STRING$ (seed)
                    SELECT CASE LEN (s$)
                      CASE 1 : s$ = "000" + s$
                      CASE 2 : s$ = "00" + s$
                      CASE 3 : s$ = "0" + s$
                    END SELECT
                    ? "Math pit:"; n4digits; ", found after only"; _
                    cIter; " iterations processing "; s$
                END SELECT
                IFZ cPit THEN    ' 1st math pit
                  mathPit[0] = n4digits
                  acIterMax[0] = cIter
                  cPit = 1    ' count the math pit
                  found = - 1
                  upp = cPit - 1
                  FOR z = 0 TO upp
                    IF mathPit[z] = n4digits THEN
                      found = z    ' math pit already recorded
                      EXIT FOR
                    END IF
                  NEXT z
                  IF found > - 1 THEN    ' math pit already recorded
                    IF acIterMax[found] < cIter THEN
                      acIterMax[found] = cIter
                    END IF
                    INC upp
                    REDIM mathPit[upp]
                    mathPit[upp] = n4digits
                    REDIM acIterMax[upp]
                    acIterMax[upp] = cIter
                    INC cPit    ' count the math pit
                  END IF    ' not known
                END IF    ' 1st time
              END IF    ' math pit
          END SELECT
        NEXT i1
      NEXT i10
    NEXT i100
  NEXT i1000
  PRINT "\n\nKAPREKAR Algorithm tried on"; cTries; " 4-digit numbers."    ' 495 4-digit numbers
    PRINT "I did not find any mathematical pit."
    upp = cPit - 1
    FOR i = 0 TO upp
      PRINT "Math pit:"; mathPit[i]; ", found after at most", acIterMax[i]; " iterations"
    NEXT i
  a$ = INLINE$ ("\nPress Enter to quit >")

Useless as it seems, the kaprekar algorithm has been used for computer generated graphical patterns; see some applications of the Kaprekar algorithm at http://mathworld.wolfram.com/KaprekarRoutine.html

Overview of variable definition

I use and abuse of the implicit types (XLONG and STRING), but sometimes, the implicit types will not do. Time has come to try other data types.

In XBLite, data representation comes in many sizes and shapes, for very good reasons:
– big integers computations
– decimal number arithmetic
scientific calculations
– ...

In case you have to, here is your road-map for this jungle:

Built-In Data Types sfx     Description        Bit Size    Data Type
=================== ===     ================== ========    =============
SBYTE               @       signed byte        8-bit       integer
UBYTE               @@      unsigned byte      8-bit       integer
SSHORT              %       signed short       16-bit      integer
USHORT              %%      unsigned short     16-bit      integer
SLONG               &       signed long        32-bit      integer
ULONG               &&      unsigned long      32-bit      integer
XLONG                       register type      32-bit      integer
GOADDR                      address type       32-bit      integer
SUBADDR                     address type       32-bit      integer
FUNCADDR                    address type       32-bit      integer
GIANT               $$      signed giant       64-bit      integer
SINGLE              !       single float       32-bit      IEEE Single
                                                           Precision Floating Point
DOUBLE              #       double float       64-bit      IEEE Double
                                                           Precision Floating Point
LONGDOUBLE          ##      long double float  96-bit      IEEE Long Double Precision
                                                           Precision Floating Point
STRING              $       ubyte string       8-bit       unsigned bytes
SCOMPLEX                    single complex     32-bit      floating point
DCOMPLEX                    double complex     64-bit      floating point

int8s@ = 1@               SBYTE
int8u@@ = 1@@             UBYTE

int16s% = 1%              SSHORT
int16u%% = 1%%            USHORT

int32s& = 1&              SLONG
int32u&& = 1&&            ULONG

int32s = 1                XLONG

int64s$$ = 1$$            GIANT

sgl32s! = 1!              SINGLE
dbl32s# = 1.0#            DOUBLE
dbl64s## = 1.0##          LONGDOUBLE

char@@ = 'A'              UBYTE
str$= "ABC"               STRING

Composite type (also called User Data Type)

A composite type is a combination of XBLite built-in types. It is declared:

  XLONG .myLong
  XLONG .myLongArray[upper bound]
  STRING * maximumLength .myString
  STRING * maximumLength .myStringArray[upper bound]

Note that all XBLite types are explicit and all strings have a fixed size.

I like to use composite types: they are a great way to package together related variables. For example, SHARED variables, or interface parameters, or "object" attributes.

Declaration of a composite type

A composite type is first declared as:

TYPE myType
  XLONG .myLong
  STRING * 255 .myString

(note the dot preceding the name)

Definition of a UDT variable

The data type being declared, the variable can be defined with it:<>/p>

myType myUDT

Using a UDT variable

You can access the individual items:

myUDT.myLong = 2
IF INSTR (myUDT.myString, "text") THEN

The UDT variables come with their own problems:
Do not confuse the use of LEN and SIZE when using UDT strings vs normal strings. For UDT variables, both LEN and SIZE return the type size. For UDT strings, this is the allocated size, and it remains constant. This does not tell how many characters are currently contained in the UDT string.

Use this to get the UDT string length:

length = LEN (CSIZE$ (myUDT.myString))

Gotcha 1: string are defined with a fixed size

Composite strings have an explicit size, which is never zero (empty string): an empty string is in fact padded with binary zeroes (null characters).

IFZ myUDT.myString THEN

does not work.

Instead use

IFZ CSIZE$ (myUDT.myString) THEN

CSIZE$ is a function that looks for the first null character and clips string off at this null character. The zero byte is represented by \0 or '0'.

Gotcha 2: numeric fields are padded up to the byte

For example, a USHORT is padded to the size of XLONG.

To illustrate a consequence of this difference, here is a small demo program in which I move -1 in an unsigned byte (horror!). If the UBYTE belongs to a structure, XBLite converts -1 to 255. If not, -1 is left unchanged.

VERSION "1.00"
' Outputs of this program
' =======================
'Case 1: IF winBack[0].color_coef = -1 THEN with_1 = -1 ELSE with_1 = 5
' coef = winBack[0].color_coef
' winBack[0].color_coef = 255, coef = 255, with_1 = 5
'==> problem 1 occurred: coef <> with_1 255 <> 5
'Case 2: IF ubyte@@ = -1 THEN with_1 = -1 ELSE with_1 = 5
' coef = ubyte@@
' ubyte@@ = -1, coef = -1, with_1 = -1
'Press Enter to quit >
IMPORT "xst" ' XBLite Standard Library
UBYTE .color_coef
DECLARE FUNCTION Entry () ' program entry point

  XLONG bAdd[0]
  WIN_BACK winBack[0]
  bAdd[0] = $$FALSE
  winBack[0].color_coef = - 1
  ubyte@@ = - 1    ' implicitly UBYTE
  ? "Case 1: IF winBack[0].color_coef = -1 THEN with_1 = -1"
  ? " ELSE with_1 = 5"
  ? " coef = winBack[0].color_coef"
  ?, "winBack[0].color_coef = "; winBack[0].color_coef;
  ' --------------------------------------------------works
  IF winBack[0].color_coef = - 1 THEN
    with_1 = - 1
    with_1 = 5
  ' -----------------------------------------does not work
  coef = winBack[0].color_coef
  ' -----------------------------------------------------------
  ? ", coef = "; coef; ", with_1 = "; with_1
  IF coef <> with_1 THEN
    ? "\n==> problem 1 occurred: coef <> with_1"; coef; " <> "; with_1
  ' ===========================================================
  ? "Case 2: IF ubyte@@ = -1 THEN with_1 = -1 ELSE with_1 = 5"
  ? " coef = ubyte@@"
  ?, "ubyte@@ = "; ubyte@@;
  ' --------------------------------------------------works
  IF ubyte@@ = - 1 THEN
    with_1 = - 1
    with_1 = 5
  ' -----------------------------------------does not work
  coef = ubyte@@
  ' -----------------------------------------------------------
  ? ", coef = "; coef; ", with_1 = "; with_1
  IF coef <> with_1 THEN
    ? "\n==> problem 2 occurred: coef <> with_1"; coef; " <> "; with_1
  a$ = INLINE$ ("Press Enter to quit >")
  QUIT (0)

Yes! Composite types are useful!

I did not mention this to prevent you from using composite types as they are very convenient in a lot of situations. However, remember that the composite items don't quite map their built-in counterparts.


At this point, it is up to you to become very proficient with XBLite. But remember, only practice makes perfect, regular practice.

I suggest that you write a series of small console programs: the ever classic guess game is a must, actually, all the good old BASIC games are perfect to acquire skills, which are knowledge in action. So, download the latest distribution of XBLite (release 2.40 still cooling from baking), and grind your teeth on:

Kindly Rat's GWBASIC website
The Old Gem - Basic

to name a few.

Well, this could be a hobby of yours for, at least, the next two years...
Happy computing!

Guy "gl" Lonné

Related links

As David announced 15 April 2008 in the XBLite Google Group:
A new version XBLite, v2.4.0, has been released
and is available for download from the XBLite

website: XB-Lite Website

or download directly from:

XB-Lite Zipped Download
XBLite 7Zip Format Download

Programming Simulations - Part 2 Real World Example: by MystikShadows


Welcome to this second part of my simulation series. If you remember, in The First Part, we covered a lot of theory about what a simulation (or simulation game) is as well as what the elements of a simulation are and possible ways they could or would need to interact with each other. Although the ultimate goal of this series is simulation games, the theory can typically best be applied (and learned) much better when used in a real world situation. The reason is the reader can relate to that real world situation in terms of understanding the different parts much better than in a game where first the user needs to situate himself/herself in the game first then comes figuring out what part does what. Don't worry though, we'll be making a simulation game in the next part of the series.

Hence, in this second part of the series, we'll put the knowledge we learned to use in an actual real world situation that we often hear of. We'll go through the steps of defining the components of the simulation and see if and how they need to interact with what other system in order to perform their designated functions. Once we define all the parts of this simulation in this article and in the next article we will detail and explain the code itself. This way you will have time to digest the information here (as it is a big article in itself). It will also give you some time to ask me questions should you have any about certain aspects of this project. So let's get right to it shall we?


Here's the situation, you won the lottery (very real world situation no?) and you decide to buy yourself a dream house. You find the perfect house for your taste (almost as of you designed it yourself) it's a rather new house built 2 years ago, it has a great big backyard with a pool, really, everything you want in a house. The only inconvenience is it's in a part of town where robbery and other crimes seem to occur a little more than you are comfortable with. But you don't want to pass up the chance of owning this house since otherwise it's just so perfect for you.

The builders of the house (the original owners) mention that some of the other houses have alarm systems and that from what they've seen over the last two years, that alone seemed to be enough to discourage robbers from infiltrating their houses (another very real world situation of course). So you say to yourself, ok, I'll get the house, but I'll put the money to have a very good alarm system. You don't stop there, you've heard of other benefits of house automation and decide to automate your house in the process (hey you won the lottery, money's no object).

Now, to do that, you need to consider more than one thing. For example, how many ways are there to get into your house? What kind of entry ways are there? What kind of sensor and/or contact do you believe you need in each room to keep them safe and the like? And this is only for the Alarm System part. You also have to consider what home automation feature you want to add to your house. For this part you basically simply have to think of what the features available are and if you want them and where in the house would they be useful. Since money is no object we won't consider any pricing or costs (but it would be a good add on feature for someone building house automation and alarm systems). So in this example, your house will have it all and this will be described in the following section.


In order to know what's involved with this simulation project, let's start by describing the house you just bought a bit in detail to get a feel of everything that it has. We'll start with the basement and work our way up all the way to the second floor and the attic above it. This way, you'll know what is where in the house.


This floor is the first to be seen by you and by guests. when they enter through the front door, the first thing they can see is the reading room and the stairs learning to the second floor on the left and a lighted room on the right (to take full advantage of the sunlight. At the end of the main hall they can spot part of the main dining area and if they walk forward, they can see the kitchen on the right and the main floor bathroom on the left. Here is the layout of this first floor.

                              RESIDENTIAL FLOOR LAYOUT
                                    First Floor

                                     80'  wide
      |           |           Patio door           |                          |
      |           |                                |                          |
      |           |                                +----------------------+   |
      |           |                                                       |   |
      +           +                                                       |   +
      |            \                                                      |   |
      |   Main      \            Dining Area              Kitchen         |   |
      + Bathroom  +                                                       |   +
      |           |                                                       |   |
      |           |                                                       |   |
      |           |                                                       |   |
      |           |                                +----------------------+   |
 60'  |           |                                |                          |
depth |           |                                |                          |
      +-----------+--------+-----+                 +--------------------------+
      |                    |-----|                 |                          |
      |                    |-----|                 |                          +
      |                    |-----|                 |                          |
      +                    |-----|                 |                          |
      |                    |-----|                 +                          +
      |    Reading Room    |-----|                /         Living Room       |
      |                    |-----|               /                            |
      +      Library       +-----+                 +                          +
      |                    +     +                 |                          |
      |                     \     \                |                          |
      |                      \     \               |                          +
      |                    +     +                 |                          |
      +-----+              +-----+-----+==+==+-----++---++              ++---++
             \            /           Main Door           \            /
              +----------+                                 +----------+

       ENTRY POINTS:   - Picture Windows left and right of the house
                       - Main entrance door
                       - Patio door in the dining area
                       - Windows in the reading room, living room and kitchen
                       - Window in the bathroom


On the second floor as soon as you come up the stairs you see two doors on the left one for the master bedroom and one for the master bathroom (so guests don't have to go downstairs if they need to go). In front of you is a sitting area just to sit and talk basically. On your far right is the guest room and beside that one, taking a lot of space, is the entertainment room (you need room to cram a pool table, home movie, stereo system and computer in there. Here's the layout of the second floor.

                              RESIDENTIAL FLOOR LAYOUT
                                    Second Floor

                                      80' wide
      |                    |                       |                          |
      |                    |       Sitting         |                          |
      |                    +        Area           |                          |
      |       Master        \                      +                          +
      +      Bathroom        \                    /           Guest           |
      |                    +                     /            Room            |
      |                    |                       +                          |
      +                    |                       |                          +
      +------+      +------+                       |                          |
      |       \    /       |                       |                          |
      |        \  /        +                       |                          |
      +                     \            +---------+--------------------------+
 60'  |                      \           |                                    |
depth |                    +             |                                    |
      |                    |-----+       |                                    |
      |                    |-----|       |                                    |
      +                    |-----|       +                                    |
      |       Master       |-----|      /                                     | 
      |       Bedroom      |-----|     /             Entertainment            +
      +                    |-----|                        Room                |
      |                    |-----+     \                                      |
      |                    |            \                                     |
      |                    |             +                                    +
      |                    |             |                                    |
      +                    |             |                                    |
      |                    |             |                                    |
      |                    |             |                                    |
      +-----+              +----+----+---+---------------+              +-----+
             \            /                               \            /
              +----------+                                 +----------+

       ENTRY POINTS:   - Picture Windows in the master bedroom and entertainment
                       - Window behind the stair case
                       - Window in the sitting area
                       - Windows the guest room
                       - Window in the master bathroom


Part of the basement is taken for the 3 car garages they take up the lower left side of the house. Behind it is empty space you use for storing stuff. The right side is an open area that can easily hold a good size wood workshop that you setup for your wood projects. Here is the layout of the basement. The only entry points to the basement (from outside) are the three garage doors. There are 6 small typical basement windows but they are too small for the average person to come through them hence one motion detector in the workshop area would do nicely. Here is the layout of the basement floor.

                              RESIDENTIAL FLOOR LAYOUT

                                      80' wide
      |                                    |                                  |
      |                                    |                                  |
      |                                    +                                  |
      |              First                  \                                 +
      |              Garage                  \                               /
      |                                    +                                /
      |                                    |                                  +
      |                                    |                                  |
      +                                    |                                  |
      +------------------------------------+                                  |
      +                                    |                                  +
      |                                    |                                  |
      |                                    +                                  |
      |               Second                \               The               |
 60'  |               Garage                 \            Workshop            +
depth |                                    +                                  |
      |                                    |                                  |
      |                                    |                                  |
      +                                    |                                  |
      +------------------------------------+                                  |
      +                                    |                                  |
      |                                    |                                  |
      |                                    +                                  +
      |               Third                 \                                 |
      |               Garage                 \    +-----+                     |
      |                                    +      +-----+                     |
      |                                    |      +-----+                     +
      |                                    |      +-----+                     |
      |                                    |      +-----+                     |

       ENTRY POINTS:   - First garage door, window and door to workshop
                       - Second garage door and door to workshop
                       - Third garage door, window and door to workshop
                       - Work shop door and six windows


The attic has no separations per se. The frame that makes up the rooftop is triangular. There is one small window and one vent on a wall. Since the vent is too small to let anyone in, the only entry point is the window. Now since it's in the attic one might think it's not obvious to get it. But a rather big tree on the side of the house managed to give access to that window rather conveniently. Hence we'll need one contact sensor for that window and a motion sensor as well since if they break the window instead of opening it they could do whatever they wanted from then on out.


Home automation are systems that are designed to help make your life that much better and do things for you (much like the automation of many processes in businesses or others). There are many things that currently exist as far as home automation goes. So looking at the floor plans above let's see what we could add to make your life easier.


When it's sunny outside sometimes (like at dusk or dawn) it can be annoying to get the sunlight directly in your face. Hence they have a system that can tint the windows according to the amount of sunshine that comes in the house. This can be quite useful as you can imagine. So you decide to put auto tint windows in your living room, dining area, reading room and the master bedroom.


This is of course related to the alarm system to some degree. But imagine this, you wake up in the middle of the night and need to go to the bathroom. This feature will light up the lights as you walk from wherever you are to the bathroom. If you're the type to hit your toes in everything by the time you get there, this might help show you where these things are and avoid some unnecessary foot pains. So you add this feature outside so the light turns on when something moves around certain parts of the house as well as in some "trajectories" to and from the bathrooms of your house.


This is typically a great tool against robbery. Imagine for a minute that you leave on vacation for 3 weeks. This feature could simulate life in your house while you're gone. It would turn on certain lights automatically at certain times as well as stereo systems, televisions and other equipment to give the impression that there's somebody in the house. Think this is taken right out of the science fiction channel? Think again, it exists, and has existed for at least 10 years now, But today, it's even more refined and perfected. So you decide to have that setup as well. Typically, this system will record your "weekly" schedule to know what to open when while you're gone.


This is rather easy and simply involves you telling the system what time to raise the heat in the morning and what time to lower it at night (to save on your energy bill). You could probably enter some special conditions too so that if you do leave on vacation the house can keep itself running on the lowest setting (or turned off) in your absence. House automation isn't just for your comfort. Sometimes it's worth paying if it saves you on your bills on top of it. So yes, you of course have that in your system ready for action.


Yes, that exists as well, they are devices you plug in your outlets on top of which you plug in your equipment. They essentially serve to control when they can be used. Hence, if you get someone to feed your pets or water your plants while you're gone on vacation. This would disallow them to use your computer or whatever else if you don't want them to. If you have kids, you could make it so they can't turn anything on passe a certain time or earlier than a certain time. Great for power management and for your ears especially when you're sleeping. This is, of course, very useful if you're the type to fall asleep to the television and leave it running all night long. It's not that expensive so you get enough of these for all your outlets.


Now we have described our house, which possible ways there are to get in the house "uninvited" so to speak and we defined all the home automation features we want. You can imagine that each window and door learning outside needs a contact sensor. You also assume that if they break the window instead of opening it the contact is still there so you add some motion detectors in every room. There are probably other things you could do as far as alarm system and home automation goes but this tutorial can do fine with this much stuff so we'll leave it at that.

You, of course, already have fire and smoke detectors which are also connected to the alarm system and some thermometer and humidity sensors so you can keep those at ideal conditions. Now comes the part where you have to take all this stuff and make it work in a program. All this gets managed and controlled from a central console (and a wireless remote that can be used anywhere in the house). So assuming you have everything connected properly. The next step is to define our central console.


Because of the need to turn the alarm off when you get home, the central console is typically located near the main entrance. It has a clear lighted display that gives you plenty of information on what's going on (if anything) where in the house. It also has a keyboard so you can set things up in the system or change anything in the house on the fly. The central console has three main functions.

  • Monitor, report and react to the sensors and contacts:
    The systems needs to poll regularly every sensor and contact mechanism in the house. It does that in its main loop as you can imagine. This system will also monitor any changes. Hence if you unplug an outlet controller, it will tell you that it has been taken out. Now, if a motion detector goes off, or a contact to a door or window is broken, it will inform you on the console and will call the police department with the needed information of what just took place. If a fire/smoke detector goes off, it will report it on the console and call the fire department with the needed information. Everything is logged on file and can be retrieved at any time. In nothing happens it will simply go back and continue polling from the sensors and contacts.

  • Perform the home automation programmed in the system:
    These are the special lighting simulations, cutting off the outlets at a given time, heating control and the likes. This is executed in the main loop as well. So the main loop will need to keep track of date and time in order to know if it should start a given automation or not. Basically, once these situations are programmed in the system, this is a very autonomous process that requires no user intervention to execute itself.

  • Allow the user to setup and control everything in the system:
    What good is a home control system if you can't control it. This mode is for the initial setup of your house of course. But also for any improvised changes. For example, say that you know you'll be programming on your computer and you don't want the system to turn off your computer on you at the time you programmed it to do so. You can just turn off outlet control for the outlet or the room your computer is in. The interface we'll build here will try to make it as quick and easy to control everything without needed some long setup process just to do some quick changes like this when needed.

The system will be in monitoring mode by default. From there the user can take a look to see if anything of interest is currently happening somewhere in the house. Hitting the F2 key will put the system in setup/change mode. This mode is based on the rooms and areas of your house. Hence it will offer a list of these areas to the user. The user will then select the room they want to setup or change and will then go the tabs on the right where they can monitor or setup the security and home automation features they want for it. I think this will be the best and quickest way to move around in the system. We are now ready to start coding our simulation. We'll use some keys on the keyboard to simulate events so we see what happens. We'll also have special things to change the date and time so we can see how the home automation features work (if they do). And aside that we'll make ourselves a complete console program for the control and monitoring of everything we described here. So let's start the coding process.


Before anything else, let's take the floor plans and descriptions and take a look at the needed equipment for each of them. This will give us an idea of everything we'll need to cover for the whole house safety and automation features. Here's a table with the quantities of everything we'll need.

First 1
Main Bathroom
Dining Area
Reading Room
Main Hallway
Living Room
Second 7
Master Bathroom
Sitting Area
Guest Room
Master Bedroom
Entertainment Room
Basement 13
First Garage Area
Second Garage Area
Third Garage Area
Workshop Area
Attic 17
All Attic Space
Inventory Totals 15

This is the set of equipment we will be setting up (simulating a setup that is) in your simulated house. We will need to add other sensors (that I'll describe in the next section) along with some other equipment to make it all stick together and work. Let's start by going over the types of sensors that are available.


Different types of sensors perform different kinds of functions. Though some are similar in nature, because of the part of the house they go on, their shape or strength of operation can vary. Let's review the different types of sensors and contacts you that are available to give you a better idea.

  • Contact Sensors:
    In the typical scenario, this involves two metal plates of some sort. While these two touch each other, everything is normal. When they are separated is when the alarm would typically go on. Some use contacts and magnets as well.

  • Trip Sensors:
    These are classically a small wire (almost invisible) that uses the principle of contact to do its job. If the wire is tripped, the contact breaks and the alarm would go on. Today, they can also use an infra red signal that triggers the alarm when it is obfuscated by a solid object.

  • Motion Sensors:
    These are sensors that can detect movement in a given room. Different motion sensors can detect different amounts of movement in different size rooms. Typically, the price paid for the sensors define how small a movement they can detect (or not detect if desired) and how low in the room it should detect. This is convenient when you have pets and you don't want them setting off the alarms.

  • Sound Sensors:
    Basically these sensors work just like an omnidirectional microphone. They are meant to pick up sound pretty much anywhere in a room (not just in the direction the microphone part is aiming at. If a sound is picked up the alarm goes on.

  • Fire/Smoke Sensors:
    I don't believe I need to explain these too much here. But yeah, every house needs at least one of those (per floor wouldn't be too much either). When smoke or fire is detected the alarm goes on. Just to be on the safe side, you put one of these in every room of your house (and open area) thinking the quick the smoke gets to the sensor the quicker it knows of some danger.

  • Light Sensors:
    Light sensors (CDS cells or others) are mechanism that can get triggered when the light going into them is either obfuscated or if, for example, when it gets dark past a given point outside. The idea is that you want to turn something on (a light, an alarm signal) when there isn't enough light to see. Most night lights today come with a CDS sensor that goes on when a room is too dark. This is used for dark purposes and also to darken the windows to shade the windows when there's too much sun coming in a room.

  • Temperature Sensors:
    This is needed for the automatic heat system this will tell the system when it's time to turn on, or off, the heat to help keep the room/house at a given temperature. Some more expensive system can actually work on a per room basis where each room can be kept at different temperatures depending on their role.


Of course, you don't want to just discourage robbers to aim for your house, you go a step further and decide to help catch these robbers whenever you can. Hence, all rooms defined above have a hidden camera in them that is connected to the alarm system. Hence if any entry points are violated in any part of the house, the corresponding camera will begin to record for a specified amount of time. Each camera can be setup to record anywhere from 1 minute to 2 hours. Not only that, if the robber breaks another entry point that camera will also start recording. So your chances of identifying the robber will be that much better. So you have a camera setup in every zone (room) of the house.

And there you have it. With these sensors in place where they go and the system programmed accordingly you are now ready to secure and control your home. There are things you could add such as scheduled lawn watering (to keep it greener than your neighbors) and the likes. We are now at the point of actually starting to code our system. So let's start by defining our data.


Mystik H.A.S.S. (Home Automation and Security System) is the name we'll call this project. Now since the main goal here is to automate the simulated house and also to plan for the future (if you add to the house for example) or if you buy a new house, I'll use data files for everything so you can add to them or change them to setup entirely different houses. This combined with dynamic arrays to load everything in RAM should offer a lean and efficient way to both setup your house and adapt the system to any other situation. Note that binary or random access files might do a quicker job in this case but for the sake of clarity of this tutorial I've selected text files so you can easily view their contents. Here is the list of files with their explanation.

  • Master Setup File: (MystikHCS.csv)
    In this file you will find information such as your address, phone number, address and phone numbers of police and fire departments, the alarm company and the likes. This can change when you change anything in your setup (such as changing the alarm company you're dealing with) but otherwise, this is a pretty static file.

  • Floor Description: (Floors.csv)
    Since the system is designed to learn about your house, this file serves to identify the floors in your house. The selection system is designed to present the house starting with the floor, the room then the equipment, sensors, scripts of that specific room.

  • Room Description: (Rooms.csv)
    This is essentially a list of the rooms and areas of your house. They are there for informational purposes only. In this file each room is numbered and attached to the floor it's on. When something happens this will make it easier to know where in the house an event is happening.

  • Equipment Description: (Equipment.csv)
    This is the file that holds the equipment (cameras, sensors, contacts and the rest) that is currently connected to the central control system. They are numbered as well. Also, information about which room has which equipment is in which will help identify where the events are happening in the house. This file will also hold the status of each of them (enabled, disabled, triggered for when something happens).

  • Security Scripts: (Security.csv)
    In this system I've separated alarm and security from home automation features (which you can read about below). This file has all scripts that explain what to do when the events are happening. For example, call the fire company if the fire alarm goes off, call the police in other cases, and the likes. This is also where we will tell the system when to start recording from the camera and for how long in each of the situations.

  • Home Automation Scripts: (Automation.csv)
    This is the file that holds the home automation features. When we want certain things to happen in the house at given times and dates (or sometimes even seasons of the year) this is the file that will hold this information. Each script and their status (enabled, disabled, running or not) will be stored in this file.

On top of these we will have a file called simulationlogs.txt which we can review at any point to see what happened when during the simulation. Anything not recorded in these log files indicate that everything was running smoothly. Anything recorded is any situation that arises during the simulation (either random or triggered manually through the menu options and such. with this, we'll be able to view the results and make sure things happened when they were supposed to happen and for the right reasons.


And there you have it, this is the plan for the simulation program. I chose this type of project because I think it's safe to assume that most of us know what home automation and security systems are. Also, as you'll see in the next issue when I publish and document the code, there should be most part of any simulation in the code which should help use this as a base (a template if you will) for your own simulation projects.

As I mentioned in the beginning of this article, if you have any questions so far in this project description, be sure to email me and let me know because it's important that everything be clear upfront before we tackle the code base (in the next issue). Perhaps I haven't detailed a part of this enough and you'd like to know more about it, just contact me and I will detail it as much as I can so that everything is clear. Until next time, happy reading and coding.

Stéphane Richard

Marrying YaBasic And Ubuntu: by E.K.Virtanen

SEC. TITLE: YaBasic for Ubuntu: How to.

Currently, YaBasic can be found in Ubuntu (Debian) repositories but sadly, it is pretty buggy version of it. However, PSnake did fix one of the biggest bug and YaBasic is very powerful and usable basic programming tool for basic lovers.

So here is a simple how-to, how you can get fixed version of YaBasic in your Ubuntu easily. I also tell you how you can use Gedit as an IDE for it.

1. To keep it simple, we first install buggy version. Why? Because this is easiest way to get all necessary libraries installed at once. So go to your terminal and type next line:

sudo apt-get install YaBasic
It is a good habit to backup things before we mess with them so let's do a backup of old YaBasic. Continue with your terminal and type next line too.
sudo cp /usr/bin/yabasic yabasicBU
Now in your /usr/bin/ folder has backup of YaBasic, named as yabasicBU. After you have gone through this tutorial and sure your YaBasic works you can remove that backup file. 2. Now, point your browser to http://yabasic.basicprogramming.org/ and download latest stable release by new developers. You can extract it where ever you want. After extracting, go with your terminal there. Type next line in your terminal then.
sudo cp yabasic /usr/bin/
This copies updated yabasic binary file to /user/bin and overrides old one. 3. Type yabasic in your terminal and add next line in YaBasic IDE
open window 100, 100
and press enter twice. If you see a small gtk window opening, your YaBasic is ready to use.

SEC. TITLE: YaBasic and Gedit.

After Ubuntu 7.10 was released, gedit syntax files went so weird that I am not honestly aware how this should be done in 100% right way. However, i did next thing and well...everything seems to work fine. 1. I am pretty sure there is some syntax file for some language, what you don't need. For me, it is vb.net. So I decided to get rid of VB.NET and add YaBasic instead of it. Go to your terminal and type:

gedit /usr/share/gtksourceview-2.0/language-specs/vbnet.lang
IMPORTANT: Be warned that with this guide, you will lose your original vb.net syntax file and it is replaced with a new one. If you hesitate then backup your vb.net lang file! Now, you see vbnet.lang file in you gedit editor. Replace it with this:
<?xml version="1.0" encoding="UTF-8"?>

 Author: John Luke <asciiworld@gmail.com>
 Copyright (C) 2008 John Luke <asciiworld@gmail.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 Library General Public License for more details.

 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.

<language id="vbnet" _name="yaBasic" version="2.0" _section="Sources">
    <property name="mimetypes">text/x-vbnet;text/x-vb</property>
    <property name="globs">*.vb</property>
    <property name="line-comment-start">'</property>

    <style id="comment" _name="Comment" map-to="def:comment"/>
    <style id="string" _name="String" map-to="def:string"/>
    <style id="preprocessor" _name="Preprocessor"
    <style id="keyword" _name="Keyword" map-to="def:keyword"/>
    <style id="type" _name="Data Type" map-to="def:type"/>
    <style id="special-constant" _name="Special constant"
    <style id="boolean" _name="Boolean value" map-to="def:boolean"/>

  <default-regex-options case-sensitive="false"/>


    <context id="line-comment" style-ref="comment"
        <context ref="def:in-line-comment"/>

    <context id="old-style-comment" style-ref="comment"
        <context ref="def:in-line-comment"/>

    <context id="string" style-ref="string" end-at-line-end="true">

    <context id="keywords" style-ref="keyword">
      <keyword>xor</keyword>    </context>

    <context id="types" style-ref="type">

    <context id="special-constants" style-ref="special-constant">

    <context id="boolean" style-ref="boolean">

    <context id="vbnet">
        <context ref="line-comment"/>
        <context ref="old-style-comment"/>
        <context ref="string"/>
        <context ref="keywords"/>
        <context ref="types"/>
        <context ref="special-constants"/>
        <context ref="boolean"/>



Save file and restart your gedit.

2. You need to install plugin "External tools" for Gedit. After this, go to Tools --> External tools manager --> Add new

Magic lines you need to add there are here:

gnome-terminal -e "yabasic $GEDIT_CURRENT_DOCUMENT_NAME"
You can also add quick key and name the tool in a way you want.

Now your Ubuntu and YaBasic are married and third wheel is gedit. In case of problems, let me hear about them in correct place, it is here. :) YaBasic forum can be found at here.


Exit Issue: by MystikShadows

And before you knew it, another exit issue presents itself in front of your eyes. It's been quite the adventure building this issue for you guys. We hope you liked it as much as we liked creating it.

We're always opened to suggestions, critics and any other contributions that you can make for future issues of PCOPY!. It's very simple to do, just let us know about your submission or contribution and we'll all see what we can do about it or make sure it's in the upcoming issue of PCOPY!

Until our next issue, this is PCOPY! Signing off...