28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix A<br />

addition, any type which is a subrange of these is an ordinal type. Whenever<br />

a type is used to select an object from a number of objects, an ordinal type is<br />

required.<br />

PROGRAM ok;<br />

BEGIN<br />

END.<br />

TYPE colour = (red, yellow, green, blue);<br />

VAR vector : ARRAY [colour] OF integer;<br />

The error message is generated if an enumerated type is required and the<br />

given type is not enumerated.<br />

PROGRAM fail;<br />

BEGIN<br />

END.<br />

TYPE enum1 = (alpha, beta, gamma);<br />

VAR bad1 : ARRAY [real] OF integer; )real isn't ordinal}<br />

good : SET OF enum1; [enuml is ordinal}<br />

*ERROR 61 -- integer index types are not permitted<br />

The compiler will not permit arrays to be declared where the type of the<br />

index is integer. If it were to do so the program would require more<br />

working memory than most computers can provide.<br />

PROGRAM fail;<br />

VAR a : ARRAY [integer] of char; (this would be huge}<br />

BEGIN<br />

END.<br />

a[-maxint] := 'a';<br />

a[+maxint] 'o';<br />

*ERROR 62 -- an object of this type may not be given a '+' sign<br />

*ERROR 62 -- an object of this type may not be given a '-' sign<br />

Plus or minus signs may only be given to numerical objects. In particular<br />

enumerated type and char type values may not be signed.<br />

<strong>Pascal</strong> Issue 1 65

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!