| |
This workshop will attempt to get you up to speed on the basics
of the BASIC programming language in the fastest and most efficient
way possible. The free version of Microsoft
QuickBASIC v1.1 will be our development tool. If you have
a Mac you will have to use the DOS emulator. Even though BASIC
has come and gone (and come again), it remains a powerful tool
that can create programs QUICKLY, EASILY and will still run on
virtually ANY PC of the past and present! BASIC is an excellent
language to ease you into programming yet still has the power
to create entertaining educational games.
If you would like to use this program at home, create a folder
on the desktop, CLICK
HERE to download the basiczip.exe
file, select your folder. Open the file when the download is complete
and it will expand into 2 separate files (QBASIC.EXE & QBASIC.HLP).
You can delete basiczip.exe
if you like. To start QuickBasic just click on the QBASIC.EXE
file and click OK. After you have started the QuickBasic program
you should familiarize yourself with the menus so that you can
SAVE, LOAD, RUN and get HELP. Use the mouse to click on FILE to
access SAVE & LOAD features (or use the keyboard <Alt-F>).
When you SAVE use a file name that is 8 characters or less long
and choose the TEXT format so that you have the option later to
use other editors (e.g. NOTEPAD, WORD, etc). Once you have typed
in a program you can click on RUN - START or <shift-F5>
to check it out. Let's get started!
________________________________________________________________
LIST OF 10 COMMON BASIC COMMANDS :________________________
CLS
Clears the screen blank. A good way to start.
PRINT "HELLO, ";A$
Prints whatever is between the quotes to the screen, numbers,
variables (A$), etc. The semi-colon causes A$ to be printed right
after whatever is in the quotes.
INPUT "Whatever question you like" ; A$
Combined PRINT and INPUT statement. Variable holds a number (e.g.
A) or characters (e.g. A$)
A$ = UCASE$(A$)
If you INPUT A$ then follow with this command, all characters
will become UPPERCASE. Helpful when you are not sure how the USER
will type their response... (e.g. NO...No...no will all become
NO)
IF ... THEN ... OR ... AND ... ELSE ... END IF
These powerful logic commands allows you to perform a task IF
certain conditions are met.
e.g. IF N=5 THEN PRINT"Hello"
or IF A$="FRED" THEN GOTO here2
{LABEL}:
Place a word followed by a colon anywhere in your program
so that you can GOTO that location if desired. {LABEL} can be
any 8 letter word or number that isn't a command
GOTO {LABEL}
Branch directly to wherever the {label} is placed (no colon here)
GOSUB {LABEL} ... RETURN
If you have a section of your program that is frequently
repeated you can write it in the form of a subroutine. Start the
section with a {LABEL}: and end it with a RETURN.
When you wish to perform the repetitive routine just call it with
GOSUB {LABEL} (no colon). Once the routine has completed
it will RETURN back to the point of the program right after the
point it was called.
END
End of the program
BEEP
Causes the computer to beep if it has a simple PC speaker
_________________________________________________________________
The General Quizzer Program Format__________________________________
Type the following program in the QBasic Editor EXACTLY and save
the file (using FILE - SAVE AS), naming it with your
initials + WS2.BAS (e.g. SAJWS2.BAS). Hereafter you can
just select FILE - SAVE. To RUN press <Shift + F5>. If your
program locks up you may have to <Ctrl + Break> or <Ctrl
+ C> to get back to the editor mode. As you type, the editor
will catch some of your mistakes as you make them and attempt
to warn you.
CLS
INPUT "WHAT IS YOUR NAME" ; N$
CLS
PRINT "The scientific method is a logical approach to solving
a problem"
PRINT "The steps of the scientific method are:"
PRINT "a) Stating the problem"
PRINT "b) Gathering data"
PRINT "c) Forming a hypothesis"
PRINT "d) Testing the hypothesis"
PRINT "e) Conclusion"
INPUT "Press ENTER to begin your quiz";A$
CLS
PRINT "What comes after Forming a hypothesis?"
PRINT "A) Stating the problem B) Gathering data C) Conclusion"
GOSUB ANSWER
IF A$="C" then
   GOSUB CORRECT
   ELSE GOSUB WRONG
END IF
PRINT "What comes before Gathering data?"
PRINT "A) Stating the problem B) Forming a hypothesis C)
Conclusion"
GOSUB ANSWER
IF A$="A" then
   GOSUB CORRECT
   ELSE GOSUB WRONG
END IF
PRINT"Thanks, ";N$;"... for taking this quiz!!!"
BEEP:BEEP:BEEP
END
ANSWER:
INPUT A$
A$ = UCASE$(A$)
RETURN
CORRECT:
BEEP
PRINT "Correct...";N$;"!!!"
PRINT
RETURN
WRONG:
BEEP : BEEP
PRINT "Wrong...";N$;"!!!"
PRINT
RETURN
_______________________________________________________________
The CHALLENGE !______________________________________________
Change the questions and answers to quiz the user on another
science topic.
FILE - SAVE and show (or email) the instructor
your completed program for grading.
|
|