TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 1 













                          TURBO-LESSONS

                     A TURBO Pascal Tutorial
                          Version 1.01









                        by Lyle M. Faurot
                           June 8, 1985



























    Copyright (C), 1985 by Lyle Faurot.  All rights reserved.

          TURBO is a trademark of Borland International.

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 2

              T A B L E     O F     C O N T E N T S 

                                                         Page

Introduction . . . . . . . . . . . . . . . . . . . . . . .  4
Distribution Notice  . . . . . . . . . . . . . . . . . . .  5

TURBO-LESSON 1: GETTING STARTED
     Loading TURBO . . . . . . . . . . . . . . . . . . . .  5
     Main Menu . . . . . . . . . . . . . . . . . . . . . .  5
TURBO-LESSON 2: EDITING PROGRAMS
     Starting an edit session  . . . . . . . . . . . . . . 10
     Ending an edit session  . . . . . . . . . . . . . . . 11
     Moving the cursor . . . . . . . . . . . . . . . . . . PROG2
     Inserting/Replacing text  . . . . . . . . . . . . . . PROG2
     Deleting text . . . . . . . . . . . . . . . . . . . . PROG2
     Auto-tabbing  . . . . . . . . . . . . . . . . . . . . PROG2
TURBO-LESSON 3: PROGRAM STRUCTURE
     Program structure . . . . . . . . . . . . . . . . . . 12
     Compiler Directive, $U+ . . . . . . . . . . . . . . . 13
     WRITE and WRITELN statements  . . . . . . . . . . . . 13
     Comments  . . . . . . . . . . . . . . . . . . . . . . 14
TURBO-LESSON 4: DECLARATIONS, INPUT
     DECLARATIONS part of program  . . . . . . . . . . . . 16
     VAR declaration . . . . . . . . . . . . . . . . . . . 16
     Input usint READLN statement  . . . . . . . . . . . . 17
     Integer Variables . . . . . . . . . . . . . . . . . . 18
TURBO-LESSON 5: INTEGER EXPRESSIONS
     Assignment statements . . . . . . . . . . . . . . . . 20
     Integer expressions . . . . . . . . . . . . . . . . . 21
     Problems with expressions . . . . . . . . . . . . . . 23
TURBO-LESSON 6: CONDITIONAL PROCESSING
     Selection structures  . . . . . . . . . . . . . . . . 25
     IF statement (One-way selection)  . . . . . . . . . . 26
     IF statement (Two-way selection)  . . . . . . . . . . 27
TURBO-LESSON 7: REPEAT STATEMENT
     CHARacter variables . . . . . . . . . . . . . . . . . 28
     BOOLEAN variables . . . . . . . . . . . . . . . . . . 29
     REPEAT statement  . . . . . . . . . . . . . . . . . . 30
TURBO-LESSON 8: CASE STATEMENT
     Block statements  . . . . . . . . . . . . . . . . . . 32
     CASE statement  . . . . . . . . . . . . . . . . . . . 34
TURBO-LESSON 9: FOR STATEMENT
     Print field width indicator, ":n" . . . . . . . . . . 36
     FOR statement . . . . . . . . . . . . . . . . . . . . 37
TURBO-LESSON 10: WHILE STATEMENT
     CONSTant declaration  . . . . . . . . . . . . . . . . 38
     WHILE statement . . . . . . . . . . . . . . . . . . . 39
     Delay timing loop . . . . . . . . . . . . . . . . . . 41

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 3


                  INTRODUCTION TO TURBO-LESSONS 

    When Borland International ran their first ads for TURBO 
PASCAL my reaction was "You gotta be kidding - they can't do 
that".  But, it seems they did!  I've been enjoying this 
programming system ever since.  Apparently a great many other 
programmers are either programming in TURBO or would like to 
learn how.  TURBO-LESSONS were designed to meet that need.  

    Each TURBO-LESSON is a bite-size tutorial which introduces 
one or more new concepts.  Each of the lessons are presented in 
the same format which includes the OBJECTIVES of the lesson, and 
the TUTORIAL portion of the lesson.  Most lessons direct you to 
work with a sample program which is provided with these lessons.  

     Be sure you make a back-up copy of the programs - you will 
be modifying and adding to the sample programs, and may want to 
return to the original copy of a program.

     Sample programs are numbered to correspond to the lessons:
PROG1 goes with TURBO-LESSON 1, PROG2, PROG2A go with TURBO-
LESSON2, . . . 

    To begin, you should print the TURBO-LESSONS before loading 
TURBO.  To help you get started, TURBO-LESSON 1 shows you how to 
load TURBO and run a sample program.  


             ****************************************
             D I S T R I B U T I O N      N O T I C E 
             ****************************************


TURBO-LESSONS are being distributed as USER-SUPPORTED software. 

Suggested donation, $7.00, for this first set, lessons 1-10, may 
be sent to:

Dr. Lyle Faurot
1904 18th Ave. South
Moorhead, MN   56560


COPYING BY ORGANIZATIONS

Clubs and other non-profit organizations may copy these lessons 
for their members, with the following conditions:

1.  No charge is made for TURBO-LESSONS, except a distribution 
charge may be made to cover the price of the diskette.  Suggested 
donation is to be made directly to the author of the lessons.

2.  Club members are informed that TURBO-LESSONS are distributed 
as user-supported software.

3.  TURBO-LESSONS are distributed unmodified.

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 4


                 TURBO-LESSON 1: GETTING STARTED         


OBJECTIVES - In this lesson you will learn about:

1.  Loading TURBO
2.  Using the Main Menu to Load, Compile, and Run a program


INTRODUCTION

TURBO-LESSONS were written with the following goals in mind:

    -- Present the concepts of Pascal and the TURBO Pascal
       implementation in bite-size chunks (called lessons).

    -- Provide one or more sample Pascal programs with each 
       lesson.   Programming examples are often more helpful
       than eloquent discussion in learning to program.

    -- Structure the lessons in a parallel format to make them
       more useful later as a reference.  The OBJECTIVE section
       at the beginning of each lesson will help you locate
       a topic later.

    -- Structure the lessons in an Action format.  If you are
       like me, you probably learn programming best by doing.
       
    -- Mark the points where some action is suggested.  This 
       should allow for differences in learning styles.  The 
       action points are marked as follows:

       ##### DO:

       For those who like to hit the high points as fast as 
       possible, these action markers will point the way.

   
Now, without further delay, on with the show!       

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 5
      

1.  Loading TURBO.

To get started, put a diskette with TURBO PASCAL in your default 
drive.  

##### DO:

Type TURBO and enter.  

A message will appear:

    Include error messages (Y/N)?

You should answer Y to provide on-screen error messages.  The 
Main Menu will appear at this point.  


2.  Using the Main Menu to Load, Compile, and Run a program.  

The menu should appear with one letter of each option 
highlighted.  

##### DO:

Adjust the brightness level of your screen.  You may need to 
adjust both brightness and contrast to make the key letters stand 
out at a comfortable level.

The main menu is the starting point for most of the things you 
will do with TURBO.  Some of the options will be discussed in 
more detail later, but for now, you should learn to get back to 
the main menu from each of the options.  

******************** Logged drive:

The Logged drive is where your Work files are stored.  This 
option is used to change your logged drive.  

##### DO:

Type L.        

Computer responds: "New drive:"    

Type B (or another drive) and enter.

Look at the top of the screen.  Did the logged drive change?  

Now, depress the space bar.  It appeared that no change had been 
made until the menu screen was redisplayed.  

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 6


******* NOTE:  SOME OF THE OPTIONS DO NOT UPDATE THE MENU SCREEN.  
YOU CAN REDISPLAY THE MENU WITH THE SPACE BAR OR ENTER KEY.  

You could have responded to the "New drive:" message by 
depressing the enter key without entering another drive 
designator.  The enter key by itself is used to escape from this 
option without making any changes.  

The first four options at the top of the menu, L, A, W, and M all 
use the enter key alone as an escape key.  


******************** Active directory: \                 

Use the A option to change the Active subdirectory if your logged 
drive is a hard disk.

##### DO:

Type A.           

Computer responds: "New directory:"   

Type subdirectory name and enter or just enter for no change.

   
******************** Work file:

This is where you name your work file.  The work file will hold 
the PASCAL program you are writing or editing.

##### DO:

Type W.           

Computer responds: "Work file name:"  

Type PROG1 and enter. (If you get the message, "New File", 
PROG1.PAS was not found on your logged drive. Your sample 
programs, including PROG1, should be on the logged drive).  


******************** Main file:

Ignore this option for now.  If you just can't resist typing M at 
this point, remember that Enter is the escape key for this 
option.  

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 7


******************** Run

This option is used to execute a program, compiling it first, if 
necessary.

##### DO:

Type R.    

The program in your work file, PROG1, is compiled and executed.  

Type R again.

Note that the program runs again without compiling.  The Run 
option will only compile if changes have been made in the program 
since the previous compile.  

Depress the space bar to get the menu back.

                                           
******************** Compile

The program may be compiled without executing by using the C 
option.  You may want to compile to see an error message without 
running the program.  Or you may be compiling a COM file, which 
cannot be executed until you exit TURBO to DOS.

##### DO:

Type C.

The program compiles but doesn't run.  Use this option when you 
want to compile without executing the program immediately.  


******************** Edit                                

The editor is used to enter a new program or change a program.  
Another lesson is devoted to editing.  For now, you should find 
out how to get back to the menu from this option.  

##### DO:

Type E.

The program, PROG1, appears on the screen, ready to edit.
Use the Ctrl-K, Ctrl-D sequence to return to the main menu.

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 8


##### DO:

Type Ctrl-K, Ctrl-D. (While depressing the Ctrl key, type K 
                      followed by D.)   

The main menu reappears.  Note that there is no way to abandon 
the edited file in memory.  This is not so bad since the edited 
copy of the program in memory is not automatically saved to disk.  
You can use the Work file option to get another copy of the 
program from disk.  
 

******************** Save 

Use this option to copy your current work file from memory to 
disk.

##### DO:

Type S.

The program, PROG1, is saved to the disk on the drive designated 
when you named this work file.  Since the work file is not 
automatically saved to disk, TURBO reminds you to save the file 
before any option which would destroy the copy of the file in 
memory.  

NOTE: REMEMBER, IT IS UP TO YOU TO SAVE YOUR WORK FILE.  IT'S A 
GOOD IDEA TO SAVE IT FREQUENTLY, IN CASE SOMETHING SUCH AS AN 
INFINITE LOOP FORCES YOU TO RE-BOOT (IN WHICH CASE YOUR WORK FILE 
IN MEMORY WOULD BE FOREVER GONE!)


******************** Dir 

The D option works similar to DIR in DOS.

##### DO:

Type D.

Computer responds: "Dir mask:"

Depress the Enter key to get a directory of the logged drive or 
use drive designator to get a directory of another drive.  You 
can use the wildcards, "*" and "?".

TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 9


******************** compiler Options                     

These will be discussed later when they are needed.  Try the O 
option now to be sure you know how to get back to the menu.  

##### DO:

Type O.

The compiler Options menu is displayed.  

You can choose the various compiler options by typing the 
corresponding letter.  

##### DO:

Type C.

Notice the arrow moved to a different option.

Type H.

Type M.

Be sure to leave the compiler option set to M, memory before 
returning to the main menu.  

Type Q.

The main menu reappears.


******************** Quit 

This option returns you to DOS.  When you are through 
experimenting with the menu options, 

##### DO:

Type Q.

You will be prompted to save your work file if it has been 
modified since you last saved it.  The prompt of the default 
drive will be displayed.
