Sign in Join
Wiki copytemporary

subrange types/fr: what changed

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

Title: subrange types/fr

OldNewLine
1+Plages de valeurs : La définition la détermine par elle-même.
2+
3+Occupation en mémoire : Correspond au type sous-jacent.
4+
5+Propriétés :
6+
7+- il définit une partie d'un type de base.
8+- les champs de donnée de ce type ne peuvent prendre que les valeurs spécifiées dans la définition.
9+
10+Tout autre valeur conduit à une erreur de compilation, le programme ne sera donc pas créé.
11+
12+Il existe deux façons de définir les types de sous-étendue.
13+
14+Variante 1, la variable est définie directement :
15+
16+``` pascal
17+ Var
18+ tbZahl1: 10..123;
19+ tbBuchstabe1: 'A'..'Z';
20+```
21+
22+Variante 2, on définit un sous-type en premier lieu:
23+
24+``` pascal
25+ type
26+ TZahl2 = 10..123;
27+ TBuchstabe2 = 'A'..'Z';
28+ Var
29+ tbZahl2: TZahl2;
30+ tbBuchstabe2: TBuchstabe2;
31+```
32+
33+Exemples d'affectation avec une valeur correcte :
34+
35+``` pascal
36+ tbZahl1 := 10;
37+ tbZahl1 := 123;
38+ tbZahl2 := 10;
39+ tbZahl2 := 123;
40+ tbBuchstabe1 := 'F';
41+ tbBuchstabe2 := 'F';
42+```
43+
44+Exemples d'affectation avec une valeur incorrecte :
45+
46+``` pascal
47+ // la valeur est en dehors de partie du type
48+ tbZahl1 := 9;
49+ tbZahl2 := 124;
50+ tbBuchstabe1 := 'f';
51+ tbBuchstabe2 := 'f';
52+ // L'affectation avec des chaîne doit passer par une conversion de type
53+ tbZahl1 := '10';
54+ tbZahl1 := '123';
55+ tbZahl2 := '10';
56+ tbZahl2 := '123';
57+```
58+
59+---
60+*From the Free Pascal wiki, page "subrange types/fr", as it stood on 2020-02-28 after a change by Trev, 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