Site hosted by Angelfire.com: Build your free website today!

The LINE Statement

By QBasicBoy



While you use these commands, it is always good to use screen 12, screen 9, or screen 13

First of all, lets look at the LINE statement itself:
LINE (X, Y)-(X, Y), color


First of all, what we have here is two coordinates. The first set is in the first parenthesis, and the second, in the second set of parenthesis. The hyphen represents the joining of these to points, thus creating a line.

Here is an example of some QBasic Code for a line:
CLS
SCREEN 9
LINE (100, 100)-(200, 100)


This creates a horizontal line. This is because it creates a point 100 pixels over and 100 pixels down, that connects with a point 200 pixels over and 100 pixels down. You'll notice that I didn't put a color attribute in that code, without a color attribute, QBasic automatically makes the line white. A line with the color attribute, would look like this:
CLS
SCREEN 9
LINE (100, 100)-(200, 100), 4


This creates a red, horizontal line, because the color attribute is 4, and in screen 9, when a color attribute is asked, 4 = red!

You can also use the LINE statement to make a box. The code for that includes an extra attachment of the ",B" or ",BF" statement. The code for a box in QBasic would look like this:
CLS
SCREEN 9
LINE (100, 100)-(200, 200), 4, B


This creates a hollow box with a red border. To fill in that box, you would simply replace 'B' with 'BF'.

In that program there are two coordinates; 100, 100 and 200, 200. QBasic connects 100, 100 to 200, 200 and uses those coordinates to estimate where, and how big, the box would be!



I hope this tutorial was self explanitory. If you still have questions about the LINE statement, feel free to e-mail me.

Created by QBasicBoy
Last modified 7-7-99