home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-05-09 | 48.8 KB | 1,256 lines |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TURBO-LESSONS
-
-
- A TURBO Pascal Tutorial
- Version 5.0 (for TURBO Pascal 5.0)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- by Dr. Lyle M. Faurot
- May 6, 1989
-
-
-
-
-
-
-
-
- Copyright 1989 by Lyle M. Faurot. All Rights Reserved.
-
- î
-
-
- TURBO-LESSONS Registration Form
-
-
-
- Name____________________________________________ Date_____________
-
- Street_____________________________________________________________
-
- City________________________________ State_________ Zip____________
-
-
- Would you like to receive notices about future releases
- of Tutorials and other products? Yes___ No___ [TP-5.0:R31]
-
-
- Where did you get your copy of TURBO-LESSONS?______________________
-
-
- Your vote counts! Which of the following would you like next?
-
- _____ More TURBO-LESSONS for Turbo Pascal 5.0
- (Several lessons of the next set are already in progress.)
-
- _____ TURBO-LESSONS for other programming languages
-
- Which ones? _______________________________________________
-
- _____ TURBO-LESSONS for spreadsheets, word processors, other products
-
- Which ones? _______________________________________________
-
- _______________________________________________
-
-
- Comments, Suggestions:
-
- -------------------------------------------------------------------
-
- -------------------------------------------------------------------
-
- -------------------------------------------------------------------
-
- -------------------------------------------------------------------
-
- -------------------------------------------------------------------
-
- ===================================================================
-
- TURBO-LESSONS for Turbo Pascal 5.0
- Set 1: Lessons 1-16 $10.00 (U.S. Funds)
-
- Mail to: Dr. Lyle M. Faurot
- Box 494
- Moorhead, MN 56560
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 2
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
-
- TABLE OF CONTENTS
-
- INTRODUCTION........................................ 5
-
- OBJECTIVES.......................................... 6
-
- SHAREWARE NOTICE.................................... 7
- What is SHAREWARE?.............................. 7
- How is TUTORIAL Shareware Different?............ 7
- Try Before You Buy.............................. 7
- Why Register Your Copy of TURBO-LESSONS?........ 7
- How to Register................................. 8
-
- DISTRIBUTION OF TURBO-LESSONS....................... 9
- Copying and Sharing TURBO-LESSONS............... 9
- PC Clubs/Bulletin Boards........................ 9
- PD/Shareware Disk Distribution Companies........ 9
- TURBO-LESSON Files on the Distribution Diskette. 10
-
- TURBO-LESSON 1. GETTING STARTED (Version 5.0)...... 11
- How to Start and Stop Turbo..................... 11
- How to Switch and Zoom Windows.................. 13
- How to Edit a File.............................. 14
- How to Save a File.............................. 14
- How to Display a Directory of Files............. 15
- How to Edit a Different File.................... 16
- How to Recover a File Saved Earlier............. 17
-
- TURBO-LESSON 2. ESSENTIAL EDITING SKILLS........... 19
- Moving the Cursor............................... 19
- Inserting and Replacing Text.................... 20
- Deleting Text................................... 21
- Experimenting On Your Own....................... 22
- Saving and Retrieving Programs.................. 22
- Re-Editing Each File............................ 23
- Getting Up to Speed............................. 24
-
- TURBO-LESSON 3. PROGRAM STRUCTURE.................. 25
- Program structure............................... 25
- How to Compile a Program........................ 26
- How to Run a Program............................ 27
- Write and WriteLn statements.................... 27
- Comments - at the beginning of program.......... 30
- Comments - at the end of a statement line....... 31
- Comments - deactivate a section of code......... 31
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 3
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
-
- TABLE OF CONTENTS (continued)
-
- TURBO-LESSON 4. DECLARATIONS, INPUT................ 32
- The DECLARATIONS Part of a Program.............. 32
- VAR Declaration................................. 32
- Input Using the ReadLn Statement................ 33
- DEBUG - Tracing Statements...................... 34
- DEBUG - Watching Variables..................... 35
- Integer Variables............................... 36
-
- TURBO-LESSON 5. INTEGER EXPRESSIONS................ 37
- Assignment Statements........................... 37
- DEBUG - Removing Watch Variables............... 38
- Integer Expressions............................. 38
- Problems with Expressions....................... 41
-
- TURBO-LESSON 6. CONDITIONAL PROCESSING............. 43
- Selection Structures for Conditional Processing. 43
- DEBUG - Goto Cursor............................ 43
- IF Statement (Two-way Selection)................ 44
- IF Statement (One-way Selection)................ 45
-
- TURBO-LESSON 7. REPEAT STATEMENT................... 48
- CHARacter Variables............................. 48
- BOOLEAN Variables............................... 49
- REPEAT Statement................................ 50
-
- TURBO-LESSON 8. CASE STATEMENT..................... 52
- Block Statement................................. 52
- CASE Statement.................................. 55
-
- TURBO-LESSON 9. FOR STATEMENT...................... 57
- Controlling Field Width in Write Statements..... 57
- FOR Statement................................... 58
-
- TURBO-LESSON 10. WHILE STATEMENT................... 60
- CONSTant Declaration............................ 60
- WHILE Statement................................. 61
- Delay Timing Loop............................... 63
-
- TURBO-LESSON 11. INTRODUCTION TO FUNCTIONS......... 65
- Pascal Subprograms.............................. 65
- FUNCTION Declaration............................ 66
- User-defined Function........................... 66
- Providing Input to the FUNCTION................. 67
-
- TURBO-LESSON 12. A FUNCTION TO DETECT ERRORS....... 72
- Error Detection................................. 72
- Using a Predefined Function..................... 73
- Writing Your Own Function....................... 74
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 4
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
-
- TABLE OF CONTENTS (continued)
-
- TURBO-LESSON 13. STRINGS........................... 76
- Strings......................................... 76
- String Replacement Statement.................... 76
- Predefined String Function, LENGTH.............. 78
-
- TURBO-LESSON 14. INTRODUCTION TO PROCEDURES........ 80
- PROCEDURE Declaration........................... 80
- Using a Procedure............................... 80
- Using Parameters................................ 82
- A Counter with Error Checking................... 83
-
- TURBO-LESSON 15. INTERACTIVE SCREEN HANDLING....... 85
- Setting up a Data Entry Screen.................. 85
- Being Nice to Users - ClrScr.................... 86
- Getting Around the Screen - GotoXY.............. 86
-
- TURBO-LESSON 16. REAL NUMBERS...................... 88
- Range of Real Numbers........................... 88
- Input/Output of Real Numbers.................... 88
- Calculations with Real Numbers.................. 89
- Calculations with Integers and Real Numbers..... 91
-
- A CHALLENGE......................................... 92
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 5
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
- INTRODUCTION
-
- Since TURBO-LESSONS were first made available as Shareware in
- 1985, Pascal programmers around the world have provided
- encouragement and some excellent suggestions for improving these
- lessons. I have used many of those suggestions in this update for
- Turbo Pascal 5.0.
-
- The new DEBUG feature in 5.0 adds a terrific learning tool.
- You will enjoy using the DEBUG "trace" and "watch" to explore the
- workings of this programming language.
-
- 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 unmodified copy of a program.
-
- Sample programs are numbered to correspond to the lessons--for
- example, PROG3 goes with lesson 3.
-
- To begin, you should print the TURBO-LESSONS before loading
- TURBO. You may also want to print a copy of the programs. This
- will allow you to see the whole program. The screen window often
- limits your view to a small part of a program.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 6
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
- OBJECTIVES
-
- The following objectives have guided the development of TURBO-
- LESSONS.
-
- 1. TO HELP BEGINNING PROGRAMMERS
-
- Programmers who had difficulty learning Pascal from reference
- books tell me they are able to make better progress on their
- own after completing TURBO-LESSONS.
-
- 2. TO HELP YOU GET STARTED PROGRAMMING IN PASCAL
-
- We hope to provide the basics you need to get started with
- Pascal and build your confidence and enthusiasm to continue
- learning on your own.
-
- 3. TO PROVIDE PRACTICAL PROGRAMMING TECHNIQUES
-
- There is more to programming than just learning the elements
- of the language. The programming techniques you learn will
- save you time and frustration in your future programming.
-
- 4. TO ENCOURAGE EXPERIMENTATION ON YOUR OWN
-
- Programming skill is acquired more by doing than by reading
- about it. The lessons are presented in a way designed to
- challenge you to try things on your own.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 7
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
- SHAREWARE NOTICE
-
-
- What is SHAREWARE?
-
- SHAREWARE is a "Try Before You Buy" approach to marketing and
- distribution of products. Shareware is not free and it is not
- public domain. Shareware authors encourage users to copy and pass
- on their copyrighted products. If after trying out the product,
- you continue using it, payment is expected.
-
-
- How is TUTORIAL Shareware Different?
-
- Most Shareware products are successful if you evaluate the product
- and decide to continue using it. Just the opposite is true of
- Tutorial Shareware--it is successful if you don't need to continue
- using it.
-
- The value of a good tutorial is in the "FIRST USE". A successful
- tutorial is like a newspaper--use it once and discard it. (I hope
- you won't discard TURBO-LESSONS though. Give a copy to a friend.)
-
-
- Try Before You Buy
-
- Let me suggest the following way to "Try Before You Buy" in the
- special case of products which don't typically get "continued use."
-
- If you try the first few lessons and decide to continue, you
- are expected to pay for the lessons.
-
- If the tutorials are successful, you are "continuing to use" the
- skills and knowledge you received from the tutorials.
-
-
- Why Register Your Copy of TURBO-LESSONS?
-
- When you send your registration you:
-
- 1. Make it possible for the author to write more tutorials.
-
- 2. Help determine which tutorials will be written.
-
- 3. Find out about new products. The next set of TURBO-LESSONS
- for Turbo Pascal 5.0 is already under construction! These
- lessons will feature data structures--Arrays, Records, Files.
-
- 4. Support SHAREWARE marketing.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 8
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
-
- How to Register
-
- The registration form is included with the first lesson file,
- TP-50A. The form is also stored in a file named REPLY. To print
- a copy of the form, type
-
- COPY REPLY PRN or COPY REPLY LPT1:
-
- When you complete the registration form, please include any
- comments about the lessons. This helps me improve the next version
- or correct errors.
-
- Please use U.S. funds in payment. It costs more than the price of
- TURBO-LESSONS to collect checks from other countries.
-
- CANADIAN checks are not a problem. My bank charges me $1.00 plus
- the exchange rate.
-
- If for some reason the file, REPLY, is not with the set of TURBO-
- LESSONS you receive, please let me know it is missing and where you
- obtained TURBO-LESSONS so I can correct the problem. You can mail
- your payment of $10.00 without the form to:
-
- Dr. Lyle M. Faurot
- Box 494
- Moorhead, MN 56560
-
- Thank you for supporting this product and the SHAREWARE marketing
- concept.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 9
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
- DISTRIBUTION OF TURBO-LESSONS
-
-
- Copying and Sharing TURBO-LESSONS
-
- You are encouraged to copy and share these lessons with others.
- This is what makes shareware work--the author appreciates your help
- in distributing this product.
-
- TURBO-LESSONS may be freely copied and shared. TURBO-LESSONS may
- not be sold. PC Clubs and Disk Distribution companies may include
- TURBO-LESSONS in their disk offerings provided any price charged is
- based on the cost of disk and handling, and not on the contents of
- the disk.
-
- TURBO-LESSONS must be distributed complete with all files. A
- complete list of files appears later in this section.
-
-
- PC Clubs/Bulletin Boards
-
- TURBO-LESSONS may be distributed by PC Clubs and uploaded to
- Computer Bulletin Boards. The set must be distributed complete
- with all files provided.
-
-
- PD/Shareware Disk Distribution Companies
-
- Disk distribution companies may include TURBO-LESSONS in their
- offerings provided they represent TURBO-LESSONS as SHAREWARE, not
- Public Domain or Freeware. Also the complete set of lessons and
- files must be distributed together.
-
- Those who "buy" TURBO-LESSONS from disk companies should understand
- that the author receives no royalty of any kind from these sales.
- We are simply helping each other--I try to provide a quality
- product for them to distribute, they provide publicity and
- distribution which would otherwise be unavailable to me.
-
-
- Site Licensing
-
- Schools, companies and other organizations are encouraged to write
- for information about site licensing for multiple copies of TURBO-
- LESSONS.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 10
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
-
- TURBO-LESSON Files on the Distribution Diskette
-
- You should have received the following files with TURBO-LESSONS.
- The approximate number of pages is listed to help you print the
- lessons.
-
- File Contents Pages to Print
-
- TP-50A Lessons 1-2, Introduction,
- Table of Contents 25
- TP-50B Lessons 3-6 23
- TP-50C Lessons 7-11 24
- TP-50D Lessons 12-16 21
- REPLY Registration/Survey Form 1
- README The starting point - read this first 1
- PRINT.BAT To help you print the lessons
- PROGx.PAS These are the programs, numbered to
- correspond to the lessons. The following
- are included: PROG3.PAS, 4, 5, 6A, 6B, 6C,
- 7, 8, 9, 10, 11, 11A, 12, 12A, 13, 13A, 14,
- 14A, 15, 15A, 15B, 16, and TEST1.PAS.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 11
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
- TURBO-LESSON 1. GETTING STARTED (Version 5.0)
-
- OBJECTIVES - In lesson 1 you will learn how to:
-
- 1. Start and stop Turbo Pascal
- 2. Switch windows
- 3. Edit a file (programs are stored in files)
- 4. Save a file
- 5. Display a directory of files saved
- 6. Edit a different file
- 7. Recover a file saved earlier
-
- In lesson 1 you will learn to use the Turbo Pascal programming
- environment. Unlike many of the earlier programming language
- systems, Turbo provides the various tools needed in one package.
- This means you can quickly go from entering or correcting a program
- to running and testing the program. Turbo also speeds up debugging
- of the program by "pointing" to your error with the cursor, and
- indicating the nature of the problem.
-
- You will need the skills acquired in the first two lessons as you
- work through later lessons. If you find yourself unsure of some of
- these file skills later, be sure to come back to lessons 1 and 2
- for help.
-
-
- 1. How to Start and Stop Turbo
-
- To get started, put a diskette with Turbo Pascal in your disk
- drive, or if you have Turbo Pascal on a hard disk, switch to the
- subdirectory with Turbo. The following files should be on the
- diskette or hard drive: Turbo.EXE, Turbo.TPL and Turbo.HLP.
-
- ##### DO:
-
- Type Turbo then press the Enter key to start Turbo Pascal.
-
- The screen which appears has the following across the top:
-
- File Edit Run Compile Options Debug Break/watch
-
- This is the main menu of Turbo Pascal. In this lesson you will
- explore only the first two options: File and Edit.
-
- Notice the first letter of each word is highlighted. You can
- choose any of the menu options by typing the first letter of the
- option while holding down the Alt key.
-
- If the first letter of each word doesn't appear highlighted, try
- adjusting the contrast and brightness controls of your computer
- monitor.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 12
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- To choose the File option, you would hold down the Alt key and type
- F.
-
- ##### DO:
-
- Type Alt-F (hold down the Alt key while you type F) to choose the
- File option.
-
- The window which appeared under File shows what you can do with
- files: Load a file, start a New file, Save a file, display a
- Directory of files saved, Quit Turbo Pascal, and several other
- choices.
-
- You have started Turbo--next you will need to know how to stop it.
- The Quit option lets you exit the Turbo programming environment.
-
- ##### DO:
-
- Type Q to leave Turbo.
-
- Try starting Turbo again and learn another way to use the menu.
-
- ##### DO:
-
- Type Turbo and press the Enter key to start Turbo.
-
- Notice the way one of the menu options is highlighted.
-
- ##### DO:
-
- Press the right arrow key several times. The highlight should move
- from one menu option to the next. Also try the left arrow. (If
- nothing happens, check for NUM at the lower right of the screen.
- If the word NUM appears, press the Num Lock Key--NUM will
- disappear. Now the arrow keys should work.)
-
- You chose the File option from the menu before by typing Alt-F.
- There's another way to choose an option--you can move the highlight
- to the option you want and press the Enter key.
-
- ##### DO:
-
- Move the highlight to the File option and press Enter.
-
- ##### DO:
-
- In the window of choices under File, use the down arrow key to move
- the highlight to Quit, then press Enter.
-
- NOTE: An option selected by typing the first letter is carried out
- immediately without pressing the Enter key. An option selected by
- moving the highlight to the desired option must be activated by
- pressing the Enter key.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 13
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- ##### DO:
-
- Try starting and stopping Turbo several times using both ways to
- choose File and Quit.
-
-
- 2. How to Switch and Zoom Windows
-
- There are two windows on the screen, the top one labelled Edit and
- the lower one Watch or Output. The Edit window is used for
- entering and editing programs. The Watch window is used with the
- DEBUG features in the lessons that follow. The Output window is
- used to display output when you run your programs. Switching the
- lower window between Watch and Output is covered in a later lesson.
-
- Only one of the two windows is active at any time. The active
- window has a double line at the top and the label is highlighted.
-
- ##### DO:
-
- Press F6 several times, noting the effect on the windows.
-
- F6 lets you switch between windows.
-
- Messages at the bottom of the screen show you the effect of special
- keys which are active with each window.
-
- ##### DO:
-
- Watch the messages at the bottom of the screen while you press F6
- several times.
-
- Did you see how the F6 message changed? When the Edit screen is
- active, the message F6-Output tells you that pressing F6 will
- switch to the Output window. When the Output window is active,
- F6-Edit prompts you to press F6 to switch to the Edit window.
-
- The messages at the bottom of the screen will help you find your
- way around while you get acquainted with Turbo Pascal.
-
- One of the messages is F5-Zoom.
-
- F5 switches the active window between a full screen display and a
- partial screen display. Sometimes you want to see both windows,
- sometimes just one window expanded to fill the full screen.
-
- ##### DO:
-
- Press F5 several times.
-
- ##### DO:
-
- Use F6 to switch to the other window, then press F5 several times.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 14
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- This feature is handy when you would like the full screen for
- editing a program or when you want to see program output displayed
- on the full screen.
-
- To make it easier to see the features of the editor without the
- Output window, we will use the full screen Edit window to explore
- how to edit a file.
-
-
- 3. How to Edit a File
-
- Why do you need to know how to edit a file?
-
- Programs are stored in files. Before you can run a program you
- must type the program into a file. You also use the editor to
- correct mistakes in the program.
-
- You will learn more of the details of editing a file later. Here
- you will type a short sentence to be stored in the Editor Work
- file. Later you will use the editor to type in programs.
-
- NOTE: Editor Work file here refers to the file you are currently
- editing. Earlier versions of Turbo Pascal referred to this file as
- the Work file; Starting with version 4.0, this file is called the
- Editor file. I refer to this file as the Editor Work file
- throughout these lessons.
-
-
- ##### DO:
-
- If the Edit window is not the active one, use F6 to switch to it.
- Then use F5 to "Zoom" the Edit window to full screen size.
- (Remember, the active window is marked with a double line at the
- top.)
-
- The blinking cursor should be at the upper left corner of the edit
- window.
-
- ##### DO:
-
- Type the sentence: This is in a file named ONE.
-
- In the next section you will Save this file and in a later section
- Load it back into the Edit Work file again.
-
-
- 4. How to Save a File
-
- Why do you need to know how to save a file?
-
- When you edit a program, it is in the computer memory. When you
- turn the computer off or leave the Turbo Pascal programming
- environment you will lose the program in the computer's memory. To
- preserve the program for future use, you must save the program as a
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 15
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- file on diskette or hard disk. Saving a program means making a
- copy of the program which is currently in the Editor Work file and
- placing that copy on a disk.
-
- The Save choice in the File menu window is used to store the
- current Editor Work file on diskette or hard disk.
-
- ##### DO:
-
- Choose the File option (type Alt-F), type S to Save the file you
- just entered.
-
- Notice that you could use the arrow keys to move the highlight to
- Save instead of typing S. Remember to use the Enter key to
- activate the highlighted option. If you just type S no Enter is
- required. You will soon form the habit of using the menu technique
- you find best for you.
-
- Look at the status line at the top of the screen--the name of your
- file is NONAME.PAS. This is the name Turbo gives your file until
- you rename it something else. The first time you save your file
- you are reminded to rename it.
-
- ##### DO:
-
- At the rename prompt type ONE as the new name for your file. Press
- the Enter key. (If you already have a file named ONE.PAS on the
- disk, you will be prompted for permission to overwrite the old
- ONE.PAS.)
-
- NOTE: You could type ONE.PAS instead of ONE, but it's not
- necessary. PAS will be added as the file extension anytime you
- omit the extension.
-
-
- Your Editor Work file has been stored on the disk with a name of
- ONE.PAS. When you need to recover this file, you can get it back
- with the Load choice in the File menu window. You will do that in
- a bit, but first, let's see how to find out which files are on your
- disk.
-
-
- 5. How to Display a Directory of Files
-
- After you have saved a few files you may forget their names or
- forget which ones you have on your disk. The Directory choice in
- the File menu window helps you list your disk files.
-
- ##### DO:
-
- Get the File menu window and type D to display a directory.
-
- Did you get a directory?
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 16
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- First, Turbo gives you a choice. Do you want to list all files
- (*.*) or files with a file extension of PAS (*.PAS) or maybe files
- that start with the letter S (S*.*)? Please check your operating
- system manual if you need more help with the meaning of the
- asterisk (*) in selecting groups of files to display.
-
- Turbo suggests the choice, *.*, to display all files.
-
- ##### DO:
-
- At the Enter Mask prompt, *.*, press the Enter key.
-
- You should see a list of all your files on the screen.
-
- The Esc key is used to back up to a previous of the menu. While
- your directory is displayed you can return to the Directory choice
- in the File window by pressing the Esc key.
-
- ##### DO:
-
- Press Esc to back-up to the Directory choice.
-
- The F10 key provides another way to exit the directory display.
- Pressing F10 will take you back to the main menu. Both the
- directory display and the File window will disappear.
-
- ##### DO:
-
- Display the directory again. Then use F10 to return to the main
- menu.
-
- F10 will take you back to the main menu from almost anywhere in the
- Turbo programming environment.
-
-
- 6. How to Edit a Different File
-
- Under the File option, the New choice allows you to establish a new
- file. Since there can only be one Editor Work file in computer
- memory at one time, the current Editor Work file will be removed
- from memory before starting the new file. If you haven't saved the
- current Editor Work file since it was last changed, you will be
- prompted to save it before establishing a new Editor Work file.
-
- ##### DO:
-
- Choose New in the File menu window.
-
- If you are prompted to save the current file, type Y.
-
- The blinking cursor should be at the upper left of the edit window.
- This indicates the editor is ready to use.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 17
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- ##### DO:
-
- Type: This is in file TWO.
-
- ##### DO:
-
- Save the Editor Work file. Name it TWO.
-
-
- 7. How to Recover a File Saved Earlier
-
- You have two files saved on the disk: ONE.PAS and TWO.PAS.
- TWO.PAS is also in the Editor Work file. If you wanted to get
- ONE.PAS back for further editing you would use the Load choice in
- the File menu window.
-
- ##### DO:
-
- Get the File menu window and type L to load a file.
-
- Turbo prompts you for Load File Name.
-
-
-
- ##### DO:
-
- Type ONE and press Enter.
-
- Notice the name of the file in the status line at the top of the
- screen. It should be ONE.PAS.
-
- There's another way to select the file to load into the Editor Work
- file. This method allows you to select the desired file from a
- menu. Load the file named TWO.PAS again using the load menu.
-
- ##### DO:
-
- Get the File menu window and press L to Load a file.
-
- ##### DO:
-
- When the Load File Name prompt appears type *.PAS and press the
- Enter key. (*.PAS may already be in the prompt box. Then you
- would only need to press the Enter key.)
-
- All files with a PAS extension should be displayed. You can use
- the arrow keys to move the highlight to the file you want to load.
- When the desired file is highlighted, press the Enter key to load
- the file.
-
- ##### DO:
-
- Use the arrow keys to move the highlight to the file, TWO.PAS.
- Press the Enter key.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 18
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- Check the status line to verify that file TWO.PAS is in the Editor
- Work file.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 19
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
-
- TURBO-LESSON 2. ESSENTIAL EDITING SKILLS
-
- OBJECTIVES - In lesson 2 you will develop skill in:
-
- 1. Moving the Cursor
- 2. Inserting and Replacing Text
- 3. Deleting Text
- 4. Efficiently Editing and Re-editing Files
-
- In the previous lesson you began your editing skills by entering a
- short sentence into a file and saving that file. In this lesson
- you will learn to get around the file by moving the cursor and to
- add, change, or delete text in the file.
-
-
- 1. Moving the Cursor
-
- To see how to move the cursor around you need several lines of text
- in your Editor Work file. Then you can try moving the cursor to
- see how the different keys work.
-
- NOTE: The Pascal programs supplied with these lessons are in files
- named PROG3.PAS, PROG4.PAS, etc. Sometimes you will need to create
- and name your own files for storing programs. I will simply
- suggest a file name to use when a DO section directs you to create
- a new file. In Turbo version 5.0 you don't supply the file name
- until the first time you save the file. I suggest you name the
- file immediately whether the version requires it or not, so that
- the file name always appears in the status line at the top of the
- Edit screen. You can save an "empty" file in 5.0 so you could save
- and name a file before editing it.
-
-
- ##### DO:
-
- Start a new file using the New option in the File menu box.
-
- ##### DO:
-
- Type the following lines into your Editor Work file. (Suggested
- file name: SKILLS.)
-
- This is not a program.
- This is only to seeee how teh editttor works.
- You can type whatever you want.
-
- Notice the status line on the top of the screen as you type. It
- lets you know the line and column of the cursor's position. To
- move around the screen easily, use the arrow keys at the right of
- the keyboard to move the cursor. If your keyboard doesn't have
- arrow keys, note that the following may be substituted for the
- arrow keys:
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 20
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
-
- Ctrl-s = left-arrow
- Ctrl-d = right-arrow
- Ctrl-e = up-arrow
- Ctrl-x = down-arrow
-
- ##### DO:
-
- Try out the arrow keys. The left and right arrows move the cursor
- one character to the left or right, and the up and down arrows move
- the cursor one line up or down, as long as there is something typed
- there.
-
- ##### DO:
-
- To move a little faster, try Ctrl-left-arrow. It moves the cursor
- one word to the left. Ctrl-right-arrow moves one word to the
- right. (Ctrl-A = Ctrl-left-arrow, Ctrl-F = Ctrl-right-arrow.)
-
- ##### DO:
-
- Try some of the other cursor movement keys. Home takes you to the
- beginning (left) of the current line, while End moves the cursor to
- the end of the current line. Ctrl-Home moves the cursor to the top
- of the current screen, while Ctrl-End moves the cursor to the
- bottom of the current screen.
-
- Two other keys that are useful if your program is longer and will
- not all fit on one screen are the PgUp and PgDn keys. They move
- the cursor to the previous or next screen respectively. Also,
- Ctrl-PgUp moves to the very beginning of the file, while Ctrl-PgDn
- moves to the end of the file. (With only a few practice lines in
- your Work file, you may not see the benefit of these keys.
- Remember to try these combinations later when you are working with
- larger files.)
-
-
- 2. Inserting and Replacing Text
-
- There are two ways to type text when using an editor or word
- processor:
-
-
- 1. Insert new text while pushing existing text to the right
- to make room for the new text, and
-
- 2. Overwrite text by typing over the original text. (You may
- know this as the "Replace" mode or "Typeover" mode if you
- use other editors or word processors.)
-
- ##### DO
-
- Look at the top line of the screen while depressing the Ins key
- several times. The status line indicates whether "Insert" or
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 21
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- "Overwrite" mode is presently active. The Ins key is the way to
- switch between modes.
-
- ##### DO:
-
- Try using both modes on the text. Type this sentence:
-
- Today is a nice day.
-
- Change it to say it is a nice sunny day. The easiest way to do
- that (adding a new word) is to use insert mode. The text is
- inserted to the left of the cursor.
-
- Change sunny to rainy. The quickest way to do this is to use
- overwrite mode, since you want to replace one word with another.
-
- A very significant difference between Insert and Overwrite mode is
- the way the Enter key works in the two modes. With the editor in
- the insert mode, you can use the Enter key to open up new blank
- lines for inserting new lines of text or program. This doesn't
- work in the overwrite mode.
-
- ##### DO:
-
- Use the Ins key to put the editor in the Overwrite mode.
-
- Place the cursor at the beginning of one of your lines of text.
-
- Press the Enter key several times. What happens?
-
- ##### DO:
-
- Put the editor in the Insert mode.
-
- Press the Enter key several times. What results does this produce?
-
- REMEMBER THIS WHEN THE ENTER KEY DOESN'T SEEM TO WORK RIGHT!
-
-
- 3. Deleting Text
-
- There are several ways to delete text:
-
- 1. The Del key (or Ctrl-G) deletes the character at the
- cursor position and pulls the characters from the right.
- You might think of this as "eating" the characters to the
- right.
-
- 2. The backspace key (or Ctrl-H) deletes the character to
- the left of the cursor and pulls the characters from the
- right. This "eats" characters to the left. Note that
- this is not the same action as the left arrow key which
- moves the cursor left without deleting characters.
-
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 22
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- 3. Ctrl-Y deletes the entire line that the cursor is on.
- The previous two ways to delete just delete one character
- at a time while Ctrl-Y gives you a way to delete a whole
- line at a time. (Remember, the Enter key will open up a
- blank line when the editor is in the insert mode. Ctrl-Y
- doesn't leave a blank line where a line is deleted.)
-
- ##### DO:
-
- Try correcting the mistakes in your file by deleting mistakes and
- correcting them with either insert or overwrite. Type in more
- sentences with mistakes and try different ways to correct them to
- see for yourself how these different techniques work. Try deleting
- a whole line.
-
- You have tried the basics of entering and editing your program.
- Learning these now will save time and frustration later when you
- are working on programs! So if you are unsure how some of these
- work, go back and experiment with them until you are comfortable
- with the basic editing features.
-
- NOTE: THE REMAINDER OF LESSON 2 IS INTENDED TO HELP YOU GET "UP TO
- SPEED" USING THE TURBO PROGRAMMING ENVIRONMENT. THE EDITING AND
- FILE HANDLING SKILLS YOU DEVELOP NOW WILL SAVE TIME AND FRUSTRATION
- IN LATER LESSONS.
-
-
-
- 4. Experimenting On Your Own
-
- In the next lesson you will begin writing Pascal programs. How
- well you learn to program in Pascal will be determined by how well
- you teach yourself. Programming is learned best by programming,
- experimenting, trying things on your own. The ##### DO sections in
- these lessons are only intended to get you started. When you do
- the activities suggested, you will probably get ideas for other
- things to try. You should pursue your ideas--try to expand on the
- programs provided.
-
- The biggest obstacle to experimentation is the fear of "messing up"
- the program that is being built by the DO sections. The main
- purpose here is to provide enough practice SAVING and RETRIEVING a
- program so that you will have no fear of losing the "official"
- program while experimenting with programs of your own.
-
-
- 5. Saving and Retrieving Programs
-
- Because there is only one Editor Work file in the computer's memory
- at any one time, you need to be able to quickly save a file so you
- can experiment with a different one. When you are through
- experimenting, you can easily retrieve the program you were
- previously editing.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 23
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- Turbo makes it very easy to save your programs. Turbo will remind
- you to save your program if you are about to do something that
- would erase it. However, it is up to you to be sure your program
- is saved.
-
- To develop facility saving and retrieving files, you will edit and
- re-edit files named ONE, TWO, THREE, FOUR, and FIVE. You already
- have files named ONE and TWO. You will first add files THREE,
- FOUR, and FIVE with a short sentence in each. Then you will edit
- each file again to add your first name as the second line of each
- file. Finally, you will edit each file again, adding your last
- name. If you time yourself as you edit each of the five files the
- last time you may be surprised at how quickly you can carry out
- these essential file operations.
-
- ##### DO:
-
- Start a new file.
-
- ##### DO:
-
- Type: This is in file THREE.
-
- Save this file with the file name THREE.
-
- ##### DO:
-
- Create and save files FOUR and FIVE with the messages:
- This is in file FOUR and This is in file FIVE.
-
- If you have trouble with these steps, please refer back to
- lesson 1.
-
-
- 6. Re-Editing Each File
-
- At this point you will add a line with your first name to each
- file. Remember to use the Insert mode to enter the additional
- line.
-
- ##### DO:
-
- Load file ONE. Edit the file to add your first name as a second
- line of the file. To position the cursor at the beginning of a new
- line, first move it to the end of the existing line and press the
- enter key. (The editor must be in Insert mode).
-
- Save the file.
-
- ##### DO:
-
- Do the same Load, Edit, Save to add your first name to each of the
- other files.
-
- î TURBO-LESSONS - A Pascal Tutorial Version 5.0 Page 24
- Copyright 1989 Lyle M. Faurot Lessons 1-16: $10.00
-
-
-
- 7. Getting Up to Speed
-
- As you edit the files one final time to add your last name, you
- might want to time yourself--you are getting pretty good at this by
- now!
-
- ##### DO:
-
- Add your last name following your first name in each of the files.
-
- That didn't take long, did it?
-
- REMEMBER: IN THE LESSONS THAT FOLLOW, IT'S QUITE EASY TO SAVE A
- PROGRAM, SO YOU CAN EXPERIMENT WITH YOUR OWN IDEAS.