The interface has the following features:
1. Window displaying the current program
2. Menu
3. Name of current program
4. Window to immediately execute a command
5. Status bar
6. Status of Caps Lock and Num Lock
7. Current line of cursor

QBasic interface
Current program
The current program is displayed in the middle of the screen, and covers
most of the QBasic interface.
Menu
The menu
provides most of the operations for the QBasic editor. Such as opening a file,
pasting text, and searching for a string.
File

New - Clears the current program
Open - Loads a program from disk
Save - Saves the current program to
disk
Save As - Saves the program, but under
a different name
Print - Prints the selected text,
current window, or entire program Exit
- Closes the QBasic interpreter
Edit

Cut - Removes the selected text and
stores it in the clipboard
Copy - Copies the text instead of
removing it
Paste - Adds the text in the clipboard
to the current position of the cursor
Clear - Removes the text without storing it to the clipboard
New Sub - Enables you to create a new
subroutine (see Subroutines and Functions)
New Function - Enables you to create a
new function (see Subroutines and
Functions)
View

SUBs - Shows the list of current
subroutines and functions (see Subroutines
and Functions)
Split - Displays the contents of the
current program in two windows. If the window is already split, this hides the
second window (NOTE: The text in each window is always the same, even if you
alter the text in one window) Output
Screen - Shows the QBasic output screen.
Search

Find - Allows you to search for a
string of text in the program Repeat
Last Find - Continues the previous search operation
Change - Replaces each instance of a
string with another string
Run

Start - Executes the current program
Restart - Starts from the beginning
Continue - Continues execution at the
current position
Debug

Step - Processes the next command
Procedure Step - Processes the next
command, but does not show QBasic going inside a subroutine or function
Trace On - Shows the command that is
being executed while the program is running
Toggle Breakpoint - Sets or removes a
breakpoint. Use this to have the QBasic interpreter stop when it reaches a
specified line in the program
Clear All Breakpoints - Removes all
breakpoints in the program
Set Next Statement - Allows you to
continue execution at the specified line
Options

Display - Enables you to change display
colors, the number of spaces to use for tabs, and whether or not scroll bars
are visible
Help Path - The location of the
QBASIC.HLP file
Syntax Checking - Allows you to have
the QBasic editor check the syntax of your program as you type
Help

Index - List of all QBasic commands,
keywords, operators, etc.
Contents - The table of contents for
QBasic help
Topic - Show help for a specific
keyword
Using Help - Displays information on
using QBasic help About - Shows
information about the QBasic interpreter
Name of current program
The file name of
the current program is displayed near the top of the screen in the center. You
can change the name by selecting "Save
As" on the "File"
menu.
Immediately execute a command
QBasic provides a
way to execute a command without running the current program. To do so, select
the bottom window (under "immediate")
and enter a command, then press Enter.
Status bar
The status bar is at the bottom of the screen. It displays a short list
commands
(<Shift+F1=Help> <F6=Window> <F2=Subs>
<F5=Run> <F8=Step>).
When you
highlight an item on the menu, the status bar displays a short description of
what the item does.
Status of Caps Lock and Num Lock
If Caps Lock is set, a "C" is displayed on the right
side of the status bar.
If Num Lock is set, an "N" is displayed on the right
side of the status bar.
Current line
On the right side of the status bar, the current line of the cursor is displayed.
Current column
On the right
side of the status bar, the current column
of the cursor is displayed (immediately after the current line).
Adding
documentation to your programs
Documenting your program (also called
"commenting") allows you to remind yourself about something in your
program. Plus, if your program is seen by other people, documenting can help
them understand your code.
The REM (remark) command enables you to add comments to your
program without the text being treated like an instruction.
CLS
PRINT "Some text"
REM This text is ignored.
REM This program clears the output screen,
REM and then prints "Some text."
TIP: You can use an apostrophe instead of the REM command.
' Comment goes here
You can add REM to the same line as another command by placing a colon
after the first instruction.
CLS: REM This command
clears the screen
PRINT "Text": REM This command prints "Text" to
the screen
PRINT 534: REM This prints
the number 534 to the screen
NOTE: If you use an apostrophe
instead of REM while doing this, you do not need to add a colon.
CLS ' This command
clears the screen
PRINT "Text" ' This
command prints "Text" to the screen
PRINT 534 ' This prints
the number 534 to the screen
Reading
and writing to files
To save data to a file:
1. Call the OPEN command, specifying the file name, file mode (
OUTPUT), and file number.
2. Use PRINT, followed by the file number and the data you want to
write.
3. Close the file using the CLOSE command.
The following opens a file, using mode OUTPUT and number 1,
and then saves the text Hello World!
to the file:
OPEN "testfile.dat" FOR OUTPUT AS #1
PRINT #1, "Hello World!"
CLOSE #1
To open a file
for "reading," call OPEN and pass INPUT as the file mode. Then you can read the data by
using the INPUT command.
OPEN "testfile.dat" FOR INPUT AS #1
INPUT #1, text$
CLOSE #1
PRINT text$
Output:
Hello World!
Displaying
graphics
Before you can show graphics images on the screen, you must call the SCREEN command. SCREEN sets the
graphics mode.
The following
program uses graphics mode 13 (320x200) to display a line, then returns back to
text mode:
SCREEN 13
' This starts at 10 pixels from the left, 10 from ' the top and
goes to point (100, 100):
LINE (10, 10)-(100, 100)
WHILE INKEY$ = "": WEND
' Waits until a key is pressed
SCREEN 0 ' Returns to text mode
You can also draw a colored line.
SCREEN 13
LINE (10, 10)-(100, 100), 192
' Dark green
WHILE INKEY$ = "": WEND
SCREEN 0
To draw a single pixel, use PSET.
SCREEN 13
PSET (160, 100)
WHILE INKEY$ = "": WEND
SCREEN 0
The following displays a circle at (160,
100) with a radius of 50:
SCREEN 13
CIRCLE (160, 100), 50
WHILE INKEY$ = "": WEND
SCREEN 0
Finally, to display a square, use LINE.
SCREEN 13
LINE (10, 10)-(100, 100), 192, B ' Notice the B
WHILE INKEY$ = "": WEND
SCREEN 0
No comments:
Post a Comment