Difference between revisions of "Basic Pascal Tutorial/Chapter 5/Subranges"
From Lazarus wiki
Jump to navigationJump to searchLine 16: | Line 16: | ||
{|style=color-backgroud="white" cellspacing="20" | {|style=color-backgroud="white" cellspacing="20" | ||
|[[Enumerated_types|previous]] | |[[Enumerated_types|previous]] | ||
− | |[[ | + | |[[Contents|contents]] |
|[[1-dimensional_arrays|next]] | |[[1-dimensional_arrays|next]] | ||
|} | |} |
Revision as of 22:18, 25 November 2007
5B - Subranges (author: Tao Yue, state: unchanged)
A subrange type is defined in terms of another ordinal data type. The type specification is:
lowest_value .. highest_value
where lowest_value < highest_value and the two values are both in the range of another ordinal data type.
For example, you may want to declare the days of the week as well as the work week:
type DaysOfWeek = (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday); DaysOfWorkWeek = Monday..Friday;
You can also use subranges for built-in ordinal types such as char and integer.
previous | contents | next |