______________________________________________________________________________ | SECTION 1 PART B SUBPART 1 | Basic Tutorials - Part 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BASIC Tutorials - installment 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Howdy! 8-) So what do you want to learn this week starting BASIC programmers? I thought I'd go over a few BASICs (pun) and some useful routines. If you want to have basic tutorials on anything else then mail the fanzine and I'll be happy to type them up for you! Recap: - Variables are memory stores. - Variables with text in are proceeded with a $ - Variables to store numbers are usually proceeded with a % So the following program would take your age and store it in age%. PRINT "Age:" INPUT age% A new format of the INPUT command: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In the previous example we displayed the question we wanted to ask 'Age:' with a print routine. We can simplify that whole previous routine into one INPUT command, look at this: INPUT "Age:",age% Basically what this means is that after the prompt 'Age:' is displayed then read in the age and place it into age%. Look at the following: INPUT "Name:",n$ Common-sense should tell you that that command would display 'Name:' on the screen and then place whatever you type into n$. Looks so simple, doesn't it? Other commands which are useful to use: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We can use other commands in conjunction with the INPUT and PRINT commands to make it all look prettier. The first command is CLS . Looking at it it means: CLear the Screen = CLS That will clear the screen of all of its text and leave you with a clean screen to place text on. There is also another command which you will find useful. It is called COLOR and yes I know it is spelt a bit strangely but thats the American way of spelling it (although I assume 90% of readers are American). 8-) Anyway this command is followed by a number which dictates what colour the text will be shown as: 0 - Black 1 - Blue 9 - Bright Blue 2 - Green 10- Bright Green 3 - Cyan 11- Bright Cyan 4 - Red\Brown 12- Bright Red 5 - Dull Purple 13- Bright Purple 6 - Brown 14- Bright Yellow 7 - Dark White 15- Bright White 8 - Dark Gray You can place a COLOR command before any PRINT or INPUT command to change the colour of its text. Look at this: CLS COLOR 15 PRINT "Details Program" PRINT "" COLOR 6 INPUT "Age?",age% COLOR 14 INPUT "Name?",n$ CLS COLOR 15 PRINT age% PRINT n$ As with the INPUT command the PRINT command can also have variables attached to it for it to print. For example if the previous program could actually say 'Hello [your name] You are [age] years old.', it would be better. It can! Look at this example of the print command. PRINT "Hello, ",n$ print "You are ",age%," years old" If you can get your head around the working of this then you'll be a master in no time. In Closing ~~~~~~~~~~ I'll be going into explaining the last piece of code in the next fanzine. It'll be part 4 of the Basic Tutorials. Part 5 will cover location, loops and logic. After that more tutorials will follow but in more specific areas of BASIC. Cheerio -------------------------------------------------------- * EDITOR'S NOTE: * This article was originally printed in Peter Cooper's BASIX Fanzine, * Issue #4 from January 1996.