MobileBASIC midlet tutorial Chapter 1

by funtikar

Have you ever thought of programming on the phone? Well, now you can with MobileBASIC midlet. This is chapter one of my tutorial series. I will explain some basic stuff and show you how to create the famous HelloWorld program.

I assume you already have your MobileBASIC midlet,if not then download it at http://xplayfuntikar.mywapblog.com/files/jazip.jar. Okay, the MobileBASIC(MB) midlet uses number to address lines of code. Usually it starts with the label number 10 and steps 10 each label. At line 10, type PRINT "Hello World!" then press enter. It will show line number 20. At this point you can already run the program by pressing your phone right soft key and select RUN. Watch the result.

Variables_
You have to use your imagination to understand this. Picture a box which you can place things inside such as a Television or a pile of book. Variables are just like that you can place any value in it. There are two types of variable the first one is string type variable which is denoted at the end of the variable's name by a $ sign,for example varname$ . The second type is integer type variable which is denoted by % sign ,for example varname%.

Let's see some example.
10 strvar$="pocoyo"
20 intvar%=20
30 print strvar$
40 print intvar%

Now if you run this it will print the value of each variable. To store a value to string variable you must write the variable name and its type in the end of the name ,after that type the = sign and type the value with the parentheses. Just like above. For integer type variable its the same but without the parentheses.

Okay to make it a little more interesting do this.

10 strvar$="pocoyo"
20 intvar%=20
30 print "my name is "+strvar$+" and im "+intvar%+" years old."

using + sign with some strings you can stick them together to form a single string. Run it and you'll understand.

INPUT command_
You can use INPUT to retrieve user's input to a variable.
Example
10 input "type your name",varname$
20 print "your name is "+varname$

This will retrieve input and store it to variable varname$

well thats it for chapter one. You will have to explore these commands that i taught you until chapter 2 comes out.

Greetings to
Askurfriends
Prodigits S40
Sabahwap

contact:funtikar(at)gmail(dot]com
site:http://funtikar.xtgem.com


XtGem Forum catalog