Developpez.com - Rubrique Pascal

Le Club des Développeurs et IT Pro

Sortie de la version 13.04.29 de FlashPascal 2

Compilateur Pascal pour machine virtuelle Flash

Le 2013-04-29 12:15:09, par Paul TOTH, Expert éminent sénior
Sortie de la version 13.04.29 de FlashPascal 2
Avec, comme nouveauté principale, l'ajout des ensembles



http://flashpascal.execute.re/

Bonjour,

Je viens de publier une nouvelle version de FlashPascal 2 !

Au programme :

- Correction du constructeur des classes utilisateurs : il est maintenant possible de dériver d'une autre classe correctement.
Code :
1
2
3
4
5
6
7
type
  TMaClass = class
  end;

  TMaClass2 = class(TMaClass)
  end;
- Ajout des SET et SET OF avec les opérateurs IN + - * et de Include et Exclude.
Code :
1
2
3
4
type
  TValue = (un = 1, deux, trois);
  TValues = set of TValue;
- Ajout d'un préfixe "." pour les membres d'un Variant dans un With (sans ce point, le compilateur ne peut pas savoir qu'il faut faire référence au Variant car il n'a pas de description !).
Code :
1
2
3
4
5
6
7
8
9
10
var
  v: Variant;
begin
  with v do
  begin
    .lineTo(0,0);
    .color := clBlue;
  end;
end;
  Discussion forum
3 commentaires
  • Archimède
    Membre chevronné
    Merci , je regarde ça quand le temps me le permettra.
    Encore bien actif malgré tes nouvelles fonctions de papa aguerri

    a+

    anthony
  • Roland Chastain
    Rédacteur/Modérateur
    Excellent !

    Je me suis penché sur le type set of, qui est une particularité du Pascal que j'aime bien.

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    program Set1;
    
    {$FRAME_WIDTH 320}
    {$FRAME_HEIGHT 200}
    
    const
      LARGEUR = 320;
      HAUTEUR = 200;
    
    type
      Number = Double;
    
      MovieClip = external class
      end;
    
      TextField = external class
        constructor Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number) as Parent.createTextField;
        property text: string;
      end;
    
    var
      textField1: TextField;
      sortie: string;
    
    function BoolStr(b: boolean): string;
    begin
      if b then Result := 'VRAI' else Result := 'FAUX';
    end;
      
    type
      tJour = (dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi);
      
    var
      s1, s2, s3: set of tJour;
    
    begin
    ////////////////////////////////////////////////////////////////////////////////
      textField1 := TextField.Create(nil, 'textField1', 0, 0, 0, LARGEUR, HAUTEUR);
    ////////////////////////////////////////////////////////////////////////////////
      
      s1 := [dimanche, lundi];
      s2 := [jeudi];
      s3 := s1 + s2;
      
      sortie := BoolStr(lundi in s3);
        
    { Résultat : VRAI }
      
    ////////////////////////////////////////////////////////////////////////////////
      textField1.text := sortie;
    ////////////////////////////////////////////////////////////////////////////////
    end.
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    program Set2;
    
    {$FRAME_WIDTH 320}
    {$FRAME_HEIGHT 200}
    
    const
      LARGEUR = 320;
      HAUTEUR = 200;
    
    type
      Number = Double;
    
      MovieClip = external class
      end;
    
      TextField = external class
        constructor Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number) as Parent.createTextField;
        property text: string;
      end;
    
    var
      textField1: TextField;
      sortie: string;
    
    function BoolStr(b: boolean): string;
    begin
      if b then Result := 'VRAI' else Result := 'FAUX';
    end;
      
    type
      tJour = (dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi);
      
    var
      s1, s2, s3: set of tJour;
    
    begin
    ////////////////////////////////////////////////////////////////////////////////
      textField1 := TextField.Create(nil, 'textField1', 0, 0, 0, LARGEUR, HAUTEUR);
    ////////////////////////////////////////////////////////////////////////////////
      
      s1 := [dimanche, lundi];
      s2 := [jeudi];
      s3 := s1 * s2;
      
      sortie := BoolStr(lundi in s3);
      
    { Résultat : FAUX }
      
    ////////////////////////////////////////////////////////////////////////////////
      textField1.text := sortie;
    ////////////////////////////////////////////////////////////////////////////////
    end.
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    program Set3;
    
    {$FRAME_WIDTH 320}
    {$FRAME_HEIGHT 200}
    
    const
      LARGEUR = 320;
      HAUTEUR = 200;
    
    type
      Number = Double;
    
      MovieClip = external class
      end;
    
      TextField = external class
        constructor Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number) as Parent.createTextField;
        property text: string;
      end;
    
    var
      textField1: TextField;
      sortie: string;
    
    function BoolStr(b: boolean): string;
    begin
      if b then Result := 'VRAI' else Result := 'FAUX';
    end;
      
    type
      tJour = (dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi);
      
    var
      s: set of tJour;
    
    begin
    ////////////////////////////////////////////////////////////////////////////////
      textField1 := TextField.Create(nil, 'textField1', 0, 0, 0, LARGEUR, HAUTEUR);
    ////////////////////////////////////////////////////////////////////////////////
      
      s := [dimanche, lundi];
      
      include(s, vendredi);
      
      sortie := BoolStr(vendredi in s);
      
    { Résultat : VRAI }
      
    ////////////////////////////////////////////////////////////////////////////////
      textField1.text := sortie;
    ////////////////////////////////////////////////////////////////////////////////
    end.
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    program Set4;
    
    {$FRAME_WIDTH 320}
    {$FRAME_HEIGHT 200}
    
    const
      LARGEUR = 320;
      HAUTEUR = 200;
    
    type
      Number = Double;
    
      MovieClip = external class
      end;
    
      TextField = external class
        constructor Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number) as Parent.createTextField;
        property text: string;
      end;
    
    var
      textField1: TextField;
      sortie: string;
    
    function BoolStr(b: boolean): string;
    begin
      if b then Result := 'VRAI' else Result := 'FAUX';
    end;
      
    type
      tJour = (dimanche, lundi, mardi, mercredi, jeudi, vendredi, samedi);
      
    var
      s: set of tJour;
    
    begin
    ////////////////////////////////////////////////////////////////////////////////
      textField1 := TextField.Create(nil, 'textField1', 0, 0, 0, LARGEUR, HAUTEUR);
    ////////////////////////////////////////////////////////////////////////////////
      
      s := [dimanche, lundi];
      
      exclude(s, dimanche);
      
      sortie := BoolStr(dimanche in s);
      
    { Résultat : FAUX }
      
    ////////////////////////////////////////////////////////////////////////////////
      textField1.text := sortie;
    ////////////////////////////////////////////////////////////////////////////////
    end.
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    program Set5;
    
    {$FRAME_WIDTH 320}
    {$FRAME_HEIGHT 200}
    
    const
      LARGEUR = 320;
      HAUTEUR = 200;
    
    type
      Number = Double;
    
      MovieClip = external class
      end;
    
      TextField = external class
        constructor Create(Parent: MovieClip; Name: string; Depth, Left, Top, Width, Height: Number) as Parent.createTextField;
        property text: string;
      end;
    
    var
      textField1: TextField;
      sortie: string;
      
    type
      tJour = (dimanche = 1, lundi, mardi, mercredi, jeudi, vendredi, samedi);
    
    const
      ChaineJour: array[1..7]of string = ('dimanche', 'lundi', 'mardi', 'mercredi',
      'jeudi', 'vendredi', 'samedi');
      
    var
      s: set of tJour;
      j: tJour;
    
    begin
    ////////////////////////////////////////////////////////////////////////////////
      textField1 := TextField.Create(nil, 'textField1', 0, 0, 0, LARGEUR, HAUTEUR);
    ////////////////////////////////////////////////////////////////////////////////
      
      s := [dimanche, lundi];
      
      s := s + [mercredi];
    
      sortie := '';
      for j := dimanche to samedi do
        if j in s then
          begin
            sortie := sortie + ChaineJour[Ord(j)];
            sortie := sortie + Chr(13);
          end;
          
    { Résultat :
      dimanche
      lundi
      mercredi }
      
    ////////////////////////////////////////////////////////////////////////////////
      textField1.text := sortie;
    ////////////////////////////////////////////////////////////////////////////////
    end.
  • Paul TOTH
    Expert éminent sénior
    ah merci de faire des tests, ça améliore le produit