13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This declaration creates the new data type DAY_ WEEK. With it, you canthen declare a user-defined scalar variable:VAR TODAY: DAY_WEEKThe variable TODAY can take just one out of seven values-namely, thevalue MO or the value TU or the value WE, and so on.You can also declare TODAY directly, without a prior type declaration:VAR TODAY: CMO,TU,WE,TH,FR,SA,SU>;User-defined scalar variables and their subranges can be used with thefollowing operations::= = CHR ORD SUCC PREDThe values of any user-defined scalar type are implicitly associated withthe positive integer range 0,1,2 ... Thus, for example, the functionORDCTDDAY> would return the integer 3 if the value of TODAY were TH.Scalar operations such as ORD are described in Chapter 6.Subrange TypesA subrange type may be defined for any scalar type, includinguser-defined scalars:constantconstantThe two constants must be units of the same scalar type and the secondconstant must have a higher value than the first in the scalar order. Hereare some examples:TYPE MINUTES= B .. 59;WORKDAY= MO .. FR;{integer subrange type}{subrange of user-defined type}VAR GRADE: 'A' .. 'F';{variable of CHAR subrange type}Subranges may also be defined for boolean types and variables; but becausethere are only two boolean units, every such subrange is equivalent to aconstant.Subrange TypesIII-35

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

Saved successfully!

Ooh no, something went wrong!