Hello again, my 5th tutorial. Not bad! In this one we cover INT, RND, VAL, STR$, CHR$, ASC, COLOR. These can be very useful in a tight spot, so to speak. How about we begin with INT? What am I asking you for, it's my tutorial after all. INT means integer, and for those of you who don't know what one is an integer is a whole number, like 5 or 1000 but not 7.5 The INT command can turn decimal numbers into integer. There's hardly a need for a full exmaple program so heres a quick look. INT (7.9) will return the value of 7 (remember the INT command doesn't round numbers!) What a quick leanrer you are you now know INT! Now onto the RND command. This will return a random number for your program to make use of. INT (RND * 10) + 1 "hey lookie there the INT command is back!" that's right, in most cases using RND you need the INT command this is because RND is used to giving numbers to about 7 decimal places but you only need the integer. We multiplied it by ten to say "I want a number between 1 and 10" and then at the end we add one (unless you want a number between 0 and ten, then take it off) WOW, you're doing good today, you've already learnt two things and we havn't even got onto a second page yet! Anyway lets keep up this learning streak and get to know VAL and STR$ VAL can turn a string (text as you should already know) into a numerical value. It can be useful when you want to test a string with mathematical operators. Take a look at this: '-------------------- CLS N$ = "5" IF 10 + VAL(N$) = 15 THEN PRINT "CHECKMATE!" '-------------------- The programs begins be N$ the number 5, although 5 is a number it is stored in a string and therefore must be treated as text. The next line is an IF, it wants to see if 10 plus what ever N$ is equals 15. So, because you cannot do math with a sstring we have to turn into a number, this is the job of VAL. 10 + 5 = 15 so the output is 'CHECKAMTE!'. If you were to replace the number 5 with a letter then VAL (n$) = 0 because a letter is not a number so VAL makes it 0. STR$ does exactly the opposite of VAL! It can turn a number into a string, observe: '-------------------- CLS N = 5 IF STR$(N) = "5" THEN PRINT "STALEMATE!" '-------------------- Not the best example, but good enough, notice that once STR$ has made N a string we had to test it with two "" around the number. Just three more things to learn from this tutorial, and two of them you'll learn now. The CHR$ command, it can return the ascii code for a letter, number or symbol. "What is ascii" you might say, well an ascii table is a list of numbers and symbols, in QBasic each and every symbol and character you can amke has a number, for example the ascii code for the letter A is 65. This means that if we put the letter A into the CHR$ we will get 65: '-------------------- CLS PRINT CHR$("A") '-------------------- On the screen all you get is 65. Now some of you might have guessed that ASC is the opposite of CHR$ well you are absolutaly right! Instead of a long explanation I'll just show you... '-------------------- CLS PRINT ASC(65) '-------------------- The output is A! So to comclude this CHR$ turns a chracter into a ascii code number and ASC turns the ascii code into the symbol is represents. Now for the final thing for this tutorial. As you may have noticed this tutorial has been all anout things you can do with text and numbers, and the COLOR statemtn is no exception. COLOR, among other things can change the colour of text (it can also change the background colour but that's for another tutorial) It's simple to use, I'll give you an exmaple of it in use and leave it at that: '-------------------- COLOR 1 PRINT "HELLO" '-------------------- Ok perhaps a bit of help with it. The number after the word COLOR is a color attribute. The number 1 means blue. Look at the table below for the list of the colours available: | COLOUR |COLOUR ATTRIBUTE| |---------------|----------------| |BLACK | 0 | |BLUE | 1 | |GREEN | 2 | |CYAN | 3 | |RED | 4 | |MAGENTA | 5 | |BROWN | 6 | |WHITE | 7 | |GREY | 8 | |LIGHT BLUE | 9 | |LIGHT GREEN | 10 | |LIGHT CYAN | 11 | |LIGHT RED | 12 | |LIGHT MAGENTA | 13 | |YELLOW | 14 | |BRIGHT WHITE | 15 | \--------------------------------/ This gives you 16 different colour to play with. Later we will find that you can actually have 256 differnt colours, and it is even possible to get over 65526 colours! By changes the number after the COLOR statement you can have different coloured text. Hope all this helps you out, bye for now.