home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Learn Pascal in a Three Days (2nd Ed.)
(Publisher: Wordware Publishing, Inc.)
Author(s):
ISBN: 1556225679
Publication Date: 07/01/97

Bookmark It

Search this book:
 
Previous Table of Contents Next


Suggestions

In order to make the program more reliable, you may add the following features:

1.  When you enter the “SSN” for a new employee, the program does not check the data format; in which case, a wrong number such as “12345-678” will be accepted. You can add the necessary statements to check for the exact number of digits as well as the hyphens.
2.  If you enter a value other than 1, 2, or 3, it will be accepted as a “Category.” Consequently, the salary will not be processed by the CASE structure. You can add the necessary steps to check the valid values of the “Category” variable.
3.  If you added the same employee to the file twice, this program would not know that the record already exists. Therefore, you need to check the “SSN” before you add a new record.
4.  If you are using Turbo Pascal, you would better use units. With units you can put each procedure in a separate file called a unit. The units you build could be usable by more than one program.

These enhancements are left for you as a drill.

Summary

1.  In this chapter you learned how to use variant records to store your data into an efficient data structure.
2.  You can declare a variant record type using the following format:
    type-name = RECORD
          fixed field-list
          variant field-list
    END

The variant field list takes the following form:
    CASE tag-field : type-definition OF
         label-1   : ( field-list : type-definition)
         label-2   : ( field-list : type-definition)
         ...
         label-n   : ( field-list : type-definition)
3.  The variant record may contain a fixed part followed by a variant part, or a variant part only.
4.  You learned how to read, write, update, and delete variant records stored in files, using the CASE structure.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.