Saturday, 11 April 2009

First Steps

If you haven't already then install JustBasic

Create Your First Program

Run the program and Select File --> New to open a new file or click the furthest left icon (a blank piece of paper)
You may notice that there is a very limited array of tools and menus and there is a dauntingly large white space but don't worry we'll have it filled with code in no time.

To prove that programming code doesn't have to be confusing and complicated have a go at understanding this snippet of code by translating it into plain English.
The code:

prompt "Enter a number...";number
print "17 times the number you chose equals ";number*17
wait
Now copy and paste the code into your JustBasic window and run the code by pressing the 'Run' button (a large 'play' button in the toolbar) or by hitting Shift-F5.

The first line prompts the user to enter a number and this brings up a dialog box as shown below. After entering a number and pressing OK the program stores this number in a variable called 'number'. The program then prints (displays in the main window) a string of text followed by the result of the inputted 'number' multiplied by 17.




Congratulations you've made your first program in JustBasic and maybe even your first ever program. On the down side, you didn't actually do anything apart from copy and paste and the program isn't very useful unless you want to practise your 17 times tables...

For practice i suggest that you modify the code so that two numbers are inputted by the user and the program multiplies them together and prints the answer. This will not require the knowledge of anything that hasn't already been taught (not much admittedly) and may only take a few minutes but is a valuable exercise.

See My Proposed Solution


This is slightly more useful; perhaps a remedy for calculators with the multiply button stuck inside the body of the calculator, but more probabbly not.

Next Steps

On to something more fun then: creating a program which might actually make you some money if you're friends, like most people, get a bit hazy when it comes to understanding probability.

I suggest you open this reference page and bookmark it as it will be very useful to you if you need a bit more information on understanding some of the commands in JustBasic. The included help file is also very useful unless you're running Vista where running the help file will helpfully inform you that Microsoft have decided that you're not allowed to be helped. If this happens to you then microsoft offer a solution or you can access the online help documentation for LibertyBasic (JustBasic's big sister) which is mostly identical.

Move on to your first useful program - Tails Never Fails

No comments:

Post a Comment