home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PASTUT34
/
TUTORHLP.TXT
< prev
next >
Wrap
Text File
|
1993-06-12
|
22KB
|
663 lines
.topic NoContext=0
Turbo Pascal Tutor and Examples ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Welcome to Turbo Pascal Tutor. This program allows notes on Turbo
Pascal to be viewed in a scrollable window, whilst the source code
for a number of examples can also be inspected. These example programs
can be run as executable files (.EXE) from the tutor screen.
The ≡ menu is accessed by pressing Alt-Space. All the other menus are
accessed by pressing Alt-Z, where Z is the first letter of the menu.
For example, the "Notes" menu is pulled down by Alt-N.
Press ESC to put this help screen away.
.topic Viewer=2
File viewer ▄
▀▀▀▀▀▀▀▀▀▀▀▀
A file viewer views the contents of a text file. You can use the
arrow keys to move about in the file. A file is loaded via the
{File│Open:FOpen} menu item.
Up Move up one line
Down Move down one line
Right Move right one column
Left Move left one column
PgUp Move one page up
PgDn Move one page down
Home View right most column of the file
End View left most column of the file
Ctrl-PgUp View top of file
Ctrl-PgDn View bottom of file.
File viewers can be resized and moved using the {Windows} menu.
.topic List
List ▄
▀▀▀▀▀
Selecting List from the Notes sub-menu provides a screen window
containing an alphabetical list of text files covering many
Turbo Pascal topics, with a brief description of the contents.
After observing the filename required, press Alt-F3 to leave this
screen display and then select Open to obtain a Dialog Box for
selection of the required file.
.topic LOpen
List Open ▄
▀▀▀▀▀▀▀▀▀▀
Select the required file from the Dialog Box by pressing the Tab
key and then using the arrow keys to move to the appropriate file.
Then press the ENTER key.
.topic ExCode
Example Code ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀
On selecting Open a list of Pascal source code files is presented
for selection of the required file by pressing the Tab key and
using the arrow keys to move to the appropriate file. The ENTER
key should then be pressed.
.topic Graphics
Graphics ▄
▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key G.
The program illustrates the graphics capabilities of Turbo Pascal,
by using the Line procedure with a suitable algorithm to draw a
parabola. Apart from using the Graph unit of Turbo Pascal, a
GraphPRN unit is employed to allow hardcopy to an Epson printer.
This latter unit is listed by Ohlsen and Stoker in 'Turbo Pascal
Advanced Techniques' published by the Que Corporation.
.topic System
≡ (System) menu ▄ (Alt-Spacebar)
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The System menu appears on the far left of the menu bar and is
represented by the ≡ symbol.
When you pull down the ≡ menu, you see
{About:SAbout}
.topic SAbout
≡│About ▄
▀▀▀▀▀▀▀▀
When you choose the About command from the ≡ (System) menu, a
dialog box appears, showing copyright and version information.
To close the box, press Esc, or click the top left symbol ▀.
.topic Records
Records ▄
▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key R.
This program allows the user to input data to a sales record.
The data for the record are Name, Item, Quantity, Unit Price and VAT
Rate and this data can be entered into memory by the user response to
screen prompts. The input is checked for correctness of type and form.
An initial menu allows the user to make a record file on disk or to
open an existing record file and, once open, the user can append to,
change data on or read from this record file. Because of the
sequential storage of the records on disk, it is not easy to remove a
record and pack the disk file. For simplicity, deletion is achieved by
changing the record fields for name and item to spaces and the numeric
fields to zeros, effectively giving an empty record.
Finally when the user selects Quit, the program automatically closes
the record file before returning to DOS.
.topic UserIO
UserIO ▄
▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key U.
Program to illustrate user input from the keyboard and output to the
screen. Use is made of the procedures Readln, Write and Writeln found
in the System Unit, which does not have to be declared in the Uses
clause as it is automatically made available. Consult the Library
Reference for details of these procedures.
.topic POpen
Examples Open ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀
To open a source code file select Open by arrow keys and then
press ENTER, or by pressing O. Then use the tab key to move to
the list of programs and then the arrow keys to select the
required one. Then press ENTER.
.topic Notes
Notes (Alt-N) ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Notes menu offers choices for opening files, changing
directories, and exiting the program.
{Open:FOpen} {Change Dir:FChangeDir} {FExit}
.topic FOpen
File│Open (F3) ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Open command displays the Open a File dialog box. In this
dialog box you select the text file you want browse in a
{file viewer:Viewer}.
The {Open a File:FOFileOpenDBox} dialog box contains:
■ an {input box:FOName} with a history list
■ a {list box:FOFiles} to browse the directory
■ the standard {Cancel:CancelBtn} button
■ {Open:FOOpenBtn} action button
■ an information panel that describes the
selected file
.topic FChangeDir
File│Change Dir...▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
File│Change Dir brings up the {Change Directory:FCChDirDBox}
dialog box, in which you can change the current directory.
.topic FDosShell
File│DOS Shell ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
With the DOS Shell command, you can leave the program temporarily
to perform a DOS command or run another program.
To return to this program, type EXIT at the DOS prompt.
.topic FExit
File│Exit ▄ (Alt-X)
▀▀▀▀▀▀▀▀▀▀
The Exit command terminates this program.
.topic Windows
Window ▄ (Alt-W)
▀▀▀▀▀▀▀
The Window menu contains commands to close, move and perform
other window-management commands.
Most of the windows in this program have all the standard window
elements, including scroll bars, a close box, and zoom icons.
For more about windows and their elements, refer to windows.
Window-management commands
══════════════════════════
{Size/Move:WSizeMove} {Zoom:WZoom}
{Tile:WTile} {Cascade:WCascade}
{Next:WNext} {Previous:WPrevious}
{Close:WClose}
.topic WSizeMove
Window│Size/Move ▄ (Ctrl-F5)
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Choose this command to change the size or position of the active
window.
▄▄▄▄▄▄
Size
▀▀▀▀▀▀
If you press Shift while you use the arrow keys, you can change
the size of the active window. Once you've adjusted its size or
position, press Enter.
If a window has a Resize corner, you can drag that corner to
resize the window.
▄▄▄▄▄▄
Move
▀▀▀▀▀▀
When you choose Window│Size/Move, the active window moves in
response to the arrow keys. Once you've moved the window to where
you want it, press Enter.
You can also move a window by dragging its title bar with the
mouse.
.topic WZoom
Window│Zoom ▄ (F5)
▀▀▀▀▀▀▀▀▀▀▀▀
Choose Zoom to resize the active window to the maximum size. If
the window is already zoomed, you can choose this command to
restore it to its previous size.
You can also double-click anywhere on the window's title bar
(except where an icon appears) to zoom or unzoom the window.
.topic WTile
Window│Tile ▄
▀▀▀▀▀▀▀▀▀▀▀▀
Choose Window│Tile to tile all file viewers on the desktop.
┌────────────────────────────────────┐
│ ╔════════════1══╗┌────────────2──┐ │
│ ║ ║│ │ │
│ ║ ║│ │ │
│ ║ ║│ │ │
│ ║ ║│ │ │
│ ╚═══════════════╝└───────────────┘ │
│ ┌────────────3──┐┌────────────4──┐ │
│ │ ││ │ │
│ │ ││ │ │
│ │ ││ │ │
│ │ ││ │ │
│ └───────────────┘└───────────────┘ │
└────────────────────────────────────┘
Tiled Windows
.topic WCascade
Window│Cascade ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Choose Window│Cascade to stack all file viewers on the desktop.
┌──────────────────────────1─┐
│┌─────────────────────────2─┐
││┌────────────────────────3─┐
│││╔═══════════════════════4═╗
│││║ ║
│││║ ║
│││║ ║
│││║ ║
│││║ ║
└└└╚═════════════════════════╝
Cascaded Windows
.topic WNext
Window│Next ▄
▀▀▀▀▀▀▀▀▀▀▀▀
Choose Next to cycle forwards through the windows on the desktop.
.topic WPrevious
Window│Previous ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Choose Previous to cycle backwards through the windows on the desktop.
.topic WClose
Window│Close ▄ (Alt-F3)
▀▀▀▀▀▀▀▀▀▀▀▀▀
Choose Close to close the active window.
You can also click the Close box in the upper right corner to
close a window.
.topic Options
Options (Alt-O) ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Options menu contains commands that let
you change {color:OColors} and {mouse:OMouse} default settings.
.topic OMouse
Options│Mouse... ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Mouse command brings up the {Mouse Options:OMMouseDBox}
dialog box, where you can set various options that control how your
mouse works, including:
■ how fast a double-click is
■ which mouse button (right or left) is
active
.topic OColors
Options│Colors... ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Colors item brings up the {Colors dialog:OCColorsDBox} box,
where you can customize the colors of the display.
.topic OSaveDesktop
Options│Save Desktop ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Saves the state of all open windows to a file call TVDEMO.DSK. This
file can be reloaded by selecting {Options│Restore Desktop:ORestoreDesktop}.
.topic ORestoreDesktop
Options│Restore Desktop ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Restore a previously-saved state of all open windows from a file
call TVDEMO.DSK. This file is saved via the
{Options│Save Desktop:OSaveDesktop} menu command.
.topic FOFileOpenDBox
Help on Open a File Dialog Box ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Open a File dialog box contains an input box, a {file list:FOFiles},
a file information panel, the standard button {Cancel:CancelBtn},
one other action button ({Open:FOOpenBtn}), plus a history list
that's attached to the {Name inputbox:FOName}.
.topic FOName
┌─ Name ──────────────────────────┐
│ │
└─────────────────────────────────┘
The Name input box is where you enter the name of the file to
load, or the file-name mask to use as a filter for the Files list
box (for example, *.*).
.topic FOFiles
┌ Files ──────────────────────────┐
│ │
│ FILENM01.PAS │ FILENM09.PAS │
│ FILENM02.PAS │ FILENM10.PAS │
│ FILENM03.PAS │ FILENM11.PAS │
│ FILENM04.PAS │ FILENM12.PAS │
│ FILENM05.PAS │ .. │
│ FILENM06.PAS │ \MOREXAMP │
│ FILENM07.PAS │ \TOURS │
│ FILENM08.PAS │ \ANSWERS.DIR │
│ ▒▒▒■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
└─────────────────────────────────┘
The Files list box lists the names of files in the current
directory that match the file-name mask in the Name input box,
plus the parent directory and all subdirectories.
┌──────────────────────────────────────────┐
│ C:\TP\EXAMPLES\*.PAS │
│ HELLO.PAS 52 Jul 14,1990 12:00pm │
└──────────────────────────────────────────┘
The File information panel shows the path name, file name, date,
time, and size of the selected file.
None of the items on this information panel are selectable.
.topic FOOpenBtn
┌──────────┐
│ [ Open ] │
└──────────┘
The Open button opens a new Viewer window and places the selected
file in that window.
.topic CancelBtn
┌────────────┐
│ [ Cancel ] │
└────────────┘
If you choose Cancel, nothing changes and no action occurs, and
the dialog box is put away.
(Esc always cancels a dialog box, even if a Cancel button does
not appear.)
.topic OpenBtn
┌──────────┐
│ [ Open ] │
└──────────┘
In the Open a File dialog box, if you choose the Open button
TVDEMO opens a new {file viewer:Viewer} and places the selected
file in that window.
.topic FCChDirDBox
Help on the Change Directory dialog box ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Change Directory dialog box consists of an input box, a list
box, the standard OK and Help buttons, and two other buttons
(Chdir and Revert).
┌ Directory Name ─────────────────────┐
│ │
└─────────────────────────────────────┘
The Directory Name input box is where you type in the path of the
new directory.
┌ Directory Tree ─────────────────────┐
│ Drives │
│ └─┬C:\ │
│ └─┬TP │
│ └──TVISION │
└─────────────────────────────────────┘
The Directory Tree list box enables you to navigate directories
by using the selecting bar and pressing Enter.
If you're using the keyboard, press Enter to make the selected
directory be the current directory, then choose OK or press Esc
to exit the dialog box.
┌──────────┐
│ [Chdir ] │
└──────────┘
The Chdir button changes the current directory once you've
selected or typed in a directory name.
┌──────────┐
│ [Revert] │
└──────────┘
The Revert button goes back to the previous directory, as long as
you haven't yet exited the dialog box.
.topic OMMouseDBox
Help on the Mouse Options dialog box ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
This dialog box consists of one check box, one slider bar, and
the standard buttons OK and Cancel.
┌──────────────────────────┐
│ Mouse Double Click │
│ Slow Medium Fast │
│ ▒▒▒▒▒▒▒▒▒▒▒■▒▒▒▒▒▒▒▒▒▒ │
└──────────────────────────┘
The Mouse Double Click slider bar adjusts the double-click speed of
your mouse.
┌───────────────────────────┐
│ [X] Reverse Mouse Buttons │
└───────────────────────────┘
Reverse Mouse Buttons makes the right mouse button take on the
normal functions of the left--and vice versa.
See also:
═════════
{Options│Mouse... menu command:OMouse}
.topic OCColorsDBox
Help on the Colors dialog box ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
The Colors dialog box consists of two list boxes, a text display
area, the standard OK, Cancel, and Help buttons, and one of the
following:
■ On color and black-and-white systems, it
also contains two color palettes.
■ On monochrome systems, it contains a set
of radio buttons instead of the palettes.
This dialog box is where you can change the colors of different
parts of this program.
┌─ Group ─────────────┐
│ Desktop │
│ Menus ■│
│ Dialogs/Calc ▒│
│ Puzzle ▒│
│ Calendar ▒│
│ Ascii table ▒│
│ │
└─────────────────────┘
The Group list box contains the names of the different regions of
the program that you can customize.
┌─ Item ──────────────┐
│ Color │
│ ■│
When you select a group from the Group list, the Item list box
displays the names of the different views in that region.
┌ Foreground ┐ ┌ Background ┐
│ ░▒▓░▒▓░▒▓░ │ │ ▓░▒▓░▒▓░▒▓ │
│ ▓░▒▓░▒▓░▒▓ │ │ ░▒▓░▒▓░▒▓░ │
│ ▒▓░▒▓░▒▓░▒ │ └────────────┘
└────────────┘
On color and black-and-white systems, you use the Foreground and
Background palettes to modify colors.
┌ Colors ──────────────┐
│ (∙) Mono low │
│ ( ) Mono high │
│ ( ) Mono underscore │
│ ( ) Mono inverse │
└──────────────────────┘
On monochrome systems, you use the Colors set of radio buttons
systems to modify the character attributes.
┌────────────────┐
│ Text Text Text │
│ Text Text Text │
└────────────────┘
On all systems, the display text (above the Help button) shows
the current color or attribute settings.
Changes do not take effect on the desktop until you close the
Colors dialog box by choosing OK.
.topic Pointers
Pointers ▄
▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key P.
This program illustrates the use of Pointers and Records.
It also illustrates Variable Typecasts, so that the value of
a pointer variable can be evaluated and hence the segment and
offset of the variable pointed to can be found. The functions
'seg' and 'ofs' are also used for this purpose. Then by
changing to the OS shell, the user can enter DEBUG and
display (d Seg:Ofs) to check the location of the records in
memory. Note the apparent multiple storage with a 16-bit
machine with 1 Mbyte of memory and explain this paradox.
It is based on a program in the Turbo Pascal version 3 Manual,
with additional declarations and statements by Ron Shaw.
.topic RunEx
Run Examples ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀
Select the appropriate example from the sub-menu, by using
the arrow keys and pressing ENTER, or by pressing the
appropriate highlighted letter.
.topic Bintree
Binary Trees ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key B.
Program to show how a binary tree can be used to order a set
of integers.
.topic Dosops
DOS Operations ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key D.
Program to illustrate the use of DOS operations from a Turbo
Pascal Program.
.topic IntrDemo
BIOS interrupt ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key I.
Program to illustrate Turbo Pascal INTR procedure, which uses DOS.
The BIOS Interrupt Service 10 Hex is used with Function (AH) = 0F
For use with Version 5 + of Turbo Pascal. Version 3 is different
because Registers is not predefined in DOS, but user defined.
.topic KeyCheck
KeyCheck ▄
▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key K.
This program illustrates the use of Units in Turbo Pascal, whereby
compiled code can be incorporated into the current program. The unit
is called LIMITKEY.TPU and provides a procedure that only allows a
selected set of keys to be acceptable input. The selected keys are
defined as the first parameter of the procedure LimitChar.
Based on a program by David Arber of David Arber Associates.
.topic TwoLinks
Double linked list ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key T.
Program to display on the screen the creation of a double-linked
list on the Heap and to show the action as the records of the list
are traversed both forward and backward under the control of the
right and left arrow keys.
The functions Seg and Ofs are used to determine the addresses on
Heap of each record of the linked list and these addresses are then
displayed as Seg:Ofs for the record and for its fields Previous and
Next. The Number field is also displayed.
The active record is shown in red.
.topic HeapList
Linked list on the Heap ▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key H.
The program demonstrates the creation of a single linked list of
records on the Heap, using pointers. The user is invited to enter
the name, as a string[15], and price in pence, as an integer, for
three items, which form the linked list.
.topic Proc
Procedure ▄
▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key C.
Program to illustrate the use of a procedure with parameters.
The procedure simply creates a Times Table for the entered value of
the multiplicand, or base, for the range of multiplier values also
entered by the user. The procedure is called TimesTable and has the
three parameters: BaseValue, Lower and Upper.
.topic Func
Function ▄
▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key F.
Program to illustrate the use of a function, in this case to evaluate
a number raised to a power ( x ^ y ). The number is referred to as the
base value and the power is the exponent. Negative base values with
fractional exponents are excluded in this simple program as they would
require the use of complex numbers. A unit POWERU.TPU is available to
handle complex solutions.
.topic OverLays
OverLays ▄
▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key O.
Program to illustrate the use of Overlays, whereby code is contained
in a number of units on disk and is called into overlay section of
memory when required. Useful when memory is otherwise fully used.
Some modifications made to the original Borland program to give
screen indication of the overlay in use.
For details refer to chapter 13 The Overlay Unit in the Programmer's
Guide (version 6.0).
.topic Structure
Structure ▄
▀▀▀▀▀▀▀▀▀▀
This program can be run by selection using the arrow keys and
pressing ENTER, or else by pressing the highlighted key S.
Program to illustrate the structure of Turbo Pascal programs.