Friday, August 29, 2008

C Programming: Turbo C++ 3.0

The first C IDE that I use is Turbo C++ 3.0 by Borland. It is a DOS base IDE, but offer wide range of functionalities for us to get start quickly. You can get your copy of Turbo C++ 3.0 here.



The interface for TC30 is very simple. All the important executables is in BIN directory. Make sure you update the "Options -> Directories" to point to the correct location.



There are tons of examples in Turbo C++, and the major one is a spreadsheet program. Of course, we cannot compare it with Microsoft Excel, but it does come with quite some functions.

For graphical programming with TC30, we can use the default Borland Graphics Interface, but the power of it is very limited. I will explain a little bit further on how to access VGA and SVGA mode in TC30.

QuickBasic Programming (2)

If we are to getting serious with QuickBasic, we should have a better IDE that can generate executable file. Microsoft Quick Basic 4.5 will be the best option. You can download it here.



There are quite some examples come together with QB45. One of the good one is sort demo. With sort demo, we can see the differences between various sorting algorithm visually, and understand their individual sorting speed.



The other example is generating torus. We can set the different parameters to generate different type of torus. And, after torus generation, there are running colors for us to enjoy too!

Tuesday, August 26, 2008

Analysis on Permatang Pauh By-Election



Today is an important day for Malaysia. Let us study the by-election results:

PKR: 31,195 (66.64%)
BN: 15,524 (33.16%)
AKIM: 92 (0.20%)
Majority: 15,671
Turnout: 81.01%

And now let us look at the Permatang Pauh constitution:

Total Voter: 58,459
Malay: 69.5%
Chinese: 24.57%
Indian: 5.8%
Others: 0.13%

I assume that 75% of non-Malay vote for PKR, we will get the following breakdown:

PKR: Malay (20,533) + Non-Malay (10,662)
BN: Malay (11,971) + Non-Malay (3,554)

That means, 63% of Malays, mostly from kampung, still pick PKR after 10 days of dirty tactics and racial bombardments by BN.

We should feel proud with the result as this clearly shows that Malaysians are moving away from racial politics and start accepting the Rakyat concept.

Bravo Malaysians!

Sunday, August 24, 2008

Venturing into C Programming

The programming language that I use after mastering QuickBasic is C. At that time, I was thirteen. The main reason for switching from QuickBasic to C was simple, I've met the limitation of QuickBasic. I realized that with QuickBasic, I cannot really develop any high performance applications. I still remember, the PC that I used was a 80286 16MHz. And with QuickBasic, to produce a more graphical intensive applications is impossible.

The first C programming IDE I used was Turbo C++ Version 3.0. As you can predict, swithing from QuickBasic to C really need some hard work. Suddenly, I have to deal with a lot of new idea like header files, variable declaration, pointers, data types, and a semicolon after each syntax.

I cannot remember the two books that I used to learn C, but I remember one of it sounds like "Complete Reference of C Language", and the other sounds like "Game Programming Guru". I spent almost 6 months to learn the language before I can produce something useful. The "Game Programming Guru" help me a lot in mastering some important game programming concepts like double buffering, direct memory access and 3D engine development.

After confident enough with my skill, I decided to produce my first commercial application.



My first commercial application is a questions bank application to assist teachers to prepare test papers and students to do their revision.



The product was completed two years later when I was fifteen. I sold it to teachers and students in my schools and other schools nearby. I make almost 10K after three months. It was the first time I made money from developing application. The feeling was great!

Until today, C is still my preferred language in developing application. But of course, it is not the plain old C language that I use, it is C# that I use now.

Thursday, August 21, 2008

QuickBasic Programming

After touching LOGO for a few months, I've been introduced with QuickBasic. I still remember the person who introduce QuickBasic to me told me "Hi, stop playing with that puny turtle, let's try QuickBasic and start writing your own computer games now!". Writing games? Wow, that's a totally new idea to me. I can write games with QuickBasic! To me, it is LOGO which give me the idea of programming, and it is QuickBasic that open the whole world of programming to me.

Similar with LOGO, QuickBasic is an intrepreter, that means we cannot really develop high performance application with it, but it do carry enough features to write almost every kind of simple applications and simple games.

Okay, let us start some action now. Before getting into action, you can download the QBASIC interpreter at here. Unzip it into any folder and run it. It should run perfectly under Windows XP and Windows Vista.

As an introduction, try the following code:

SCREEN 13
FOR I = 1 TO 100
COLOR I
CIRCLE (160, 100), I
NEXT




Press F5 to run the program. You will see a colourful circle immediately. Amazing right?

LOGO Programming Series (2)

On the previous post, I touched about FORWARD and LEFT. Of course, with just FORWARD and LEFT won't do much. Here is a more complete list of syntax for controlling the turtle:

1. FORWARD
2. BACK
3. LEFT
4. RIGHT
5. PENUP
6. PENDOWN
7. HOME - move turtle back to center
8. CLEAN - clear the drawing space

PENUP and PENDOWN is used when we want to draw a dashed line or move the turtle to somewhere without leaving the trail. For example:

FORWARD 10
PENUP
FORWARD 10
PENDOWN
FORWARD 10

will produce the following result:



And to produce greater things, we have to use the powerful REPEAT.

Try the following code

REPEAT 10 [ FORWARD 100 LEFT 108 ]

and you will see this



With little creativity, we can produce greater result. Try the following code:

REPEAT 10 [
PENUP
LEFT 36
FORWARD 80
PENDOWN
REPEAT 10 [ FORWARD 50 LEFT 108 ]
PENUP
BACK 80]

and we will get



To draw a circle, use the following code:

REPEAT 360 [ FORWARD 1 RIGHT 1]

Have fun trying your own code!

Wednesday, August 20, 2008

Upgrade Laptop Hard Disk Without Reformatting

Recently I decide to upgrade my 100GB laptop hard disk to 320GB due to seriously lack to disk space. After searching all the net, I end up with Acronis Migrate Easy. You can use this software for free for 15 days. So, make sure you get the largest available hard disk for upgrading. If not you will have to pay on the next upgrade. For me, I purchased it as the license cost only USD39.99.

Using Acronis Migrate Easy 7.0 is simple.



1st, connect the unformatted new hard disk using USB cable.

2nd, run Acronis Migrate Easy and choose Disk Clone.

3nd, the program will decide the partition size automatically and reboot the computer.

4th, after reboot, Acronis will run the migration process automatically. I wait around 3 hours for 100GB migration.

5th, shut down computer, remove old hard disk, plug in new hard disk, and it's done!

My C: grow from 30GB to 93GB while my D: grow from 60GB to 204GB. It's really exciting to see lots of free space on my laptop! All software on my computer run perfectly after migration except Adobe products that need reactivation.

When I upgrade my hard disk previously, I need to spend almost one day to reformat, reinstall the operating system, reinstall all the software and customize to the state that I like. Now, with Acronis Migrate Easy, it's a breeze!

Tuesday, August 19, 2008

Learn Programming Easily with LOGO

When I first touching programming in 1988, it was not very common in Malaysia. The first programming language that I learn is LOGO. Even though it is a very simple programming language, it is great in instilling our interest in programming. In LOGO, we basically use some simple syntax to command a cursor to draw. LOGO is a very old program that first appears in 1967. You can still download the free MSWLOGO (here) or ACSLogo (here) interpreter to have a try. It’s fun!

In LOGO, we call the cursor “turtle”. We can use simple commands like “FORWARD”, “LEFT”, “RIGHT” to make the turtle move. Try the following:

FORWARD 100
LEFT 144
FORWARD 100
LEFT 144
FORWARD 100
LEFT 144
FORWARD 100
LEFT 144
FORWARD 100

Copy and paste it into UCB Logo, you will see a star!




It’s even better for you to paste line by line to see the turtle in action.

It was this star that ignite my programming passion until today.

I will follow up with more examples on my next return. Keep in touch!