home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
libbasic
/
overview.txt
< prev
next >
Wrap
Text File
|
1992-09-16
|
7KB
|
318 lines
Overview of the Liberty BASIC Environment:
This chapter will introduce you to:
The Liberty BASIC browser ;
The Liberty BASIC Trace Window
BASIC editors
The Liberty BASIC browser
When you start Liberty BASIC, you get a window that looks like this:
{Illustration was here}
The window has four panes. Starting in the upper-left-hand corner, the first
pane is where you select the disk drive on which your work is or will be
stored. To its right is a pane where you select the directory where your
work is. The next pane contains a list of *.bas files. The big pane comprising
the lower half of the window is a source editor, which displays file details (see
illustration above) until you select a file to edit.
Each of the panes in the browser has a pull-down menu. Each pull-down menu
can also be popped-up. To pop up a menu, point into that pane with the mouse
and press the right-hand mouse button once. We will use the pull-down menus
for our examples here.
Let's begin by creating a BASIC program file. Pull down the Files menu and
select Create.
{Illustration was here}
You will be asked to type the name of your new BASIC program. Type
ellipses, then strike return or click on OK.
{Illustration was here}
Then click on Yes or press Enter.
{Illustration was here}
The file will be created, and you will be given an empty source
editor pane.
Now type in the source code below, so that your window
looks like the illustration.
' draw some ellipses
nomainwin
open "Ellipses" for graphics as #1
print #1, "down"
print #1, "place 130 130"
for x = 30 to 230 step 10
print #1, "ellipse "; x ; " "; 260 - x
next x
print #1, "flush"
input r$
close #1
{Illustration was here}
Now pull down the File menu and select Save and your program will be
saved to disk.
{Illustration was here}
Now let's run the program.
{Illustration was here}
and we get:
{Illustration was here}
Now close the window.
Using the Debugger:
Let's take a closer look at how our ellipses program works using the debugger.
Pull down the Source menu and select Debug.
{Illustration was here}
A dialog will appear asking if you want to watch variables. Respond by clicking
on Yes or by pressing Enter.
{Illustration was here}
A Trace Window will appear, and also another window labeled
Program named - 'ellipses.bas'
{Illustration was here}
Select the Trace Window to bring it to the foreground and to make it the active
window. Notice that it has two panes. The pane on the top shows variables as
they change value. The pane on the bottom shows each line of code as it
executes.
{Illustration was here}
The three buttons on the bottom of the window let you pick three different
modes of execution:
Step - Step one line at a time through program execution
Walk - Run the program non stop highlighting each line as it executes
Run - Run full speed. Do not highlight each line
Program always begins in Step mode when the Debug option is used.
Now let's click on the Step button once. Your Trace Window should look
like:
{Illustration was here}
Now we see that the nomainwin statement has been executed, the results of
which are not visible. When we click on Step again, the open statement will
open a graphics window for us labeled Ellipses. Try it.
{Illustration was here}
Now notice that the Trace Window now highlights the next line, and that
a graphics window appears labeled Ellipses.
{Illustration was here}
Now click on Step twice more. The two statements:
print #1, "down"
print #1, "place 130 130"
will be executed. You won't be able to immediately see the effect of these
two statements. The first one tells the window's graphic pen to be 'lowered'
to the surface of its 'paper'. The second statement places the pen at 130
in x and y.
Now click on Step again. Now look at the variables pane in the Trace Window.
{Illustration was here}
This shows that the variable x has been assigned the value 30. Each and every
time that x (or any other variable), changes, we will be informed as to just what
that change is.
Now click on Step again. The line:
print #1, "ellipse "; x ; " "; 260 - x
will be executed, and you will see this:
{Illustration was here}
Now click on Step a dozen or so times, watching the value of x change and
seeing several new ellipses drawn. Finally, click on Walk and the program
will run non-stop, highlighting each line as it goes, and displaying each new
value of x. When this is done, you may close the graphics window, the
Trace Window, and the window labeled: Program named: 'ellipses.bas'.
When you close this third window, Liberty BASIC will ask if you want to
terminate ellipses.bas. Respond by pressing Enter or clicking on Yes.Editing several BASIC files:
Only one Liberty BASIC browser can be open at a time. If you want to edit
more than one *.bas file at a time, you can open seperate BASIC editors on
each one. A BASIC editor is a window with a single pane for editing, and it
also let's you run and debug. Let's say you want to edit both hello.bas and
ellipses.bas at the same time. Starting with the browser window, select
hello.bas so that its source code is visible in the editor pane as shown:
{Illustration was here}
Now pull down the Files menu, and select BASIC Editor.
{Illustration was here}
Now a BASIC editor window will appear with the contents of hello.bas ready
to edit or run. The BASIC editor does not have a pull-down menu for running
or debugging. Instead, it has a pop-up menu for accomplishing the same thing.
To pop up the menu, simply point inside of the pane with the mouse, and push
the right-hand mouse button once. The menu will appear and you can then
choose what operation you want to perform.
{Illustration was here}
Now we can simply go back to the browser and select the other file(s)
that we want to edit or run, only ellipses.bas in this example.
Shortcuts:
Here is a list of key combinations that activate useful features in Liberty BASIC:
Shift + Del Cut
Ctrl + Ins Copy
Shift + Ins Paste
Clear Del
Select All Ctrl + A
Print Selection Ctrl + P
Find/Replace Ctrl + F
Find Again Ctrl + G
Open Scratchpad Alt + N
Open a File Editor Alt + O
Save Alt + S
Save As Alt + A
Print Alt + P
These features are also available in the File and Edit pull-down menus.