Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
prog:lazarus:types:const [18/03/2020 19:27]
thierry [Definir une constante a l'initialisation d'une unité]
prog:lazarus:types:const [17/05/2021 10:14] (Version actuelle)
thierry [Array en Const]
Ligne 1: Ligne 1:
 ====== Constantes ====== ====== Constantes ======
 +===== Exemples =====
 +<code delphi>
 +Const
 +  MonthStart = 0 ; // could be 1 and
 +  MonthEnd ​  = 11; // 12 if desired
 +  DayStart ​  = 0 ; // same,could be 1 and
 +  DayEnd ​    = 6;  // 7
 +  DayNameCh: array [DayStart .. DayEnd] of char =(
 +        '​S','​M','​T','​W','​H','​F','​A'​);​
 +  DayNameShort:​ array [DayStart .. DayEnd] of string=
 +    ( '​Sun','​Mon','​Tue','​Wed','​Thu',​
 +      '​Fri','​Sat'​ ) ;
 +  DayNameLong:​ array DayStart .. DayEnd] of 
 +    string = ( '​Sunday',​ '​Monday','​Tuesday','​Wednesday',​
 +               '​Thursday',​ '​Friday',​ '​Saturday'​ );
 +     ​MonthNameLong:​ array[MonthStart ..MonthEnd] of string = (
 +  '​January','​February','​March','​April',​
 +  '​May','​June','​July','​August',​
 +  '​September','​October','​November'​.
 +  '​December'  ​
 +             );
 +   ​MomthDays:​ ARRAY [ MonthStart .. MonthEnd ] of
 +    integer = ( 31, 28, 31, 30, 31, 30,
 +                31, 31, 30. 31, 30, 31 );
 +</​code> ​               ​
 +
 ===== Definir une constante a l'​initialisation d'une unité ===== ===== Definir une constante a l'​initialisation d'une unité =====
 <code delphi> <code delphi>
Ligne 23: Ligne 49:
 initialization initialization
   {affectation de la constante}   {affectation de la constante}
-  MA_CONST:=GetQPF;+  MA_CONST:=GetValue;
 end. end.
  
 </​code>​ </​code>​
 +===== Record en Const =====
 +<code delphi>
 +   ​C_CHAR_INFLATE:​ TSize = (cx: 2; cy: 2);
 +</​code>​
 +===== Array en Const =====
 +<code delphi>
 +DayNameShort:​ array [0 .. 6] of string=
 +    ( '​Sun','​Mon','​Tue','​Wed','​Thu',​
 +      '​Fri','​Sat'​ ) ;
 +      </​code>​
 +===== Sources et Ressources =====
 +  * [[https://​wiki.lazarus.freepascal.org/​Constants]]
 +
 +