Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 5/Subranges: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Basic Pascal Tutorial/Chapter 5/Subranges

OldNewLine
1+5B - Subranges (author: Tao Yue, state: unchanged)
2+
3+A *subrange* type is defined in terms of another ordinal data type. The type specification is:
4+
5+``` pascal
6+lowest_value .. highest_value
7+```
8+
9+where `lowest_value < highest_value` and the two values are both in the range of another ordinal data type.
10+
11+For example, you may want to declare the days of the week as well as the work week:
12+
13+``` pascal
14+type
15+ DaysOfWeek = (Sunday, Monday, Tuesday, Wednesday,
16+ Thursday, Friday, Saturday);
17+ DaysOfWorkWeek = Monday..Friday;
18+```
19+
20+You can also use subranges for built-in ordinal types such as `char` and `integer`.
21+
22+---
23+*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 5/Subranges", as it stood on 2022-08-20 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history