PCOPY! Issue #60 ~ January 8th 2008
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)
Reliving BASIC's History In One Website (MystikShadows)
The Open Source Entity Demystified (MystikShadows)
Interview with Pete Berg (E.K.Virtanen)
Open Source Software For A Living (MystikShadows)
Reviews & Presentations:
Introduction to sdlBasic (Cybermonkey)
QBinux (Sebastian McClouth)
Tutorials & HowTo's:
The ABC of the Xblite Programmer (Guy "gl" Lonne)
An Xblite Primer (Guy "gl" Lonne)
Guy (gl) Lonné
Issue release 1.1
Date 10'th Jan. 2008
~ REGULAR COLUMNS ~
From the Editors: by Da Editors
Hi everyone and welcome to this newest issue of PCOPY!
This is a new year and have we got some new tricks up our sleeve. . Aside the recently created website, PCopy! now has a support/feedback forum at BASIC Programming's forum.
There is one more plan also in the air, but it is so new that even my partners here dont know about it yet :D But if they like it (as much as i do), it will make PCopy! magazine to look and feel way different than before.
New year started with a good news. yaBasic got new interesting developer who has already fixed something, new BASIC programming website has been founded, new versions of several different BASIC dialects have been announced and there's more to come in the near future. It feels good to be a basic programmer here.
Here's what we have to offer in this issue. Yet another cool issue about BASIC, BASIC programming and BASIC programming dialects. One more interesting BASIC dialect is presented here, MystikShadows introduces a high quality level BASIC website and Guy (gl) Lonné shares more of his great articles. MystikShadows tackles two Open Source oriented subjects. The first is Open Source Licensing and "Open Source for a living".
For FreeBASIC and QBASIC fans, we have a treasure here, right in this issue. We have an interview with Pete Berg. Every QB/FB user knows him and his website, right?
Now go and grab a cup of coffee, put on your slippers and enjoy PCopy! issue #60!
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 dont be shy, you know something others dont 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 a writer you are dont 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 email@example.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 argonizer
dog.legs = 4 dog.name = "sheba" animals << dog
That looks like Ruby on rails :)
Letter from pete
Could you tell to that smallbasic tutorial creator that hes article was great and easy to read by a person who dont understand english so good (like i do). I downloaded smallbasic and now im interested how to create simple text file and how to get one certain line from it in a variable. Would it be possible to get this kind of tutorial for pcopy, or could you point out some url where this kind of tutorial is?
In The News: (+ some olds)(Mixed Contributors)
Work at smallBasic website has continued by Chriss-Warren Smith. If you are smallBasic fan or curious about it, then you really should go and see what's happening there.
Two new releases of thinBasic
And yet another new release of thinBasic. This popped in our email just before releasing this issue. new thinBasic stable release 126.96.36.199 is out and full of hot features.
Version 2.4.12 released for Basic4GL at 24th November 2007
Last Modified 2008-Jan-02 reads at bottom of BASIC Programming Resources and Chipmunk Basic Home Page
4'th demo of QB64 released at November 24, 2007. See post by Galleon to know more.
New basic programming website started. At basicprogramming.org you can find already a forum, blog and wiki and its only just started.
Where is ethosBasic? Domain is for sale.
QBinux pre-alpha-release announced at Pete's QBASIC website. Click here for more details.
Error 400 - Bad Request by http://www.extremebasic.com/
02 Jan 2008 After three years of development, there is the new version of Gambas. See more at http://gambas.sourceforge.net/
Atelier (V1.6) of KBasic Software is planned to be released in near future. V1.7 is expected in late January 2008. The new version of the compiler and IDE is complete. The runtime is currently completed. So please be patient. It comes with a VB upgrade wizard. Improvements were also made to the performance and reliability of the IDE and runtime.
8'th December 2007 is last time when Richard Russel has updated his website.
Development of yaBasic continues with new efforts. PSnake has already fixed one irritating bug, added new keyword and is looking with bright feelings in future. Old yaBasic community is gathering in new location, which you can find here. Old website of yaBasic still does exist but it's future is unsure.
Reliving BASIC's History In One Website: by MystikShadows
Here we are, in 2007, using what we've come to consider an every day tool. We sit at our computers do whatever we want to do (usually using a GUI of some sort) and program in our favorite language. We live in a perfect harmony (or close to it) of hardware, technology and software that make our day to day computer activities easy to integrate to our schedules and our life styles. Basically (no pun intended) today using computers is part of our lives. However, It wasn't always the case. There was a time when computers were something that only a few people new about and even less people could actually use for any purpose, that is until BASIC saw the light of day.
In 1964, when BASIC was created, it's main goal was to be a language that a lot more people could understand quickly and use almost immediately in order to get computers to do things for them as soon as possible. I often wonder if John George Kemeny and Thomas Eugene Kurtz had any idea of the impact their creations would have had in the computing industry back then. But the idea of having a programming language that most people could learn create a set of chain reactions for the whole computing industry. The purpose of this article is to take you back to that era, the times when programming was reserved for an elite group of people, The other purpose is to introduce you to a website that seems to have capture that era pretty well. So let's get started.
THE WEBSITE WE ARE TALKING ABOUT HERE:
Now, what was it really like back then? How can you put yourself in a context a lot of you might have never given a second thought about? I think there's only one way to do that well. The website is located at this location and is rightfully called "Classic BASIC Games Page". This website, created by and individual called Scott Moore features a very straightforward design (you basically read the site from top to bottom. It has a lot of contents but also helps describe (in a unique way I believe) how things really were back then. What you are reading here is my humble attempt at describing facts more than experiences and situations as Scott did on his website (sometimes explaining situations and experiences like that can really give a sense of how things were, how the programmers were thinking back then and what they had (or didn't have) to work with).
For example, back then RAM (Random Access Memory) wasn't as abundant (to say the least) as it is today. What would you do do if you were confined to the following parameters for your programming needs.
Can you even imagine yourself doing anything in these kinds of constraints? Most of your probably can't conceive what this really meant back then. Because today you have, in comparison limitless memory and storage space for your programs, you also have computer monitors that surpass the video output quality and resolution of any television set (unless you happen to be lucky and have one of those new HDTV wide screen sets) and today, programming editors and Integrated Development Environments really spoils us programmers a whole lot with features like syntax highlighting, autocompletion and the likes. But now, let's go to a time long before all these every existed.
MORE ABOUT SCOTT MOORE'S WEBSITE:
The first thing you'll probably notice when you visit his website will probably be a picture of what you'll categorize as the weirdest typewriter you ever saw in your life. That's because it's not a typewriter but an actual computer. There was no monitors back then they came out several years later. The website is divided into more than one section each with it's own specific set of information purpose and contents. Let's take a look at them and describe them here:
This is an ongoing website that is complete opened to submissions. It's not impossible today to create games that fall under the classic basic games category. The definitions of a classic BASIC game is detailed on the website we just need to create games to follow these rules and submit them to Scott (all submission details including email addresses are on the website).
IF you go to google and search for websites on the history of computing and the history of BASIC you will probably find a great list of websites that you can take a look at. Each of them have their own specific contents, you'll probably notice that most of them offer dates, models, versions and the likes on relevant material. Scott's website offers, as I said before, a very different point of view on Classic BASIC that I think really makes you relive the moment as if it was happening right in front of you. Not to mention with the collections of programs, I definitely categorize his website as one of the website that simply should never cease to exist.
Of course, you dont have to take my word for it. Take a look at the website for yourself, see what's there, read it as it was meant to be read, from top to bottom, and you'll see for yourself the unique approach that's being presented there. Until next time, happy coding (whether it's classic programming or not).
The Open Source Entity Demystified: by MystikShadows
What is the first thing that comes to your mind when I say Open Source software? Could it possibly be "Free source code" or "Free Software Foundation"? The first thing that comes to your might night not be licensing schemes and protection of code. Yet just like regular copyrighted software, There are many things that govern what can and can't be done with source code from any Open Source software. Added to that the overwhelming number of recognized Open Source Licensing scheme and you have yourself a plethora of questions that come to mind. Issues to resolve, what you really want people to do with your source code is ultimately up to you. However there are guidelines and goals that you can use as the tools for evaluation a given opensource licensing scheme.
The goal of this article will be to first attempt to clarify what exactly Open Source Licenses are all about. But we will also be looking at what you can think about when defining what you want others to be able to do with the source code of your project. Once we established this, we can then take a look at how to compare your criteria with those found in the recognized Open Source licensing schemes so that you can choose theone that matches the closest your own specifications.
WHAT IS OPEN SOURCE SOFTWARE:
To best define Open Source Software is to use Richard Stallman's definition. IN essense, if a software project is to be open source it should give the users of the program 4 distinct freedoms. Here are these freedoms as stated on the Free Software Foundation website itself.
Of course the Free Software Foundation encourages and supports free software. However, as you can see here, there is nothing that specifically states the program (or any alterations) have to be free as well. Now when you look at these 4 freedoms you need to look at them from the author of a project's point of view. If you write a program, any program or game, and you want users to be able to do all 4 of these freedoms, you can consider Open Source Licensing.
The bottom line is that Open Source doesn't "have" mean Free Source. You have every freedom to create a program (even a commercial one) and distribute the source code to it with your compiled binaries. Most closed source projects entails that if the purchaser of the closed source program needs a modification brought to the program they would typically contact the author of the program and negotiate a deal to have these alterations done to the program. Open Source in a commercial environment would mean that since they have the source code they could decide to bring the changes themselves (or contacting you if they dont have the competence to bring the changes they need to make). But at least they have the choice, the freedom if you will. Besides, well written code distributed with a project is a great side of confidence on the part of the creator and is starting to be quite noticed in both the open source community and the corporate world alike.
OPEN SOURCE LICENSING SCHEME:
Now that you know what defines an Open Source program, let's Assume that you have a project with which you want to allow the four freedoms described above. It's a pretty safe bet that all Open Source Licensing schemes will give the four freedoms above to your project by definition. This means that no matter which licensing scheme you pick the users of your program will be able to read the source code, modify it and distribute them. Thus what remains is what I like to call the aftermath or the consequences of given licenses.
Basically, the main area of discrepancies between the licensing schemes seem to revolve around the fact that open source code should be distributed with your program or not. Some specifically want you to distribute the source code of the program or library with your project that uses it even if your project is a closed source one. Others tackled the subject and seem to give you the freedom to distribute the source code or not with your project. Personally me, anything I write as open source I like to give the freedom to do anything anyone wants with them the question is, is this always the best practice for open source software? Probably not.
The main reason I say probably not is because ultimately allowing the user to put your open source code into a closed source project could cause a grey area in the future. The main reason I typically allow this is because if you are creating a professional application you might now want to send your users to different places to get this and that part of your program, you'd like to give the an installation that they run that includes all that's needed and installs as easily as possible. Some Open Source licenses make this "freedom" very difficult to achieve.
OPEN SOURCE AS A RECOGNITION TOOL:
Aside all the legal issues of licensing software, Open Source Licensing schemes are also there to recognize the authors of the work done. This includes both the original creation as well as the modifications brought to the code. It's a great tool (when used adequately) to document the history of the code based being studied. So when you see that more than one author worked on a particular code it can indicate that the code is good and very refined. There is a limit however. IF your modifications end up modifying the whole program (read a completely new design to perform the intended functionality) then claiming it as your own is allowable since it's 100% your code that merely got inspired by the other code you looked at.
It is also useful for knowing who to contact when a very specific situation (or problem) occurs. AS you know Open Source is a voluntary effort to produce code that others can see, read, learn from and use and as such, some of them can have a long line of authors who brought modifications to the code in very specific areas. It's common knowledge that the author of the code (or the specific modification) is typically the best qualified to bring changes to it or answer questions you might have about it. Hence, this practice is a tool to recognize who did what work on a given Open Source project and a great reference tool to know who to contact about a specific area of the code.
This is even a great tool for the corporate world as well. Even if a lot of businesses dont care to use open source software per se (though that seems to be changing more and more these days) imagine the following situation. You are a business owner, you are looking for a specific piece of software to be done for you, you can go see in the open source community for projects that might come close to what you need. Get in touch with it's creator to see if you can get a development contract that can benefit both of you. The developer won't mind getting paid, you get the most qualified person to develop your solution, it's the best of both worlds.
THE CATHEDRAL AND THE BAZAAR OPEN SOURCE MODELS:
You can't talk about Open Source Software without talking about these two models. Open Source is a very freestyle type of effort. It is both it's strength and it's weakness. Anyone can sit down and code something for the Open Source community, anyone at all. This also implies that the code you're likely to see can very a lot in quality and in organization. You can expect to see jut about all levels of organization and disciplines in the Open Source community. All in all the can be split into what is classically called the cathedral and the bazaar. Let's take a look at both of these as they are defined on the Wikipedia website.
In other words, there are all types of different people creating different types of projects which means that there can be that many levels of implementation. It's all voluntary so you might find projects that took a few hours to develop or you might find projects development by groups of people (or organizations) that reflect a lot more structure and time investments on the part of the authors. People take Open Source seriously at different degrees and so do corporations. Trying to find a specific project (or category of project) can sometimes be a daunting task especially if you're looking for a quick short algorithm rather than a fully fledged application or library. But I believe that knowing the difference between the cathedral and the Bazaar will help you filter out what you dont need.
WHAT YOU CAN DO WITH OPEN SOURCE LICENSING:
Since there are so many Open Source Licensing schemes as well as the other licensing schemes such as freeware, shareware, standard corporate licenses and the likes, how do you draw the line of what can be done? After all my research on the subject I can break things down to Three distinct things you can do to make sure people that look at your code can do what you want them to do with your code. Let's review each of them so you know the difference and the possibilities. This is after doing some research and exchanging emails with people from the Open Source Initiative website (OSI).
The best advice I can give at this point is that if you are making an Open Source project that might have commercial derivatives (either you sell the product itself in the long run or you sell services related to your product). For example, I've seen a music software that is open source (in it's basic edition) and you can buy a professional version of the software. IF you are creating something that might be like this project try using the first two alternative above as im not sure about the exception file (it's just something I use for the projects I dont want commercial links to). But if you are just creating something that is destined to never have any commercially related traces then you can use whatever you want as it's your code and you have the freedom to do whatever you want with it. If you are using other Open Source projects with your creation then the licenses used by those other project is what you must consider when distributing them with your work. It's pretty much as simple as that.
All in all, Open Source is a very widely used entity. As you might have noticed, even some corporation today have developed some Open Source licensing scheme (IBM and Microsoft for example). Open Source is pretty much a part of every software developer out there in one way or another. It's also a very evolved entity. As you can see in the reference links below, if you go to the OSI website you'll see that there's a wide variety of Open Source licenses to choose from. Much like a lot of other things in the software development industry, the Open Source entity is evolving day by day in order to answer the needs of the current reality of Open Source. This will change as new needs and new requirements are manifested. The bottom line is that Open Source is here to stay, it's gaining a lot of acceptance (even in the corporate world) and without a doubt will continue to do so.
Needless to say that all this research I've done on the subject dont make me a copyright lawyer per se, but they did happen to give me some insight on all these discrepancies and alternate possibilities. My email is below (at the end of this article) if you have questions I can either attempt to answer them myself or contact the right people to get the right answers for you. Feel free to contact me with any concerns or questions about Open Source Licenses. Also I invite you to take a look at the reference links below as they also hold a world of details and information that might already have the answers you are looking for. Until next time, keep it real, keep it Open Source.
Here are some reference I use all the time and that I believe were very useful in my composing this article as well as useful for many other things when it comes to my open source software projects.
Interview with Pete Berg by E.K.Virtanen
If I say the name Pete Berg what comes to your mind? To some
perhaps a lot of things, to others it might not even ring a bell. Pete
Berg is probably known by just about any QuicKBASIC (and family of
compilers) programmer that has an internet connection. Some of the more
known things (that can be found online as far as QB is concerned is his
website and a magazine started by him about 3 years ago called QB Express.
E.K.V Let's start with a "stats". Who, where and what?
Pete Well, let's see... I'm a 22-year old guy currently living in Los Angeles, California -- but I'm originally from upstate New York. I grew up in a town that has a population of a few hundred and not even one stoplight, so LA is quite the contrast!
Eventually, I want to produce documentary features and reality tv, and right now I'm working on a few reality shows while I try to start my own production company on the side. (Hopefully I can avoid twenty years of working my way up through the industry before I actually have my own show!) To see some example of my video & film work, visit http://www.peteberg.net
But the way all of you probably know me is because of Pete's QB Site (http://www.petesqbsite.com), which I started when I was 13 and have been running ever since. As far as I can tell, it's been the most-visited QBasic & QuickBasic site on the 'net for the last few years -- thanks mostly to our big tutorials collection and QB Express magazine, which I started in 2004.
E.K.V I heard that you dont program anymore even though you still maintain a very succesful website with most succesful basic community magazine?
Pete That's true -- I dont program in BASIC anymore, even though I run a site about QB and FB. The last time I've coded any significant project in QB was way back in 2001 or so, when I was working on a professional wrestling sim that was part fighter / part RPG, and focused on the "storylines" and drama in the sport. I also had a traditional RPG in the works for several years (so did everybody back then, heheh). Neither of these games ever got a release, because I'm a perfectionist and I was always too busy with my site and other real life obligations to get them finished. I suppose I've always been more interested in the QB community, and helping other people share and promote their programs than in actually coding myself. At this point, I run my site and QB Express out of a sense of loyalty to the QB/FB community more than anything else.
E.K.V There is hundreds of tutorials in your website. You think you can get them even more or are everything worth of publishing in there already? Do you find new QBASIC tutorials anymore from anywhere? Would you call your website now as an archive of QBASIC articles or does it still grow?
Pete The purpose of my site is to be a permanent archive, or library of the QB community. The majority of the old QB sites that were around back when the Qmunity was at its peak (1997 - 2001 or so) have disappeared, and my goal was to make sure as much of that content as possible was still available. Most of those sites were usually hosted by free services, and have since been abandoned, so every day more and more of these sites are disappearing.
I was worried that a lot of that content would get permanently lost, so when I relaunched my site, I spent a few days scouring every QBasic site I could find to collect all of the tutorials. I found close to 700 tutorials in all, and I must say, I did a very thorough job. I'm sure there are some tutorials that I missed, and new tutorials pop up every day, but the majority of the QB tutorials released on the web are available on my site.
That's also not to mention the 200 or so tutorials that have been published in QB Express, which I haven't put in the Tutorials section yet. I would say my site does have the definitive QB/FB tutorials collection.
E.K.V How worried you are with the fact that number of QBASIC users decreases all the time and they moves to other basic dialects or even totally different programming languages?
Pete I'm not worried that users are gradually shifting away from QBasic -- it was bound to happen, and has been happening for years. There are a lot of reasons why this is happening. Most importantly is that modern versions of Windows hardly support QB anymore (Vista especially), and Linux and Mac OS X systems take more of the market share. If you look at the trends in the QB community, a major recession started in 2001 when Windows XP was released, which had Windows NT architecture, and made it incredibly difficult to run MS DOS-based programs. (I, for instance, am running Vista on my desktop and I'm currently typing this in Leopard on my MacBook Pro -- which does not support QBasic programs what'soever.)
The other big issue is that QB is very well-suited for making simple, two-dimensional games, like what we saw in the '80s and early '90s. When QB was really popular, those kinds of games were still being produced for the mass market, and played on a regular basis all over the world. QB coders were motivated because they could create programs that were almost as good as the leading games of the time. In the past fifteen years, however, games have gotten way more complex, with 3D graphics, surround sound, gigantic worlds, online play, etc. -- and users can no longer replicate "professional" games in QB like they used to. I think less young gaming enthusiasts are interested in programming and making their own games in the first place, because they no longer see the quick results that you can create in a 2D or text-based environment.
As for QB users switching to FreeBasic, I think it's very a good thing. FB is a more powerful and accessible dialect of BASIC, and it's almost completely compatible with old QB code. But now users have the ability to access tools like OpenGL, so they can make professional-looking games much easier. There are a lot of FB haters out there, but the way I see it -- what's not to like?
E.K.V QBE magazine is more and more as a FBE (FreeBasic Express) after every issue. There is also lot's of talk about you should rename it. Can you clear now when and if you will rename it or is present name holy, and untouchable?
Pete A few months ago, I was thinking of changing "QB Express" to "FB Express" because usually around 70% of the content is FB-related these days, and I had gotten some complaints from people who mistakenly thought that it was still just a QB magazine. Then I realized, "What's in a name?" The magazine will still have the same content, regardless of what it's called. I also didn't want to alienate the QB users by making it sound like it had become an exclusively FB magazine. Maybe in a few years, when the QB content has dropped to zero, I'll consider a name change again...but for now, I'm going to keep the name.
E.K.V Your website still seems to be mostly for QB users. New comers shows up day after day. Time to time they ask help for things that are easier to create with FreeBasic and sometimes there is a reply "Use fb". How you see this pattern?
Pete It's true that my website is mostly about QB, and that's because I haven't had the time to update it to both a QB and FB website. Aside from QB Express (which is pretty substantial), there's hardly anything on the site that is FB-related. Also, most of the sections on the site haven't been updated since 2004 or so. If I had a few weeks of spare time, I would definitely go through and add quite a bit of FB content. It's not that I'm anti FreeBasic, it's just that I dont have time to do an overhaul on my site.
As for the "Use QB" issue, I've posted my feelings in this thread on my forum http://www.petesqbsite.com/forum/viewtopic.php?t=2479 I dont appreciate it when a QB newbie posts a question, and the other users make no effort to answer the question, instead just recommending them to use FreeBasic. Here's my official policy:
I would much prefer if it people either answer the question being asked (no matter what language it's in), and dont criticize people for the programming language they've decided to use. (Basically a "If you dont have anything nice to say, dont say anything at all" policy.)
That said, I also believe that FreeBasic is a much better language than QB at this point, and I think that the people recommending new users to switch to FB do have a good point. If I were a new BASIC programmer, I certainly would start with FB -- for compatibility and user support issues alone.
E.K.V If you could have time to program, which game genre game would you try first? Is there some favorite game genre for you and perhaps some favorite QB/FB programmer?
Pete If I had time to develop a game, I would probably try to make a 2D Metal Gear Solid or Resident Evil game. I really like 3rd person action/adventure games, especially ones that are heavy on puzzles, and where your player isn't invincible (you have to outsmart, rather than overpower the enemies in both of these games). I also much prefer narrative games, especially very cinematic ones, and actually prefer linear to open-ended games for the most part.
As for a favorite programmer, I have to say I think that I'm most fond of DarkDread's games (Mysterious Song, Secret of Cooey, Lianne in: The Dark Crown). Of all the people to ever contribute to the BASIC games community, he was one of the most prolific and talented programmers ever. I couldn't believe the quality of game he could churn out in just a few days...and every single one of his RPGs was impressive in one way or another. More lately, I've been especially impressed with Syn9 and Cha0s / Josiah Tobin's work in FreeBasic -- just like everybody else.
E.K.V What do you think is the impact of a community around a compiler project? Can compiler such as FB is success with only by itself or are colorful, productive or other kind of persons around of it necessary to have? Is "friendly and helpful" harmony just a dream or does community need a good fights time to time, just like married couples needs to refresh air with a good argue in every few years?
Pete Well, without users, computer code is just a bunch worthless bits and bytes. The fact that FreeBasic has developed a great community is one of the primary reasons people code in it. No matter how small your project, you can share it and receive feedback from a group of your peers who are just as interested and dedicated as you. There may be better compilers out there, but few of them have the tight-knit, helpful and colorful community FB has...and that's why it's so successful. After all, people coded in QB for YEARS even though it was one of the least powerful compilers available. I believe that has mostly to do with the community that surrounded it, because the technology was definitely not anything groundbreaking.
As for the flame wars and the arguments that always happen in the FB community, it's inevitable, and perfectly healthy for this type of thing to happen in any sort of community. Not only does it add interest, but it creates a sense of competition and one-upsmanship that encourages innovation. Where's the fun in everyone always just getting along and complementing each other? You need dissenting voices, and critical people who are not afraid to speak their minds to have a functioning society. Otherwise it starts resembling some kind of totalitarian regime where a few people make all the decisions, and everyone just follows blindly.
E.K.V Would you like to play a game called prophet? Where is and what does Pete Berg do at year 2010? What has happened to your website and remaining users of QB and FB users of today?
Pete Well, at this point, 2010 is just two years away, and I think the QB/FB scene will be pretty much the same as it is right now. My website has been online for nearly a decade, and I plan to keep it online indefinitely (though I can't promise I'll always update it).
I'm sure that QBasic will continue plugging along for the next two years, with a handful of users posting at a handful of forums. People have been predicting the death of QBasic ever since I joined the community in 1997, and it's still alive and well. As for FB, I think the community will stay small and tight-knit. I dont see FB ever hitting it big and becoming a major compiler, at least not in its current form, but I'm sure it will continue to have a moderate following like it has right now.
As for me, I'm hoping to have a job producing documentaries or reality tv shows by then -- not an entry level job, but something more substantial where I have some degree of creative control. And who knows, one of the production companies I'm working to start in my free time might actually take off...that's something I'm working toward. I really dont like the idea of spending my life making other people's dreams come true, when I've got just as many dreams of my own. If you want to be successful, it's very important to go against the grain and take risks, even if they dont all pay off -- and that's why I'm trying to start my own television production company. It might not go anywhere, but at least I can say I tried!
E.K.V Would you like to say something for BASIC programmers who are reading this interview?
Pete dont let anyone tell you your programming language is dead. If you are still using it, it's alive!
Thanks to Pete Berg for this interview.
Open Source Software For A Living: by MystikShadows
Today, looking at the corporate world and the software development industry many of you might wonder "Where do I fit in?" and with reasons. When you look around, what do you see? Software development companies left and right all busy creating either their next product or the next version of they existing product. You go to The Google Search Engine and do a search for something and more often than none it seems that there's already hundreds of software that typically do all, or very close to, everything you need the program do to.
If you've searched for applications in particular you might have noticed that Open Source Software seems to pop up a lot. More and more today it seems that Open Source Software is getting to be quite the popular alternative. Not too long ago, open source was viewed as something typically created in a programmer's basement, lacked any and all kinds of dedication, organization and any level of professionalism. They were viewed as code no one would ever want to use for anything serious and so did most Open Source Projects for that matter. With the creation of the Free Software Foundation and the Open Source Initiative as well as the creation of large scale development tools and business applications in the Open Source community it all served to bring great changes to Open Source in relation to the corporate world. It took a long time, just about two decades, but with patience and perseverance Open Source Software took on a new role in the Software Development Industry.
In this article, we'll look at where the professional developer fits in, not only as per the corporate world but also in the open source community all from a "making a living" perspective. We'll take a look at what you can do, as a software developer, to create an impact, make a difference and stand yourself out of the corporate and Open Source realms so that you can have a chance at making a good living from open source software projects and how you can mix the best of both worlds in your every day programming tasks to get you productive to a professional level. As such this article is for the curious software developers all around the world eager to start something that can help them make it in this industry and introduce you to the jungle that is the software development industry. But before we go into all that let's start with an overview of just what is going on today in both worlds.
TODAY'S SOFTWARE DEVELOPMENT AND OPEN SOURCE REALITY:
Just what exactly is going on today in the software development industry? A whole lot. The whole indsutry seems to be shifting and changing on a regular basis as it pretty much always has since it's birth three or four decages ago. We'll seperate the commercial and the open source entities for now as we get a brief coverage of just what today's reality is.
This is pretty much, in a nutshell, how both words evolved over the past decades. The main reasons for this evolution was of course the growing needs of the users combined with the bigger and faster computers that kept on surfacing (specifically over the past 15 years or so). The needs and the industry itself has been evolving at a rather fast pace and both manage to follow these needs pretty well if I do say so myself. All these caused some barriers between the corporate and the open source words to break. Let's take a look at what happened on that side from both perspectives.
THE CORPORATE WORLD MIXES WITH OPEN SOURCE:
One of the first thing we can notice in the corporate world is that it seems that more and more companies are creating their own O.S.I. approved Open Source licensing schemes. For example, the I.B.M. Public Licence, The Intel Open Source License, the Microsoft Public License and the Microsoft Reciprocal License and there are others too. Likewise some computer vendors now distribute soome flavor of Linux with their computers instead of the traditional Windows PC. This is just to show you how big an impact Open Source has on the industry.
There are more and more examples like this and needless to say that all this is great for both world. The Corporate world gets an OS (and an offfice suite as they typically install OpenOffice in those linux systems too) and the open source world gets recognition for their hard work. It helps to both provide more tools that users can just go ahead and use in their PC and to get them renounced which encouranges the development teams of these Open Source projects to develop the software even more. One of the many examples of a perfect marriage between the corporate world and the Open Source world.
THE OPEN SOURCE WORLD MIXES WITH THE CORPORATE WORLD:
On the Open Source side, one of the great example that really helped the Open Source Community is the fact that some companies are now fully supporting Linux, not just like I mentioned above by selling their computers with Linux installed, some compannies officially distribute and support linux, for example SuSE Linux and Redhat Linux are linux distributions that are supported by the corporate world. There are others as well. Needless to say that the impact of this is that developers of these linux distributions are even more active.
Another aspect of the Open Source world that is gaining popularity is huge projects. Things like the GNU Project and the The Debian Linux Distribution which are project that offer an organization and dedication to their efforts that probably surpasses most commercial projects. This kind of dedication doesn't go unnoticed on the part of the corporate world and as such there are more and more companies using Open Source tools and distributions such as these two in their every day tasks. Both the corporate world and the Open Source world are seemingly starting to work together on a vast variety of levels. This in turn defines our role as software developer into this new reality of today's software development.
THE ROLE OF THE SOFTWARE DEVELOPER IN BOTH THESE WORLDS:
When you look at what's going on today we can see that the corporate and open source worlds are following each other. More and more today we can notice that for much of the commercial application there is an open source counterpart either existing or in the making. This is thrue, at least, for the well known applications of our time which are the application we would typically use on a day to day basis. With this in mind there are still many other programs that dont have their open source counterparts. The software developer's role, I believe, is to take a look at what's out there, see what's missing (in both the commercial and open source worlds) and fill in the gaps so to speak. It's there that often you'll search for an idea or inspiration you have to see if has already been made and you might find that it has indeed already been made. But this is not true for every software idea.
There are big engines that are created, engines like GIS systems, database environments and report generating engines. What is missing is applications that actually make use of these engines. Specifically GIS related applications. And many of the existing tools seemed to be designed for developers, not for the actual users per se. Tools that would simplify the use of these big environments. This is true for many applications and engines out there. It seems the user is left out as the programs are either too complex to use or too simple to be of any use to the users.
In the gaming area, though it's hard to make a game, it's a long time investment but games will always be there. One thing that use to be plentiful back in the 80s, that seems to now have been very neglected is the field of educational games. And im not just talking about kids educational games either. There are a lot of games that test your knowledge, not that many that actually give you knowledge.
As a software developer, today, I believe that this is where the work resides. The gaps between the two ends of the chain so to speak. There is nothing stopping any developer from say creating the next popular GUI if they feel up to it. But the bottom line is one shouldn't expect to make a project as big as this to make a living. Quick tools will more than likely be the way to go. Things that take two big monsters engines and make them talk to each other for example. Or tools that have a niche market that simply hasn't been touched yet. There are many of them if you look hard enough, more than you might be thinking. Maybe all you need to do is take two seemingly unrelated programs and see what can be done with both of them or for both of them. Import/export of data between them for example. It's been done before and can still be done.
HOW THE SOFTWARE DEVELOPER CAN BENEFIT FROM THE OPEN SOURCE WORLD:
Let's give you a quick situation here that has probably happened before or you might be pondering on it as you're reading this. Let's say that you want to start a software development firm. You know 4 or 5 different individuals and they know 4 or 5 different other people. Say you end up with 16 people willing to give this project a chance. Now, what does the Open Source community have to offer you to help you out? You will probably be surprised to learn that there are a lot of open source tools at your disposal. We're going to look at some of them here to give you an idea on what's out there. The idea behind the company is to do both contractual work and develop a series of products that will be commercialized. Hence for the most part, you would need a good set of software design and software development tools. Here is a set of tools you might find quite useful in a situation like this one:
Basically, these tools are there, at your disposal, and as you can see from this small sample they can cover a lot of ground in the software development phase, from the design all the way to distributiona and installation phase. The point is there are there and one might one why developers invest so much time in tools as sophisticated as these given away for free. Some do it for simple recognition, to get known in the software development industry some. Others have a master plan that includes Open Source contributions. There's no doubt in my mind that the open source projects are visited by the commercial world probably a lot more often than you may believe. There is a whole bunch of very interesting projects (today more than ever) in the open source community and when they are organized and represent a lot of serious time investments on the part of the authors of a project, it doesn't go unnoticed.
IDEAS AND POSSIBILITIES FOR THE SOFTWARE DEVELOPER:
Here I thought I would give suggestions on how you can use Open Source for a living specifically. This doesn't just mean to use the tools I suggested in the section above, far from it. These suggestions are based on a research did and it's related observations. You just might find something useful here especially if you're thinking about starting such a project.
these are 4 of the more wide spread open source related commercial possibilities at your disposal. from these you can probably think up something that might mix one or more of these possibilities. I think today, there's nothing stopping anyone from doing anything like this. the best advice I can give is to be broad. To not be affraid to dwelve into the unknown so to speak. If you dont try something in a given field you'll never know if it can work or not and you shouldn't assume it won't work. You can make something that can be used by just about anyone or you can make something that can be used by a specific group of people and you can do that in just about any type of applications (or games) that you can imagine. Just because it hasn't been made definitely doesn't mean it sholdn't be made. It could be as simple as it just hasn't been thought of before. So the key is to not limit ourselves by what we see in the search results and say that well I can find something so i has been made, why should do another? Chances are, the less number of different applications that do a same given task, the more likely the need hasn't yet been completely answered.
THE FINAL WORD: (THE BOTTOM LINE)
Basically, it doesn't matter which programming language you use, commercial or not, BASIC or not even. Today, a software developer can't go through is career path without having to hear about or work with either or both commercial and open source software engineering and development tools. In my opinion Open Source is here to stay and as such it's an endeavour that is definitely worth investing time into. I suspect a lot more projects will be started (and completed) in the Open Source community as well as the corporate world because the needs of the users are still changing and evolving. We will soon embarq on a new wave of completely new software development projects that we just haven't thought about thus far and the more ready for this new phase the better things will be.
Of course, this whole article represents my research, observations, it is based on my past experiences as a software developer along with the development of my own personal projects (some of which I plan to commercialized when they are done). Some of you might have a very different or very similar view on all this than I do. I'd love to hear from you and find out what you think of these commercial and open source worlds, how they have affected you so far and how you believe they will affect you in your software development future. My email is in my name (below in blue) so feel free to click on my and share your stories and visions. Until next time, happy coding, open source or not.
Introduction to sdlBasic by Cybermonkey
sdlBasic is an interpreted programming language developed by an Italian programmer (Roberto Viola). Its core is based on wxBasic by David Cuny. Roberto (a.k.a. vroby) has changed the bindings from wxWidgets to the Simple DirecMedia Layer. So this BASIC is intented to write multimedia applications with. SdlBasic comes with its own Editor which is based on SCITE (see figure 1). It has syntax highlighting and all programmes can be started 'on the fly', just by pressing the green 'go' button. It's really comfortable to use this IDE.
Because sdlBasic is based on wxBasic it has the possibility to 'bind' the runtime with the BASIC code to an executable application. This feature can be enabled by 'Plugins'. So you dont have to mess with the console but your executable file is just one click away. sdlBasic consists of two binary files. First 'sdlBasic' which is the editor and second 'sdlBrt' which is the runtime. So sdlBasic is working under a lot of different platforms, starting with Linux, Windows and MacOS X to more exotic like GP2X and MorphOS. Porting to other platforms should'nt be that hard. So what are the capabilities of sdlBasic? It has a lot of built-in commands which are inspired by the old AMOS. There are commands for grpahics and image manipulation, blitting, sprites and bobs, text draw and screen manipulation. (It is even possible to create a 'dualplayfield' which is a screen with two layers). There is support for sound and music, video Mpeg and CDs. One can scan different input hardware, such as keyboard, mouse or joystick. One has also access to the socket via SDL_Net. The disadvantage of these cpabilities is that one has a large dependency on the SDL libraries. This is especially difficult if one will compile sdlBasic from source.
So what about an example?
Shadow of the Beast demo running with sdlBasic
Pretty impressive (66 fps) for an interpreted language, isn't it? (Okay, okay, if you know FrozenBubble ... which is also written in an interpreted language namely Perl with sdl bindings ... but there is also a port of FrozenBubble to sdlBasic) And here is the (uncommented) source code. I think if you are familiar with any BASIC dialect you should have at least an idea what's going on:
' ' beast demo scrolling ' fps(1) setdisplay(640,480,32,1) dualplayfield(1) screenopen(1,100,40,0,0,100,20,3) autoback(-5) autoupdatebob(0) mousehide soundchannels(0) screen(0) dim x dim y dim v dim l loadmusic ("media/b-title.mod") 'setcolorkey(rgb(255,0,255)) loadimage("media/background.png",0) :x=0:y=0:v=0:l=640 loadimage ("media/beast01.png",1) :x=0:y=0:v=0.1:l=640 loadimage("media/blimp.png",2) :x=displaywidth:y=160:v=0-0.5:l=640 loadimage("media/blimp_small.png",3) :x=0:y=100:v=0.1:l=640 loadimage("media/clouds5.png",4) :x=0:y=200:v=0.5:l=640 loadimage("media/clouds4.png",5) :x=0:y=180:v=1:l=640 loadimage("media/clouds3.png",6) :x=0:y=140:v=2:l=640 loadimage("media/clouds2.png",7) :x=0:y=60:v=3:l=640 loadimage("media/clouds1.png",8) :x=0:y=0:v=8:l=640 loadimage("media/mountains.png",9) :x=0:y=270:v=1:l=640 loadimage("media/grassall.png",10) :x=0 :y=430 :v=2 :l=640 loadimage("media/grass4.png",11) :x=0:y=460:v=32:l=640 loadimage("media/grass3.png",12) :x=0:y=445:v=16 :l=640 loadimage("media/grass2.png",13) :x=0:y=435:v=8 :l=640 loadimage("media/grass1.png",14) :x=0 :y=430 :v=4 :l=640 loadimage("media/tree.png",15) :x=0:y=160:v=8:l=640 loadimage("media/wall.png",16) :x=0:y=440:v=32:l=640 loadimage("media/moon.png",17) :x=500:y=40:v=0:l=64 loadimage("media/splash.png",18) :x=displaywidth:y=0:v=1.5:l=640 loadimage("media/splash2.png",19) 'start while y<480 sprite(1,x,y,1) y=y+v v=v+0.01 screenswap end while pasteicon(0,0,0) pastebob(x,y,17) playmusic(-1) while inkey<>27 i=2 x[i]=x[i]-v[i]:if x[i]<-l[i] then : x[i]=displaywidth: end if sprite(i*2,x[i],y[i],i) for i=3 to 14 x[i]=x[i] - v[i]:if x[i]<-l[i] then : x[i]=0: end if sprite(i*2,x[i],y[i],i) sprite(i*2+1,x[i]+displaywidth,y[i],i) next for i=15 to 16 x[i]=x[i]-v[i]:if x[i]<-l[i] then : x[i]=displaywidth: end if sprite(i*2,x[i],y[i],i) next x=x-v if x< -l*2 then v= -v end if if x>l then v= -v end if sprite(18*2,x,y,18) sprite(18*2+1,x+displaywidth,y,19) if key(k_1) then loadmusic ("media/b-title.mod") playmusic(-1) end if if key(k_2) then loadmusic ("media/beast1_2.mod") playmusic(-1) end if if key(k_3) then loadmusic ("media/beast1_3.mod") playmusic(-1) end if if key(k_4) then loadmusic ("media/beast1_4.mod") playmusic(-1) end if if key(k_5) then loadmusic ("media/beast1_5.mod") playmusic(-1) end if waitvbl screenswap screen (1) locate(0,0):prints("fps:"+str$(fps())) screen(0) end while
By the way this example is converted from a BlitzBasic example which has about 100 lines more of code ...
Qbinux by Sebastian McClouth
On the 28th of April 2005 I posted there the Core ß0.03.
And around May 2005 I joined Pete’s QBSite forum. And what a help I got there.
We’ve seen different versions of QBinux passing by, some working some not.
As I had always done before, I was using real Linux code.
mov ah,#0x03 | read cursor pos xor bh,bh int 0x10
RegsX.ax=&H300 | read cursor pos IntX &H10, RegsX, RegsY
Some other things were a lot trickier, like BCD2BIN and bitshifting. For the bitshifting I made a function, with the help of Ryan Kelly, Moneo, Mystik Shadows, Wyndo, Nathan, DrV (members of Petes QBsite).
After a lot of writing codes and all that I derived with the following:
FUNCTION BitShift (Value%, way$, count%) IF way$ = "<<" THEN x = Value% * (2 ^ count%) temp& = x% temp& = (temp& * (x ^ count%)) AND &HFFFF BitShift = temp% ELSEIF way$ = ">>" THEN BitShitf = INT(Value% / (2 ^ count%)) END IF END FUNCTION
In case that people thing I’m trying to create Linux from Scratch in QuickBasic (PDS 7.1), you’re 50% correct. I’m not gonna make it bootable or anything, Im the end I want it to be a programming environment for the QB/FB-community by the QB/FB-community, just like Linux.
Just like Linux it has to be available to everyone.
It the coming versions, I will not add any GUI, just TUI (Textural User Interface).
Z!re’s Linux clone, Novix, is a big inspiration sourced and due to technical reasons, I’m using it’s filesystem (which I named NVXFS, NoViX FileSystem) for QBinux as well.
Well not much call be told here, since like I’ve said, I’m still developing.
Well till next time, hopefully with a beta-version.
~ TUTORIALS & HOWTO's~
The ABC of the Xblite Programmer by Guy "gl" Lonne
Why writing this article? Because I want to share my own recipes to cook programs in a new programming language. Either you have some programming background and I will show you how to code (very) basic idioms in XBLITE, or you are new to programming and you learn programming using XBLITE, because it is free, open-source and there is an active support for it on the Net. Either way, I will try to provide with some bits of information on XBLITE programming. And if you like my A.B.C, say so and my D.E.F will follow.
Numbers involved in computations can be integer or decimal. For this ABC, I will always refer to integers.
To simplify my programming, I usually resort to the implicit numeric data type, which is XLONG (integer only, remember!). When size matters, that is to say that the numbers you want to work with might exceed +/-2gigas, (precisely 2,147,483,647 for positive numbers and -2,147,483,648 for negative numbers), use GIANT numeric data type by using the '$$' suffix to define that variable as a GIANT numeric data type.
total = sum1 + sum2 perCent = (sum / total) * 100
Gotcha 1: division by zero. Always guard from dividing by zero. This is easy in XBLITE:
IFZ total THEN (*) ' error: division by zero ELSE perCent = (sum / total) * 100 END IF (*)"IFZ total", which is the short form of "IF total = 0"
Gotcha 2: data overflow caused by the multiplication
perCent = (sum / total) * 100
(division first) is OK, but
perCent = (sum * 100) / total
(multiplication first) is risky.
Because you multiply first, and since the implicit data type (XLONG) is used, you must prevent perCent = (sum * 100) / total from overflowing during the multiplication.
To avoid the risk of an overflow, force XBLITE to use the GIANT type for the multiplication:
perCent = (sum * 100$$) / total
Why? Because 21474837 * 100 is an XLONG multiplication and overflows, when 21474837 * 100$$ is an GIANT multiplication and does not overflow.
Decisions: IF and boolean variables
To perform a Yes/No kind of choice, use the IF statement. To remember your choice, use a boolean variable.
IF condition THEN bIndicator = $$TRUE ELSE bIndicator = $$FALSE END IF
I am using also the default type XLONG.
Gotcha: $$TRUE cannot be used in IF $$TRUE = ... THEN
$$TRUE's value is -1 (please, dont remember this); any value tested with an IF (as in IF value THEN) will yield to a true condition if the value is any non-zero value.
So remember that "IF value THEN" is not equivalent to "IF $$TRUE = value THEN". Subtle but let it sink into your mind because you have to remember it. Only IF $$FALSE = ... is accurate, but quite ugly to my eyes.
Make a mental habit that when your inner voice whispers "multiple items" to think loop processing: DO ... LOOP. To remember how many items were processed, use a counter variable.
cItem = 0 ' so far, no item was processed DO IF bDone THEN INC cItem ' done with cItem items LOOP
Gotcha: endless loop
You have to place an IF ... THEN EXIT DO or (even better) an end condition. Always!
DO IF bEndOfData THEN EXIT DO LOOP
DO UNTIL bEndOfData LOOP
Note: counters start at zero, numbers at 1
Here is a number:
cItem = 0 ' so far, no item was processed numItem = 0 ' item number DO IF bToDo THEN INC numItem ' increment before processing ... INC cItem ' increment after processing END IF LOOP
Too subtle for most Programmers, it is unambiguous, at least for you and me.
I also associate "multiple items" with array as a data structure to hold a set of items. With arrays, I associate the FOR NEXT loop. To access to array's items, use an index variable.
Idiom: to walk thru an array
FOR index = 0 TO upper_bound ... NEXT index
Gotcha: array overflow
An array index start at 0 (never 1) and runs up to UBOUND, inclusively; anywhere else, your program crashes.
Idiom: walking thru array arr
FOR iarr = 0 TO UBOUND (arr) PRINT arr[iarr] NEXT iarr
By the way, I always name my indexes: "i" followed by the associated array's name. My convention, maybe not yours: for me, a variable name should bear indication on its purpose. When its purpose is just technical (i.e. array indexing), a variable name such as "index" just states the obvious. I would just use i in that case. If the variable has technical and algorithmic purposes, abbreviations allow to pack both information in the name.
Compare "index" with my convention "iarr"; iarr can be "read" in my programs as:
1. an index ("i...")
2. of array arr[ (".arr")
Sometimes, you have to accumulate a series of amounts (in cents, not dollars because they are expressed with integers, and it is only integers time...).
sum = 0 ' so far, no amount was processed DO UNTIL bNoMoreAmount sum = sum + amount LOOP
Gotcha 1: sum not reset to zero
Gotcha 2: sum too small to hold the total
Remember, GIANT can be your best friend!
Multiple decisions: SELECT CASE
To perform complex choices, use the SELECT CASE statement. To remember your choice, use a switch variable.
SELECT CASE condition CASE 1 switch = 1 CASE n switch = n CASE ELSE switch = 0 ' should not happen! END SELECT
I am using also the default type XLONG, just for convenience.
Hint 1: never use 0 as a normal value for a switch
On the contrary, associate the case "0" to $$FALSE.
Hint 2: never use negative values
Idiom (not for the Fainted at heart): use binary numbers as a generation algorithm for a complex enumeration:
switch = 0 rank = 0 IF condition 0 THEN switch = switch + 1 ' or (2 ** 0) rank = n IF condition n THEN switch = switch + (2 ** rank) ... SELECT CASE switch CASE 1 CASE 2
switch = 0 val = 1 FOR rank = 0 TO UBOUND (aBool) IF aBool[rank] THEN ? "$$TRUE at index"; rank switch = switch + val END IF val = 2 * val NEXT rank
or the equivalent:
switch = 0 FOR rank = 0 TO UBOUND (aBool) IF aBool[rank] THEN ? "$$TRUE at index"; rank switch = switch + (2 ** rank) END IF NEXT rank
I believe (only by intuition, alas) that this is the absolute minimum you should master before you start programming with XBLITE. This handful of XBLITE recipes should avoid you some of the frustration of learning unguided, just by trials and mistakes. But unapplied knowledge "rusts" in brains. dont let that happen! What about taking it from there and coding the guessing game in XBLITE? E.K. Virtanen is craving for an XBLITE version of it to add to his collection. Will you be the First?
Guy "gl" Lonne, 12 December 2007
An Xblite Primer by Guy "gl" Lonne
In my opinion, mastering xblite depends on acquiring knowledge on:
1. Algorithm construction
2. Algorithm translation in xblite
By "algorithm", I mean any process that can be computerized. Algorithm knowledge is fundamental to the programming activity. However, you are here on your own: this primer will not teach you algorithms. If you want to explore this fascinating area, my advice is to do it by reading books, articles, interest groups...
Algorithm translation in xblite is, on the contrary, exactly this primer's goal. I will show here how to express the basic algorithmic bricks in xblite. I tried also to be entertaining; since if "there is more than one way to skin a cat", my preferred way is to pet it to baldness.
II. The venerable "Hello World!" program
Tradition has it that the "Hello World" program is the best starting point to learn a new programming language. There is even a site at URL http://www.roesler-ac.de/wolfram/hello.htm that is dedicated to this very programming atom.
A. "Hello World!" In xblite, console mode
1. What you need:
' Hello World! In xblite, console mode PROGRAM "hello" CONSOLE DECLARE FUNCTION Entry () FUNCTION Entry () a$ = INLINE$ ("Hello World!\n\n\n Press Enter to quit ") END FUNCTION END PROGRAM
2. Some explanations:
At this point, you can start reading xblite manual: in its xblite FAQ, you will find additional information that will more than complete this primer. Take the time to explore the manual. Be clever: learn new keywords and find an immediate use for them. David Szafranski, xblite father, follows the following method: every time he introduces a new concept, he makes a demo program. I tried also to apply this idea to this primer.
B. "Hello World!" In xblite, GUI mode
1. What you need:
' Hello World! In xblite, Windows GUI mode PROGRAM "hello" IMPORT "gdi32" ' Graphic Device Interface IMPORT "user32" ' Windows management DECLARE FUNCTION Entry ()' declare function Entry() FUNCTION Entry ()' begin function ' display a message box MessageBoxA (0, &"Hello World!", &"Hello World Window", $$MB_OK) END FUNCTION END PROGRAM
III. The "99 Bottles of Beer" program: console
Tradition has the "Hello World" priming program, Internet has the "99 Bottles of Beer" equivalent. I found the site http://www.99-bottles-of-beer.net, where 3 joyful fellows, Oliver, Gregor and Stefan, had the idea to challenge the programming community to print the lyrics of the "99 Bottles of Beer" using all existing programming languages known on Earth. For anybody hungry for more, read the article at URL http://en.wikipedia.org/wiki/99_Bottles_of_Beer in Wikipedia: this song is at so many levels!
A. First attempt in console mode:
PROGRAM "conbottles" VERSION "1.0" CONSOLE DECLARE FUNCTION Entry () FUNCTION Entry () FOR n = 99 TO 1 STEP -1 PRINT n; " bottle(s) of beer on the wall," PRINT n; " bottle(s) of beer." PRINT "Take one down, pass it around," PRINT n - 1; " bottle(s) of beer on the wall." PRINT " " NEXT n a$ = INLINE$ ("Press Enter to quit (drinking?) ") END FUNCTION END PROGRAM
B. Improved version:
PROGRAM "conbottles" VERSION "1.0" CONSOLE DECLARE FUNCTION Entry () FUNCTION Entry () line$ = " 99 bottles of beer on the wall, 99 bottles of beer." FOR b = 98 TO 0 STEP -1 PRINT line$ ' b$ = STR$ (b) SELECT CASE b CASE 1 : b$ = b$ + " bottle" CASE 0 : b$ = " no more bottles" CASE ELSE : b$ = b$ + " bottles" END SELECT PRINT " Take one down and pass it around," + b$ + " of beer on the wall." ' line$ = b$ + " of beer on the wall," + b$ + " of beer." NEXT b PRINT " No more bottles of beer on the wall, no more bottles of beer." PRINT " Go to the store and buy some more, 99 bottles of beer on the wall." a$ = INLINE$ ("\n\n Press Enter to quit (drinking?) ") END FUNCTION END PROGRAM
C. When simple is simplistic...
The apparently simple version A has 2 bugs and I had to submit them to David Szafranski to have workaround solutions.
So, I asked the following 2 questions to David Szafranski:
1. Why do I loose the very 1st line: "99 bottles of beer on the wall..."?
Your program prints many lines of text. It exceeds the default number of lines in the console buffer. To add more buffer space you need to use:
IMPORT "xio" hStdOut = XioGetStdOut () ' maxLines is number of lines in buffer maxLines = 500 XioSetConsoleBufferSize (hStdOut, 0, maxLines)
2. Why "PRINT n; " bottles..." prints " n bottles..." with a leading space for n?
The leading space is for negative values. Use STRING$() to remove leading space:
Here is the final version:
PROGRAM "con99bottles" VERSION "2.0" CONSOLE IMPORT "xio" DECLARE FUNCTION Entry () FUNCTION Entry () hStdOut = XioGetStdOut () ' maxLines is number of lines in buffer maxLines = 500 XioSetConsoleBufferSize (hStdOut, 0, maxLines) FOR n = 99 TO 3 STEP -1 ' the leading space is for negative values PRINT STRING$ (n); " bottles of beer on the wall,"; _ n; " bottles of beer." PRINT "Take one down and pass it around,"; _ n - 1; " bottles of beer on the wall.\n" NEXT n PRINT "2 bottles of beer on the wall, 2 bottles of beer." PRINT "Take one down and pass it around, 1 bottle of beer on the wall.\n" PRINT "1 bottle of beer on the wall, 1 bottle of beer." PRINT "Take one down and pass it around, no more bottles of beer on the wall.\n" PRINT "No more bottles of beer on the wall, no more bottles of beer." PRINT "Go to the store and buy some more, 99 bottles of beer on the wall.\n" a$ = INLINE$ ("Press Enter to quit ";) END FUNCTION END PROGRAM
IV. The "99 bottles of beer" program: Windows (TM) GUI
As you surely know, Microsoft developed Windows (TM) using the C language. David Szafranski's goal when creating xblite was to create an XBasic variant dedicated to the development of Windows applications and using natively the Windows API. This was possible because xblite Windows programs are very similar to their C counterparts and can rely on the same programming techniques.
If you want to write flexible Windows application, you must explore the Windows API, which is a very demanding commitment. I recommend the website "Forger's Win32 API Tutorial" at URL http://www.winprog.org/tutorial/. If you have a gold miner soul (and I wish you had), your gold mine will be David's demo programs. After your mining, try to write a collection of idioms in xblite. This is a good way to acquire a solid command of a new programming language.
1. What you need:
Here is a version of the "99 Bottles of Beer" using an Edit Box to display the lyrics.
' #################### ' ##### PROLOG ##### ' #################### ' ' gui99bottles - would sing all the verses of the song "99 bottles of beer" ' if only it could! ' PROGRAM "gui99bottles" VERSION "0.01" ' ' ############################### ' ##### declare functions ##### ' ############################### ' ' xblite DLL headers ' IMPORT "xst" ' xblite Standard Library ' ' Win32API DLL headers ' ' ---Note: import gdi32 BEFORE user32 IMPORT "gdi32" ' Graphic Device Interface IMPORT "kernel32" ' operating system IMPORT "user32" ' Windows management ' ' ################################# ' ##### Function prototypes ##### ' ################################# ' ' These are standard functions that belong to all xblite GUI programs DECLARE FUNCTION Entry () DECLARE FUNCTION InitGui () DECLARE FUNCTION RegisterWinClass (className$, addrCallback, icon$, menu$) DECLARE FUNCTION CreateWindows () DECLARE FUNCTION NewWindow (className$, title$, style, x, y, w, h, _ exStyle) DECLARE FUNCTION NewChild (className$, text$, style, x, y, w, h, parent, _ id, exStyle) DECLARE FUNCTION MessageLoop () DECLARE FUNCTION CleanUp () ' The next function is the callback function for the main ' window. This is where messages are sent when a user ' interacts with the controls in the window DECLARE FUNCTION mainWnd_callback (hWnd, msg, wParam, lParam) ' ' ' ################################################# ' ##### declare and define global constants ##### ' ################################################# ' ' Global Constant which represent the control ID for the "edit" ' control used for the song's display ' (prefix "$$" declares implicitly a global constant) $$lyrics _Id = 9000 ' multi-line edit box ' ' ' ###################### ' ##### Entry () ##### ' ###################### ' ' Application start-up entry ' FUNCTION Entry () STATIC entry IF entry THEN RETURN ' enter once entry = $$TRUE ' enter occurred InitGui () ' initialize win32 controls and libraries CreateWindows () ' create Windows and other child controls MessageLoop () ' the main message loop CleanUp () ' unregister the window class END FUNCTION ' start GUI FUNCTION InitGui () SHARED hInst ' global variable: current instance handle hInst = GetModuleHandleA (0) ' get current instance handle IFZ hInst THEN QUIT (0) ' error: abend! END FUNCTION ' register the window class FUNCTION RegisterWinClass (className$, addrCallback, icon$, menu$) ' ' Returns: ' - an error flag: $$TRUE = error, $$FALSE = OK! SHARED hInst WNDCLASS wc wc.style = $$CS_HREDRAW | $$CS_VREDRAW | $$CS_OWNDC wc.lpfnWndProc = addrCallback wc.cbClsExtra = 0 wc.cbWndExtra = 0 wc.hInstance = hInst wc.hIcon = LoadIconA (hInst, &icon$) wc.hCursor = LoadCursorA (0, $$IDC_ARROW) wc.hbrBackground = $$COLOR_BTNFACE + 1 wc.lpszMenuName = &menu$ wc.lpszClassName = &className$ IFZ RegisterClassA (&wc) THEN RETURN $$TRUE ' error END FUNCTION ' create a window FUNCTION NewWindow (className$, title$, style, x, y, w, h, exStyle) ' ' Arguments: ' - className$: window's class ' - text$ : title ' - style : style ' - x : Left ' - y : Top ' - w : Width ' - h : Height ' - exStyle : extended style ' ' Returns: ' - The window's handle if OK!, 0 = error SHARED hInst ' current instance handle RETURN CreateWindowExA (exStyle, &className$, &title$, style, x, y, _ w, h, 0, 0, hInst, 0) END FUNCTION ' create a child window (i.e. a control) FUNCTION NewChild (className$, text$, style, x, y, w, h, parent, id, _ exStyle) ' ' Arguments: ' - className$: window's class ' - text$ : title ' - style : style ' - x : Left ' - y : Top ' - w : Width ' - h : Height ' - exStyle : extended style ' ' Returns: ' - The child window's handle if OK!, 0 = error SHARED hInst ' current instance handle style = style | $$WS_CHILD | $$WS_VISIBLE RETURN CreateWindowExA (exStyle, &className$, &text$, style, x, y, w, _ h, parent, id, hInst, 0) END FUNCTION ' main message loop FUNCTION MessageLoop () ' ' Returns: ' - an error flag: $$TRUE = error, $$FALSE = OK! MSG msg DO ' the message loop ret = GetMessageA (&msg, NULL, 0, 0) ' retrieve next message ' SELECT CASE ret CASE 0 : RETURN $$FALSE ' WM_QUIT message CASE -1 : RETURN $$TRUE ' error CASE ELSE ' deal with window messages hwnd = GetActiveWindow () IF (!IsWindow (hwnd)) || (!IsDialogMessageA (hwnd, &msg)) THEN ' send only non-dialog messages TranslateMessage (&msg) ' translate virtual-key messages DispatchMessageA (&msg) ' send message to callback function END IF END SELECT LOOP ' forever END FUNCTION ' callback function for window mainWnd FUNCTION mainWnd_callback (hWnd, msg, wParam, lParam) ' ' Message handler: all messages pass thru this function. ' (called by Windows' function DispatchMessage) ' ' Returns: ' - the error code of the default window procedure, 0 = OK! SELECT CASE msg CASE $$WM_CLOSE : DestroyWindow (hWnd) CASE $$WM_DESTROY : PostQuitMessage (0) CASE ELSE RETURN DefWindowProcA (hWnd, msg, wParam, lParam) END SELECT RETURN 0 'OK! END FUNCTION ' This function generates the main window and displays it FUNCTION CreateWindows () ' ' Returns: ' - an error flag: $$TRUE = error, $$FALSE = OK! ' ******************************* ' *** Begin Window Generation *** ' ******************************* ' register the window class for window: mainWnd ' #mainWnd_class$: global variable that holds the window class ' (prefix "#" declares implicitly a global variable) #mainWnd_class$ = "mainWndClass" addrCallback = &mainWnd_callback () icon$ = "" menu$ = "" IF RegisterWinClass (@#mainWnd_class$, addrCallback, @icon$, _ @menu$) THEN RETURN $$TRUE ' error ' create window title$ = "Song \"99 Bottles of Beer\"" style = $$WS_OVERLAPPEDWINDOW x = 309 y = 47 w = 508 h = 433 exStyle = 0 ' #mainWnd_handle: global variable that holds the window handle #mainWnd_handle = NewWindow (@#mainWnd_class$, @title$, style, x, _ y, w, h, exStyle) IFZ #mainWnd_handle THEN RETURN $$TRUE ' "\r\n" are the codes for carriage return and line feed t$ = "" FOR n = 99 TO 3 STEP -1 ' t$ = t$ + STRING$ (n) + " bottles of beer on the wall," t$ = t$ + STR$ (n) + " bottles of beer.\r\n" t$ = t$ + "Take one down and pass it around," n_1 = n - 1 t$ = t$ + STR$ (n_1) + " bottles of beer on the wall.\r\n\r\n" NEXT n t$ = t$ + "2 bottles of beer on the wall, 2 bottles of beer.\r\n" t$ = t$ + "Take one down and pass it around, " t$ = t$ + "1 bottle of beer on the wall.\r\n\r\n" t$ = t$ + "1 bottle of beer on the wall, 1 bottle of beer.\r\n" t$ = t$ + "Take one down and pass it around, " t$ = t$ + "no more bottles of beer on the wall.\r\n\r\n" t$ = t$ + "No more bottles of beer on the wall, " t$ = t$ + "no more bottles of beer.\r\n" t$ = t$ + "Go to the store and buy some more, " t$ = t$ + "99 bottles of beer on the wall." ' *** Begin Controls Configuration *** ' Multiline Edit Control with Vertical ScrollBar style = $$ES_MULTILINE | $$ES_AUTOVSCROLL | $$WS_VSCROLL | $$ES_LEFT | _ $$WS_TABSTOP #lyrics_handle = NewChild ($$EDIT, t$, style, 16, 24, 483, 365, _ #mainWnd_handle, $$lyrics _Id, 0) ' *** End Controls Configuration *** ' ******************************* ' *** End Window Generation *** ' ******************************* ' auto-center main window ' (standard function from Xst.dll) XstCenterWindow (#mainWnd_handle) ' display main window ShowWindow (#mainWnd_handle, $$SW_SHOWNORMAL) RETURN $$FALSE 'OK! END FUNCTION FUNCTION CleanUp () ' #mainWnd_class$: global variable: window class SHARED hInst ' global variable: current instance handle ' unregister the main window UnregisterClassA (&#mainWnd_class$, hInst) END FUNCTION ' ' ' ######################### ' ##### END PROGRAM ##### ' ######################### ' END PROGRAM
2. My tips:
When tackling the API (and GUI mode) for xblite, I would take a working sample (David Szafranski provides with a huge amount of demo programs) and break that down into sections to see for example what needs to be done. Then, I would write a small program to test as much as I can before I incorporate the technique into my real project. Actually, even after mastering some techniques, I still proceed this way to build up programming knowledge in xblite.
V. The "Guessing Game" program
Computer plays the guessing game: guess.x
1. computer asks the User to choose a digit between 0 and 9
2. Computer waits until the go of the User and proposes its first guess: 5 (middle between 0 and 9); it then asks the User to say if it is too high, too low or found.
3. According to the answer, computer proposes the middle of the half-interval, which is the remainder after having clipped off the higher half if the guessed digit was too high, or the lower half if too low; for example 3 if the User said : "too high!".
Here is a version of the "Guessing Game".
PROGRAM "guess" VERSION "1.00" CONSOLE ' ' guess - VERSION "1.00" ' (c) GPL 2007 Guy "gl" Lonne, using xblite ' Source code released under GNU GPL ' ' ***** Description ***** ' ' Computer plays the guessing game. ' 1. Ask the User to choose a digit between 0 and 9 ' 2. Waits until the go of the User ' 3. Propose a first guess: 5 (middle between 0 and 9) ' 4. Asks the User to say if it is ' - too high (h) ' - too low (l) ' - good (g) ' 5. According to the answer, propose the middle of the ' half-interval, which is the remainder after having ' clipped off the higher half if the guessed digit ' was too high, or the lower half if too low; for ' example 3 if the User said : "too high!" ' 6. Count computer's attempts (including the correct ' guess) ' 7. See if this binary search has a maximum number of ' guesses. ' ' This is EASY but it takes time for a modest result. ' Don't get discouraged: it is your first step for a LONG ' trek in XBLITE-land. ' ' ***** Notes ***** ' ' ***** Versions ***** ' 1.00-gl-07dec07-creation ' ' ' ' ############################## ' ##### Import Libraries ##### ' ############################## ' ' xblite DLL headers ' IMPORT "xst" ' xblite Standard Library ' ' ' ############################################ ' ##### Internal Function Declarations ##### ' ############################################ ' DECLARE FUNCTION Entry () ' ' ' ################################# ' ##### Program Entry Point ##### ' ################################# ' FUNCTION Entry () ' if the program was started by mistake, here is an easy way out a$ = INLINE$ ("Do you want to play the 'Guessing Game' with me? (q = quit!)\n>") IF LCASE$ (a$) = "q" THEN QUIT (0) ' to compute the maximum of computer's attempts attemptsMax = 0 DO PRINT "\n\n\n\nThink of a digit between 0 and 9 and I shall read it in your mind..." attempts = 0 high = 9 low = 0 bFound = $$FALSE DO INC attempts ' ' interval check ------------------------------- inter = high - low IF inter < 0 THEN PRINT "Pay attention! You mislead me." attempts = 0 ' Cheater! I reset my attempt count. ELSE SELECT CASE inter CASE 0, 1 bFound = $$TRUE IF high = 9 THEN ' the guess "9" was never proposed myGuess = high ELSE IF low = 0 THEN ' the guess "0" was never proposed myGuess = low ELSE ' guard your program from being mislead by your User PRINT "Pay attention! You mislead me." attempts = 0 ' Cheater! I reset my attempt count. END IF END IF ' CASE inter > 0 myGuess = (inter \ 2) + low x = (inter \ 2) IF inter > (2 * x) THEN INC myGuess PRINT x, myGuess ' CASE ELSE ' guard from being mislead by User PRINT "Pay attention! You mislead me." attempts = 0 ' Cheater! I reset my attempt count. ' END SELECT END IF ' ---------------------------------------------- ' IF bFound THEN PRINT "I read "; myGuess;" in your mind..." ELSE PRINT "I propose "; myGuess END IF ' a$ = INLINE$ ("Is it 'too High! (h)', 'too Low! (l)', 'Good! (g)', 'Quit! (q)?\n>") SELECT CASE LCASE$ (a$) CASE "q" : EXIT DO CASE "h" IF bFound THEN attempts = 0 ' Cheater! I reset my attempt count. PRINT "Cheater! I read "; myGuess; _ " in your mind..." EXIT DO END IF high = myGuess ' CASE "l" IF bFound THEN attempts = 0 ' Cheater! I reset my attempt count. PRINT "Cheater! I read "; myGuess;" in your mind..." EXIT DO END IF low = myGuess ' CASE "g" EXIT DO ' END SELECT LOOP IF LCASE$ (a$) = "q" THEN EXIT DO ' IFZ attempts THEN PRINT "Cheater! Cheater! Pants on fire!" ELSE PRINT "I found "; myGuess; " in "; attempts; " attempts." END IF ' IF attemptsMax < attempts THEN attemptsMax = attempts LOOP IFZ attemptsMax THEN PRINT "\n\n\n\nThe maximum of attempts is zero (does not count)." ELSE PRINT "\n\n\n\nI found in a maximum of"; attemptsMax; " attempts." END IF a$ = INLINE$ ("Press Enter to quit >") QUIT (0) END FUNCTION END PROGRAM
2. My tips:
- Stick to the assignment to the letter:
- Guard your program from being mislead by your User
1. Understand the assignment before writing a single line of code
2. Experiment until you get it right;
3. When it works, it WORKS! Elegant, not elegant or whatever, you can't beat success!
4. When you start the game, I suggest that you offer the choice of ending it; what about if I started the program by mistake?
5. The program must work in all circumstances:
6. I should not be allowed to mislead the program so that it continues to try and climb up to a score that I could render ridiculous.
7. I advise you not to write the text of your messages capital letters; IT IS LIKE SHOUTING AT THE USER!
8. Respect the User interface:
9. I would accept "Y" for Y(es), as well as "y", "L" as well as "l" for L(ow) (I use LCASE$ to take care of this duality) .
VI. Learning to learn
For me, mastering XBLITE programming means:
1. become fluent in XBLITE (what is a IF, a FOR loop...)
2. know how to express the basic algorithms (array, find in array...)
3. build console applications (the Guessing Game...)
4. master the GUI building blocks: 3-control GUI applications (text label/edit box/push button)
5. build User-friendly GUI applications
So, I do follow a method when comes learning a new language. It is not that clear in my mind but at least, I can come up with the following remarks:
1. There is a point to make about code commenting. Comments are invaluable to document your findings. I intend to write a short article on code commenting and I would appreciate any kind of input on this topic. I suggest that you tear apart my own submissions here and say candidly what you think about them. Just remember that the first function of a program is to do the job, just the job and all but the job.
2. I am a believer in idioms. You must constitute your grab-bag of stock answers to recurrent problems. Handling a Yes/No type of entry in one of them.
3. Go back to this quiz say in 6 months; you will measure your progresses by checking that you would handle it differently.
If you are interested in "test-driving" xblite, this is the right place to start. You should shorten your learning curve by studying this primer. But, as I said above, simple does not mean simplistic. There are no shortcuts to mastery. As anything in life, "practice makes perfect". So, read, apply, read more and apply more. And don't forget to give some feedback to the author so that we all have a learning experience.
Guy "gl" Lonne, 26 March 2007
Exit Issue: by MystikShadows
And there you have, Issue #60 must now come to an end. We already have some ideas for the upcoming issue of PCOPY! And of course we more than welcome any suggestions or contributions. So far it looks like PCOPY! Is shaping itself up pretty good, we're still trying new things, new sections to add to the magazine we might try some new regular columns and things like that. This means that now is the time to email us and let us know the things you'd like to see in future releases of PCOPY!.
Maybe you have an idea for an article or article series, maybe you can think of a few things you believe anyone would love to read about, maybe you even have time to write about some of these and contribute them to PCOPY!'s future issues, the choice is yours. Likewise, if you liked an issue, or not, we want to hear from you, it's the best way to get PCOPY! Up to par on what you readers want PCOPY! To be. So dont be shy, we dont bite that I know of (except maybe on a full moon) and we're always glad to hear from you.
And let's not forget that if you use a BASIC that you haven't seen mentioned in PCOPY! Yet we would love to hear from you too. After all, it's one of the main goals of PCOPY! Is to cover all BASICs. As you've seen in the last issue we also love to announce and talk about new BASIC compilers in the making so if you have one of those new projects, by all means, let us know so we can share this great news with our readers.
Until our next issue, this is PCOPY! Signing off...