May 12, 2013

WHILE...WEND loop

The WHILE...WEND loop executes a set of instructions as long as a given condition is true.The syntax of the WHILE...WEND loop is given below:

WHILE  <condition>
<instruction-list>
WEND
where,
condition is a logical expression
instruction-list  is the set of instructions to be executed repeatedly.

Steps Of  Execution-
1. condition is evaluated.

2. If condition evaluates to true, instruction-list is executed, otherwise the control is transferred to instructions immediately after WEND.

3.The WEND statement transfers the control back to step 1.

Example-1
Using the loop in a programme-
CLS
X=10
WHILE X<15
PRINT "The value of X is:";X
X=X+1
WEND
END

Try this in your qbasic and explore more.......

May 05, 2013

Changing the background and text color

Normally, most of you have got bored of this q basic with it's blue and white sober nature.

To give it a tinge of your own style, follow the below process-
1.Click on Options and select 'Display' among the drop-down menu.

2.A Display window appears.see among the colors section.

3.Select the color you prefer for the text in the bar below the  foreground 

4.Select the color you prefer for the background in the bar below the  background.

5.Click 'OK' to confirm your settings.

May 04, 2012

Color statement and color codes

The color statement is used to change the color of the text or graphics.
COLOR <Color code>

where , 

Color-code = the number that sets the color.


The number that sets the color are as follows-

 Color                                 Color code

      1                                                              Dark blue
      2                                                              Dark green
      3                                                              Dark cyan
      4                                                              Dark red
     5                                                               Dark magenta
     6                                                                Magenta
     7                                                                White
     8                                                                Grey
     9                                                               Light blue
   10                                                               Light green
   11                                                               Light cyan 
   12                                                               Light red
   13                                                               Light magenta
   14                                                               Yellow 
   15                                                              Bright white                                                                                                        

Screen modes

You may have got the doubt of the statement 'SCREEN X' in my commands.Normally,  Q basic is in default the screen 0, which is text mode. The other screens from  1 to 13 are in increasing resolution as follows-


          Screen 0                      -                  80*25 -Text mode only
          Screen 1                      -                  320*200 -graphics
          Screen 2                      -                  640*200 -graphics
          Screen 7                      -                  320*200 -graphics
          Screen 8                      -                  640*200 -graphics
          Screen 9                      -                  640*350 -graphics
          Screen 10                    -                  640*350 -graphics
          Screen 12                    -                  640*480 -graphics
          Screen 13                    -                  320*200 -graphics 


Screen statement- 
                SCREEN < MODE >
   where, 
 MODE = the number that sets the screen mode

March 19, 2012

Finding a square root of a number

Normally, you may had come across situations in which you may have to find square roots of some 10 digit numbers.The syntax of finding a square root -
                                                    SQR ( N )
where,
         N = the number of which you need to find the square root.

Example-
1)  Finding square root of 25
      CLS
      PRINT SQR (25)
      END

  Rejoice !!!
  You can also find square roots of non-square numbers upto four decimal digits.

March 07, 2012

Drawing a circle

Let's learn how to draw a circle and arcs-
              First of all, don't forget to type " Screen 9" because normally Q basic is in default screen 1 in which figures cannot be drawn.

The syntax for drawing a circle or an arc-
                     CIRCLE ( X, Y ) , R , C , SA , EA
where,
         ( X , Y ) =  the coordinate of the center of the circle.
         R           =  the radius of the circle
         C           =  the colour code which is optional
         SA         =  the starting angle if you want to draw an arc
         EA         = the ending angle of the arc

Examples-
1. Drawing a circle-
                         CLS
                        SCREEN  9
                        CIRCLE  ( 60 , 60 ), 20 , 9
                        END
This draws a circle with radius 20 pixels at the pixel pointed (60,60)  in blue.

               Don't just draw circles, try concentric circles, intersecting circles and complex figures and pictures using circle and line commands.

Drawing a Line

Today, let's learn to draw a line -

        Before all , remember that you have to type "SCREEN 9" in the type area of Q basic.
The syntax of the command to draw a line-
                 LINE  ( X1 , Y1 ) - ( X2 , Y2 ), C , ( B , (F))
Where,
      ( X1 , Y1 ) = the coordinate of the starting point of line
      ( X2 , Y2 ) = the coordinate of the ending point of line
       C = the color code
       B and BF = used to draw an empty or filled rectangle respectively in which ( X1 , Y1)-( X2, Y2) specify diagonally opposite corners.

   X1, X2 represent the column number
   Y1, Y2 represent the row number.

Examples-
     1.  Drawing a line-
                   CLS
                   SCREEN 9
                   LINE (10,10)-(100,100), 9
                   END
            This draws a line from the pixel pointed 10,10 to the pixel pointed 100,100 in blue.  

               Don't just draw a line and feel happy seeing it.
               Try complex figures and matrixes.