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






You can click on the URL below to see the new Qbasic page there. Please leave me your feedback in the forums and I will respond. I would like to explain also that I was heavily attacked by spam back in the days and didn't get a lot of your messages. Anyway, just would like you to know everything is good now.

www.programmermind.com/Qbasic.html

My academic level is:

Your Name:

Email Address:

SUBMISSION BOARD: Reason for visiting:
Also please include an email address

Click here to see programs that were requested on the submission board.
ProgrammerMind Web Site

Qbasic with Programming

Introducing programming for the Qbasic community. Below are a list of alphabetized commands. The black text is the command defined. The white text is the sample program. Finally the black box shows the result or output of the program. Please note: The "," appearing after the PRINT command creates a tab(separation) between the two variables. When you run the Qbasic programming containing the "," you will see what I mean. This is only a few of the most common commands used.

CLICK HERE IF YOU WANT YOUR GAME REVIEWED


* ABS (Absolute value of a number):

SCREEN 0:CLS
My.Number1 = -255
My.Number2 = 128
PRINT ABS(My.Number1),ABS(My.Number2)


255 128
* AND (Performs bit manipulation):

SCREEN 0:CLS
Nate=15
Julie=25
IF Nate=15 and Julie=25 THEN PRINT "Brother & sister"


Brother & sister
* AS (Names a variable type when used with COMMON, DECLARE, DEF FN, DIM, FUNCTION, REDIM, SHARED, STATIC & SUB statments.):

SCREEN 0:CLS
DIM Textvalue AS STRING * 17
Textvalue = "Wecome to Qbasic"
PRINT Textvalue


Welcome to Qbasic
* ASC (Returns the ASCII value of a CHR$ statement):

SCREEN 0:CLS
DIM Disk AS STRING * 1
Disk = CHR$(ASC("#"))
Disk.word$ = CHR$(68) + CHR$(105) + CHR$(115) + CHR$(107)
PRINT Disk.word$, Disk


# Disk
* BEEP (Sends a beep sound to the PC speaker):

SCREEN 0:CLS
DIM Beep.word$ AS STRING * 5
Beep.word$ = "Beep!"
FOR H=1 TO 5
BEEP
PRINT H, Beep.word$
NEXT


1 Beep!
2 Beep!
3 Beep!
4 Beep!
5 Beep!
* BLOAD (Loads a sprite image from disk -created by the BSAVE command.):

SCREEN 13:CLS
DIM Player(129)
Player.X = 10
Player.Y = 15
Dir$ = "c:\sprites\"
DEF SEG = VARSEG(Player(0))
BLOAD Dir$ + "player.spr", VARPTR(Player(0))
PUT (Player.X, Player.Y), Player, PSET
DEF SEG

* CALL (Launches a user-defined subroutine):

DECLARE SUB Display.Text(x, y, c, Word$)
SCREEN 1:CLS
DIM Text.message AS STRING * 29
Text.message = "This is a Subroutine running."
View$ = Text.message
CALL Display.Text(5, 10, 7, View$)
' Sub begins here...

SUB Display.Text(x, y, c, Word$)
COLOR c, 2:LOCATE y, x:PRINT Word$
END SUB


This is a Subroutine running.
* CASE (Selects a entry below based on the expression):

SCREEN 0:CLS
Main:
PRINT "TYPE A O TO END THE PROGRAM"
INPUT "Enter your age please."; Age;
IF Age<1 THEN END
INPUT "Now enter a number from 1-100";Years
IF Years<1 OR Years>100 THEN END
Old = Age + Years
Check.age:
SELECT CASE Years
CASE 1 TO 100
PRINT "In ";Years;" you will be the age of ";Old;"."
PRINT: GOTO Main
CASE 0
END
END SELECT
GOTO Check.age


TYPE A 0 TO END THE PROGRAM
Enter your age please? 14
Now enter a number from 1-100? 25

In 25 years you will be the age of 39.
* CHAIN (Loads in a new program):

SCREEN 0:CLS
DIM Directory AS STRING * 11
DIM File AS STRING * 7
Directory = "C:\WINDOWS\"
File = "WIN.INI"
CHAIN Directory + File


[windows]
load =
Nullport = None
device = Cannon Bubble Jet BJC - (Copy 2), CANON, LPT1:
ScreenSaveActive = 1
NOTE: The WIN.INI file will be displayed (as above) when you run the CHAIN program. Caution, don't make any changes to the WIN.INI file as this can affect changes to Windows 95/98/2000/ME/XP.

I just used WIN.INI to demonstrate how easily you can load in txt files or ini files in Qbasic, using CHAIN.

* CHDIR (Sets or changes a drives directory):

SCREEN 0:CLS
DIM Directory AS STRING * 11
Directory = "C:\WINDOWS\"
CHDIR Directory
FILES "*.BMP"


WAVES.BMP PINSTR~1.BMP TRIANG~1.BMP BLACKT~1.BMP
SETUP.BMP STRAWM~1.BMP BUBBLES.BMP CIRCLES.BMP
..............................................
Will point directory at the Windows directory on your root drive and display all the bitmap files in that directory (FILES "*.BMP").
* CHR$ (displays the character set of your pc):

SCREEN 0:CLS
FOR cycle = 1 TO 255
PRINT CHR$(cycle);
NEXT


will cycle through the entire ASCII PC character set. NOTE: Not all characters will be visible.
* CIRCLE (X,Y, Radius, Color): Draws a circle shape based on parameters X(left/right),Y(up/down), Radius(size),Color(1-15) entered.

DIM A(10) AS SINGLE
DIM X AS INTEGER
DIM Y AS INTEGER
DIM CHG AS INTEGER
SCREEN 12: X = 280: Y = 400
FOR A=1 TO 180 STEP 3.141/INT(CHG+1)
CIRCLE (X, Y- A), A, CHG
CHG = CHG + 1
IF CHG> 15 THEN CHG = 1
NEXT A


This will draw a circle starting at the down coordinate of 400 and you will see a tunnel shape that is made up of 15 colors.
* CLOSE # Close filenumber that was OPENed.

DIM PATH AS STRING
DIM TEXT AS STRING
PATH = "C:\WINDOWS\": CLS
OPEN PATH + "EXPLORER.EXE" FOR INPUT AS #1
INPUT #1, TEXT
CLOSE #1
PRINT TEXT


L=!This program cannot be run in DOS mode.
NOTE: Don't meddle with the EXPLORER.EXE file (as listed above). This is one of the many files that Windows needs to perform successfully.
* CLS (Clears the screen.)

DIM A AS INTEGER
DIM KY AS STRING
CLS
FOR A = 1 TO 12
LOCATE 5 + A, 12 + A
PRINT STRING$(A, "#"), TAB(40+A); STRING$(A, "#"))
NEXT A
PRINT: PRINT: PRINT TAB(40/2);"PRESS SPACE-BAR TO CLEAR THE SCREEN."
HOLD.KYPRESS:
KY = INKEY$: IF KY = "" THEN GOTO HOLD.KYPRESS
IF KY = CHR$(32) THEN CLS: END
GOTO HOLD.KYPRESS


      #               #
       ##               ##
        ###               ###
         ####               ####
          #####               #####

                    PRESS SPACE-BAR TO CLEAR THE SCREEN.

* COLOR (Modifies the luminance for SCREEN modes):

CLS
SCREEN 1
LOCATE 12,6:PRINT"TYPE TO CYCLE BACKGROUND COLORS"
LOCATE 13,8:PRINT"PRESS ESC TO QUIT PROGRAM"
Pause:
Tapkey$=INKEY$:IF Tapkey$="" THEN GOTO Pause
IF Tapkey$=CHR$(27) THEN END
COLOR ASC(Tapkey$)
GOTO Pause

      TYPE TO CYCLE BACKGROUND COLORS
        PRESS ESC TO QUIT PROGRAM
* COMMON (Saves variable names and passes them: when using CHAIN):
PROGRAM NAME: MATH.BAS

DIM MathValue(100), Number
COMMON MathValue, Answer
CLS
RANDOMIZE TIMER
INPUT "Please enter a numeric value: ";Number
MathValue = INT(RND(1)* 65536)
Answer = MathValue + Number
CHAIN "MATH2.BAS"

PROGRAM NAME: MATH2.BAS

COMMON MathValue, Value, Answer
CLS
PRINT
PRINT "When you add ";MathValue; " + "; Value; " you get ";Answer

When you add 500 + 46238 you get 46738
* COS (Trigonometric function cosine: Used for Math):

SCREEN 12
x = 320
y = 165
pi = 3.14159
angle = 2 * pi
FOR L=1 TO 250
LINE (x - (20 - L * COS(angle)), 165 + (60 * SIN(angle)))-(x - 25, y - 60), c
b = b + 1
  IF INT(b/15) = b/15 THEN
    c = c + 1
    b = 0
  END IF
angle = angle + 2 * pi / 90
NEXT

* CSRLIN (Remembers the line the cursor is on):

CLS
SaveLn = CSRLIN
FOR X=1 TO 20
PRINT "Cursor is at line: ";CSRLIN
NEXT
COLOR 2
LOCATE SaveLn, 1
PRINT "Cursor is at line:"

Cursor is at line: 1
Cursor is at line: 2
Cursor is at line: 3
Cursor is at line: 4
Cursor is at line: 5
Cursor is at line: 6
Cursor is at line: 7
Cursor is at line: 8
Cursor is at line: 9
Cursor is at line: 10
Cursor is at line: 11
Cursor is at line: 12

* DATA (List of constants to be assigned to a variable: Used with READ):

CLS
DIM Month(12) AS STRING * 10
FOR X=1 TO 12
READ Month(X)
PRINT "Month: ";Month(X)
NEXT
DATA January, February, March, April, May, June, July,
DATA August, September, October, November, December

Month: January
Month: February
Month: March
Month: April
Month: May
Month: June
Month: July
Month: August
Month: September
Month: October
Month: November
Month: December



Qbasic Page Qbasic Downloads Qbasic Programming Help Learn about the architecture of logic Qbasic Visitor Page