Previous | Next | Table of Contents | Index | Program List | Copyright

12.6 Tricks of the Trade: Common Programming Errors

When you use multidimensional arrays, make sure the subscript for each dimension is consistent with its declared type. If any subscript value is out of range, Constraint_Error will be raised, of course.

If you use nested FOR loops to process the array elements, make sure that loop control variables used as array subscripts are in the correct order. The order of the loop control variables determines the sequence in which the array elements will be processed.

Understanding variant records is not always easy. In defining variant record structures, remember that the only way to allow for changing the variant stored in a variant record variable is to supply a default value for the discriminant. This action makes the variable unconstrained.

In using variant record variables, keep in mind that the value of the discriminant field determines the form of the variant part that is currently defined; attempting to manipulate any other variant will cause either a compilation error or the raising of Constraint_Error. It is the programmer's responsibility to ensure that the correct variant is being processed; consequently, a variant record should always be manipulated in a CASE statement with the discriminant field used as the CASE selector to ensure that the proper variant part is being manipulated.


Previous | Next | Table of Contents | Index | Program List | Copyright

Copyright © 1996 by Addison-Wesley Publishing Company, Inc.