IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Comment afficher fichier séquentiel volumineux


Sujet :

Delphi

  1. #1
    Membre régulier
    Inscrit en
    Mai 2003
    Messages
    146
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 146
    Points : 116
    Points
    116
    Par défaut Comment afficher fichier séquentiel volumineux
    J'utilise Delphi 7 personnel donc pas de base de donnée.
    J'ai créé un fichier séquentiel.
    type
    TLoto = record
    Nombre: String[8];
    N1: String[2];
    N2: String[2];
    N3: String[2];
    N4: String[2];
    N5: String[2];
    N6: String[2];
    end;
    TLoto649 = file of TLoto;
    Mon application génères des miliers de "record", pas de problème à ce point.
    Ça ce complique lorsque je veux voir ces enregistrement: Avec un TListview, c'est possible lorsqu'il y a quelques centaines ou milliers d'enregistrement mais plus ça augmente, plus c'est lent jusqu'à planter mon application.

    Y a t'il un moyen, sans recourir à une base de donnée, de pouvoir voir un fichier séquentiel de grande envergure sans trop de perte de temps.
    Notez que le fichier peut contenir plusieurs millions d'enregistrement.

  2. #2
    Membre éprouvé
    Avatar de Dr.Who
    Inscrit en
    Septembre 2009
    Messages
    980
    Détails du profil
    Informations personnelles :
    Âge : 45

    Informations forums :
    Inscription : Septembre 2009
    Messages : 980
    Points : 1 294
    Points
    1 294
    Par défaut
    coucou déjà oublis le File Of TLoto.


    Un manque de performance, c'est un programme mal pensé, mal établis.


    Que penserai tu d'un truc base sur TFileStream, avec que des entiers

    voici un exemple, heu ... complet en fait

    Loto.pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
     
    unit Loto;
     
    interface
     
    uses
      Windows, SysUtils, Classes;
     
    type
      PLoto = ^TLoto;
      TLoto = packed record
        case byte of
          0:(Numbers : array[0..6] of byte);
          1:(N1,N2,N3,N4,N5,N6,N7: byte);
      end;
     
    const
      SizeOfLoto = SizeOf(TLoto);
      LotoDefault: TLoto = (Numbers:(0,0,0,0,0,0,0));
     
    type
      TLotoFile = class
      private
        fLotos : array of TLoto;
        fStream: TFileStream;
        function getLoto(index: integer): TLoto;
        procedure setLoto(index: integer; const Value: TLoto);
      public
        property loto[index: integer]: TLoto   read getLoto   write setLoto; default;
     
        function count: integer;
     
        function Push(aLoto: TLoto): integer; overload;
        function Pop: TLoto;
     
        function IndexOf(aLoto: TLoto): integer;
     
        procedure Exchange(IndexA, IndexB: integer);
     
        constructor Create(aFileName: string); reintroduce;
        destructor Destroy; override;
      end;
     
    function LotoToString(aLoto : TLoto): string;
    function LotoCompare(A, B: TLoto): boolean;
    function LotoCreate(aN1,aN2,aN3,aN4,aN5,aN6,aN7: byte): TLoto;
     
    implementation
     
    function LotoCreate(aN1,aN2,aN3,aN4,aN5,aN6,aN7: byte): TLoto;
    begin
      result.N1 := aN1;
      result.N2 := aN2;
      result.N3 := aN3;
      result.N4 := aN4;
      result.N5 := aN5;
      result.N6 := aN6;
      result.N7 := aN7;
    end;
     
    function LotoCompare(A, B: TLoto): boolean;
    begin
      result := compareMem(@A, @B, SizeOfLoto);
    end;
     
    function LotoToString(aLoto : TLoto): string;
    begin
      result := format('%d, %d, %d, %d, %d, %d et %d',
                       [ aLoto.Numbers[0],
                         aLoto.Numbers[1],
                         aLoto.Numbers[2],
                         aLoto.Numbers[3],
                         aLoto.Numbers[4],
                         aLoto.Numbers[5],
                         aLoto.Numbers[6] ]);
    end;
     
    { TLotoFile }
     
    function TLotoFile.count: integer;
    begin
      result := fStream.Size div SizeOfLoto;
    end;
     
    constructor TLotoFile.Create(aFileName: string);
    begin
      inherited Create;
      if FileExists(aFileName) then
        fStream := TFileStream.Create(aFileName, fmOpenReadWrite)
      else
        fStream := TFileStream.Create(aFileName, fmCreate);
    end;
     
    destructor TLotoFile.Destroy;
    begin
      fStream.free;
      inherited;
    end;
     
    procedure TLotoFile.Exchange(IndexA, IndexB: integer);
    var A,B: TLoto;
    begin
      A := getLoto(IndexA);
      B := getLoto(IndexB);
      setLoto(IndexA, B);
      setLoto(IndexB, A);
    end;
     
    function TLotoFile.getLoto(index: integer): TLoto;
    begin
      if (Index >= 0) and (Index < Count) then
      begin
        fStream.Seek(Index * SizeOfLoto, soFromBeginning);
        fStream.Read(result, SizeOfLoto);
      end
      else
        assert(false, format('%d is out of Indexs [0..%d]',[Index, Count-1]));
    end;
     
    function TLotoFile.IndexOf(aLoto: TLoto): integer;
    var X: integer;
    begin
      result := -1;
      for X := 0 to Count - 1 do
        if LotoCompare(getLoto(X), aLoto) then
        begin
          result := X;
          break;
        end;
    end;
     
    function TLotoFile.Pop: TLoto;
    begin
      fStream.Seek(fStream.Size-SizeOfLoto, soFromBeginning);
      fStream.Size := fStream.Size - SizeOfLoto;
    end;
     
    function TLotoFile.Push(aLoto: TLoto): integer;
    begin
      result := Count;
      fStream.Seek(0, soFromEnd);
      fStream.Write(aLoto, SizeOfLoto);
    end;
     
    procedure TLotoFile.setLoto(index: integer; const Value: TLoto);
    begin
      if (Index >= 0) and (Index < Count) then
      begin
        fStream.Seek(Index * SizeOfLoto, soFromBeginning);
        fStream.Write(Value, SizeOfLoto);
      end
      else
        assert(false,format('%d is out of Indexs [0..%d]',[Index, Count-1]));
    end;
     
     
    end.

    LotoDemo.pas/projet
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    unit LotoMain;
     
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Loto, StdCtrls;
     
    type
      TForm8 = class(TForm)
        ListBox1: TListBox;
        procedure FormCreate(Sender: TObject);
        procedure FormDestroy(Sender: TObject);
      private
        { Déclarations privées }
      public
        LotoFile : TLotoFile;
      end;
     
    var
      Form8: TForm8;
     
    implementation
     
    {$R *.dfm}
     
     
    // create random number in 1..50
    function randByte: byte;
    begin
      result := byte(1+random(50));
    end;
     
     
    procedure TForm8.FormCreate(Sender: TObject);
    var X: integer;
        L: TLoto;
    begin
      // create LotoFile
      LotoFile := TLotoFile.Create(ExtractFilePath(ParamStr(0))+'LotoTest.loto');
     
    {  // generate 1 000 of unic sequence.
      for X := 0 to 999 do
      begin
        // create a random sequence
        L := LotoCreate(randByte, randByte, randByte, randByte, randByte, randByte, randByte);
     
        // while in file
        while LotoFile.IndexOf(L) <> -1 do
          // create new random sequence
          L := LotoCreate(randByte, randByte, randByte, randByte, randByte, randByte, randByte);
     
        // is ok, push the sequence !
        LotoFile.Push(L);
      end;
    }
      // show many informations
      ListBox1.items.add('Total d''entrées  : '+IntToStr(LotoFile.count));
      ListBox1.items.add('Taille du fichier : '+IntToStr(LotoFile.count*SizeOfLoto));
      ListBox1.Items.add('');
      ListBox1.Items.add('Affichage des 100 premiers');
      ListBox1.Items.BeginUpdate;
      try
        for X := 0 to LotoFile.count-1 do
        begin
          ListBox1.Items.Add(IntToStr(X)+' = '+LotoToString(LotoFile.loto[X]));
          if X >= 99 then
            break;
        end;
      finally
        ListBox1.Items.EndUpdate;
      end;
    end;
     
     
    procedure TForm8.FormDestroy(Sender: TObject);
    begin
      // hey, free the file !
      LotoFile.Free;
    end;
     
    initialization
      Randomize;
     
    end.
    [ Sources et programmes de Dr.Who | FAQ Delphi | FAQ Pascal | Règlement | Contactez l'équipe ]
    Ma messagerie n'est pas la succursale du forum... merci!

  3. #3
    Membre régulier
    Inscrit en
    Mai 2003
    Messages
    146
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 146
    Points : 116
    Points
    116
    Par défaut
    Je vais essayer de comprendre la solution de dr. Who. Je crois que je me suis mal expliqué: Mon but n'est pas de générer des numéros de loto aléatoires. "LOTO" a créé cet équivoque mais seulement de trouver toutes les possibilités de combinaisons possible pour cette loterie: 6 numéros de 1 à 49 : plus petite combinaison possible : 1-2-3-4-5-6. Plus grande combinaison: 44-45-46-47-48-49.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    procedure TForm1.BCreerClick(Sender: TObject);
      var
        Image: TLoto;
        tempF: TLoto649;
        NBV:Integer;
        N1V,N2V,N3V,N4V,N5V,N6V: Byte;
      begin
        NBV:=1;
        For N1V:=1 To 45 do
        begin
          Edit1.Text:=IntToStr(N1V);
          For N2V:=N1V+1 To 45 do
          begin
            Edit2.Text:=IntToStr(N2V);
            For N3V:=N2V+1 To 46 do
            begin
              Edit3.Text:=IntToStr(N3V);
              For N4V:=N3V+1 To 47 do
              begin
                Edit4.Text:=IntToStr(N4V);
                For N5V:=N4V+1 To 48 do
                begin
                  Edit5.Text:=IntToStr(N5V);
                  Application.ProcessMessages;  // Tous les 49 combinaisons, les TEdit
                  FOR N6V:=N5V+1 TO 49 do       //sont mis à jour et on peur canceller.
                  begin
                    if arret=True then exit;
                    Edit6.Text:=IntToStr(N6V);
                    Edit7.Text:=IntToStr(NBV);
                    AssignFile(tempF,Repertoire+'Loto.txt');
                    if FileExists(Repertoire+'Loto.txt') then reset(tempF)
                    else rewrite(tempF);
                    seek(tempF,Filesize(tempF));
                    image.Nombre:=Edit7.Text;
                    image.N1:=Edit1.Text;
                    image.N2:=Edit2.Text ;
                    image.N3:=Edit3.Text;
                    image.N4:=Edit4.Text;
                    image.N5:=Edit5.Text;
                    image.N6:=Edit6.Text;
                    write(tempF,image);
                    CloseFile(tempF);
                    Edit6.Text:=IntToStr(N6V);
                    Edit7.Text:=InttoStr(NBV);
                    inc(NBV);
                  end;
                end;
              end;
            end;
          end;
        end;
      end;
    Logiciel pas vraiment utile en soit mais c'est juste pour le plaisir et essayer d'apprendre de nouvelles choses. Le code ci-dessus semble bien recréer toutes les possibilités ( Le traitement est long, il devrait y avoir approx 12 millions de possibilités, à voir) Juste lors de l'affichage que je butte.
    Merci.

  4. #4
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    bonjour,

    première remarque, le AssignFile devrait être en tout début de code et non dans la boucle, ensuite il suffit de faire un write et le close tout à la fin en dehors des boucles.

    ensuite pour l'affichage il faut passer par une liste virtuelle. Par exemple TListBox en style lbVirtualOwnerDraw. Il suffit alors de définir la valeur de "ListBox.Count" pour "remplir" la liste; OnDrawItem est appelé pour chaque ligne à afficher. Il suffit alors de récupérer l'enregistrement numéro "Index" pour l'afficher dans le Canvas de la listbox.

    NB: il existe aussi un VirtualTreeView mais pas en standard sous Delphi.

    Pour éviter l'accès fichier il serait plus efficace de passer par un filemapping afin d'accéder directement aux données du fichier en laissant l'OS le charger en mémoire.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    Membre régulier
    Inscrit en
    Mai 2003
    Messages
    146
    Détails du profil
    Informations forums :
    Inscription : Mai 2003
    Messages : 146
    Points : 116
    Points
    116
    Par défaut
    Un gros merci à vous deux; je débroussaille tout cela. Je marque résolu. Bonne année à tous.

  6. #6
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 420
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 420
    Points : 1 325
    Points
    1 325
    Par défaut
    Bonjour à toutes et à tous et meilleurs voeux pour 2013.

    @ Dr.Who, Quand on sait que la règle pour le Lotto est de choisir 6 numéros de 1 à 45 et pour l'Euro Millions la règle est de choisir 5 numéros de 1 à 50 et 2 étoiles de 1 à 11.

    Ta suggestion qui affiche 6 chiffres + 1, peut elle être ajustée en conséquence ?

    Merci d'avance,

    @+,

    Cincap

  7. #7
    Membre éprouvé
    Avatar de Dr.Who
    Inscrit en
    Septembre 2009
    Messages
    980
    Détails du profil
    Informations personnelles :
    Âge : 45

    Informations forums :
    Inscription : Septembre 2009
    Messages : 980
    Points : 1 294
    Points
    1 294
    Par défaut
    @cincap :

    oui il suffit de modifier en conséquence :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    unit Loto;
     
    interface
     
    uses
      Windows, SysUtils, Classes;
     
    const
      cLoto        = $01;
      cEuroMillion = $02;
     
    type
      PLoto = ^TLoto;
      TLoto = packed record
        LotoType : byte;
        case byte of
          0:(Numbers : array[0..6] of byte);
          1:(N1,N2,N3,N4,N5,N6,N7: byte);
      end;
     
    const
      SizeOfLoto = SizeOf(TLoto);
      LotoDefault: TLoto = (LotoType:cLoto; Numbers:(0,0,0,0,0,0,0));
     
    type
      TLotoFile = class
      private
        fLotos : array of TLoto;
        fStream: TFileStream;
        function getLoto(index: integer): TLoto;
        procedure setLoto(index: integer; const Value: TLoto);
      public
        property loto[index: integer]: TLoto   read getLoto   write setLoto; default;
     
        function count: integer;
     
        function Push(aLoto: TLoto): integer; overload;
        function Pop: TLoto;
     
        function IndexOf(aLoto: TLoto): integer;
     
        procedure Exchange(IndexA, IndexB: integer);
     
        constructor Create(aFileName: string); reintroduce;
        destructor Destroy; override;
      end;
     
    function LotoToString(aLoto : TLoto): string;
    function LotoCompare(A, B: TLoto): boolean;
    function LotoCreate(aType,aN1,aN2,aN3,aN4,aN5,aN6,aN7: byte): TLoto;
    function LotoValid(aLoto: TLoto): boolean;
     
    implementation
     
    function LotoValid(aLoto: TLoto): boolean;
    begin
      result := false;
      case aLoto.LotoType of
        cLoto        : result := 
          (aLoto.N1>0 and aLoto.N1<=45) and
          (aLoto.N2>0 and aLoto.N2<=45) and
          (aLoto.N3>0 and aLoto.N3<=45) and
          (aLoto.N4>0 and aLoto.N4<=45) and
          (aLoto.N5>0 and aLoto.N5<=45) and
          (aLoto.N6>0 and aLoto.N6<=45);
     
        cEuroMillion :
          (aLoto.N1>0 and aLoto.N1<=50) and
          (aLoto.N2>0 and aLoto.N2<=50) and
          (aLoto.N3>0 and aLoto.N3<=50) and
          (aLoto.N4>0 and aLoto.N4<=50) and
          (aLoto.N5>0 and aLoto.N5<=50) and
          (aLoto.N6>0 and aLoto.N6<=11) and
          (aLoto.N7>0 and aLoto.N7<=11);
     
      end;
    end;
     
    function LotoCreate(aType,aN1,aN2,aN3,aN4,aN5,aN6,aN7: byte): TLoto;
    begin
      result.LotoType = aType;
      result.N1 := aN1;
      result.N2 := aN2;
      result.N3 := aN3;
      result.N4 := aN4;
      result.N5 := aN5;
      result.N6 := aN6;
      result.N7 := aN7;
    end;
     
    function LotoCompare(A, B: TLoto): boolean;
    begin
      result := compareMem(@A, @B, SizeOfLoto);
    end;
     
    function LotoToString(aLoto : TLoto): string;
    begin 
      result := '';
      case aLoto.LotoType of
        cLoto : result := format('%d, %d, %d, %d, %d et %d',
                       [ aLoto.Numbers[0],
                         aLoto.Numbers[1],
                         aLoto.Numbers[2],
                         aLoto.Numbers[3],
                         aLoto.Numbers[4],
                         aLoto.Numbers[5],
                        ]);
        cEuroMillion : result := format('%d, %d, %d, %d, %d et %d, %d',
                       [ aLoto.Numbers[0],
                         aLoto.Numbers[1],
                         aLoto.Numbers[2],
                         aLoto.Numbers[3],
                         aLoto.Numbers[4],
                         aLoto.Numbers[5],
                         aLoto.Numbers[6],
                        ]);
      end;
    end;
     
    { TLotoFile }
     
    function TLotoFile.count: integer;
    begin
      result := fStream.Size div SizeOfLoto;
    end;
     
    constructor TLotoFile.Create(aFileName: string);
    begin
      inherited Create;
      if FileExists(aFileName) then
        fStream := TFileStream.Create(aFileName, fmOpenReadWrite)
      else
        fStream := TFileStream.Create(aFileName, fmCreate);
    end;
     
    destructor TLotoFile.Destroy;
    begin
      fStream.free;
      inherited;
    end;
     
    procedure TLotoFile.Exchange(IndexA, IndexB: integer);
    var A,B: TLoto;
    begin
      A := getLoto(IndexA);
      B := getLoto(IndexB);
      setLoto(IndexA, B);
      setLoto(IndexB, A);
    end;
     
    function TLotoFile.getLoto(index: integer): TLoto;
    begin
      if (Index >= 0) and (Index < Count) then
      begin
        fStream.Seek(Index * SizeOfLoto, soFromBeginning);
        fStream.Read(result, SizeOfLoto);
      end
      else
        assert(false, format('%d is out of Indexs [0..%d]',[Index, Count-1]));
    end;
     
    function TLotoFile.IndexOf(aLoto: TLoto): integer;
    var X: integer;
    begin
      result := -1;
      for X := 0 to Count - 1 do
        if LotoCompare(getLoto(X), aLoto) then
        begin
          result := X;
          break;
        end;
    end;
     
    function TLotoFile.Pop: TLoto;
    begin
      fStream.Seek(fStream.Size-SizeOfLoto, soFromBeginning);
      fStream.Size := fStream.Size - SizeOfLoto;
    end;
     
    function TLotoFile.Push(aLoto: TLoto): integer;
    begin
      result := Count;
      fStream.Seek(0, soFromEnd);
      fStream.Write(aLoto, SizeOfLoto);
    end;
     
    procedure TLotoFile.setLoto(index: integer; const Value: TLoto);
    begin
      if (Index >= 0) and (Index < Count) then
      begin
        fStream.Seek(Index * SizeOfLoto, soFromBeginning);
        fStream.Write(Value, SizeOfLoto);
      end
      else
        assert(false,format('%d is out of Indexs [0..%d]',[Index, Count-1]));
    end;
     
     
    end.
    [ Sources et programmes de Dr.Who | FAQ Delphi | FAQ Pascal | Règlement | Contactez l'équipe ]
    Ma messagerie n'est pas la succursale du forum... merci!

  8. #8
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 420
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 420
    Points : 1 325
    Points
    1 325
    Par défaut
    Bonjour à toutes et à tous,

    @ Dr.Who, merci pour la rapidité de ta réponse, après avoir créer la new unité "Loto", à la compilation j(obtiens ces erreurs :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
    [Erreur] Loto.pas(60): Types incompatibles
    [Erreur] Loto.pas(61): Types incompatibles
    [Erreur] Loto.pas(62): Types incompatibles
    [Erreur] Loto.pas(63): Types incompatibles
    [Erreur] Loto.pas(64): Types incompatibles
    [Erreur] Loto.pas(65): Types incompatibles
    [Erreur] Loto.pas(68): Types incompatibles
    [Erreur] Loto.pas(69): Types incompatibles
    [Erreur] Loto.pas(70): Types incompatibles
    [Erreur] Loto.pas(71): Types incompatibles
    [Erreur] Loto.pas(72): Types incompatibles
    [Erreur] Loto.pas(73): Types incompatibles
    [Erreur] Loto.pas(74): Types incompatibles
    [Erreur] Loto.pas(81): ':=' attendu(e) mais '=' trouvé(e)
    [Erreur] Loto.pas(107): Expression attendu(e) mais ']' trouvé(e)
    [Erreur] Loto.pas(116): Expression attendu(e) mais ']' trouvé(e)
    [Conseil] Loto.pas(28): Le symbole privé 'fLotos' est déclaré mais jamais utilisé
    [Erreur fatale] LotoMain.pas(7): Impossible de compiler l'unité utilisée 'Loto.pas'
    Pour les erreurs "107" et "116", je pense que c'est au niveau de la virgule !

    Je suis sous D6 et Seven 64bits.

    @+,

    Cincap

  9. #9
    Modérateur
    Avatar de tourlourou
    Homme Profil pro
    Biologiste ; Progr(amateur)
    Inscrit en
    Mars 2005
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Biologiste ; Progr(amateur)

    Informations forums :
    Inscription : Mars 2005
    Messages : 3 844
    Points : 11 274
    Points
    11 274
    Billets dans le blog
    6
    Par défaut
    Pour le 1), il doit suffire d'ajouter les parenthèses autour de chaque test < et >
    Delphi 5 Pro - Delphi 10.4 Rio Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
    . Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !

  10. #10
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 420
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 420
    Points : 1 325
    Points
    1 325
    Par défaut
    @ tourlourou, merci de ta réponse, après correction j'obtiens plus qu'une seule erreur au niveau de la ligne 74 :


    [Erreur] Loto.pas(74): Instruction attendue, mais expression de type 'Boolean' trouvée
    [Conseil] Loto.pas(28): Le symbole privé 'fLotos' est déclaré mais jamais utilisé
    [Erreur fatale] LotoMain.pas(7): Impossible de compiler l'unité utilisée 'Loto.pas'
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    implementation
    
    function LotoValid(aLoto: TLoto): boolean;
    begin
      result := false;
      case aLoto.LotoType of
        cLoto       :  result :=
          (aLoto.N1>0) and (aLoto.N1<=45) and
          (aLoto.N2>0) and (aLoto.N2<=45) and
          (aLoto.N3>0) and (aLoto.N3<=45) and
          (aLoto.N4>0) and (aLoto.N4<=45) and
          (aLoto.N5>0) and (aLoto.N5<=45) and
          (aLoto.N6>0) and (aLoto.N6<=45);
    
        cEuroMillion :
          (aLoto.N1>0) and (aLoto.N1<=50) and
          (aLoto.N2>0) and (aLoto.N2<=50) and
          (aLoto.N3>0) and (aLoto.N3<=50) and
          (aLoto.N4>0) and (aLoto.N4<=50) and
          (aLoto.N5>0) and (aLoto.N5<=50) and
          (aLoto.N6>0) and (aLoto.N6<=11) and
          (aLoto.N7>0) and (aLoto.N7<=11) ; //Ici
    end;
    end;
    J'ai aussi modifié ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    function LotoToString(aLoto : TLoto): string;
    begin
      result := '';
      case aLoto.LotoType of
        cLoto : result := format('%d, %d, %d, %d, %d et %d',
                       [ aLoto.Numbers[0],
                         aLoto.Numbers[1],
                         aLoto.Numbers[2],
                         aLoto.Numbers[3],
                         aLoto.Numbers[4],
                         aLoto.Numbers[5]]);//Enlever la virgule
        cEuroMillion : result := format('%d, %d, %d, %d, %d et %d, %d',
                       [ aLoto.Numbers[0],
                         aLoto.Numbers[1],
                         aLoto.Numbers[2],
                         aLoto.Numbers[3],
                         aLoto.Numbers[4],
                         aLoto.Numbers[5],
                         aLoto.Numbers[6]]);//Enlever la virgule
      end;
    end;
    @+,

    Cincap

  11. #11
    Modérateur
    Avatar de tourlourou
    Homme Profil pro
    Biologiste ; Progr(amateur)
    Inscrit en
    Mars 2005
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Biologiste ; Progr(amateur)

    Informations forums :
    Inscription : Mars 2005
    Messages : 3 844
    Points : 11 274
    Points
    11 274
    Billets dans le blog
    6
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    cEuroMillion :      Result :=    / ici !
          (aLoto.N1>0) and (aLoto.N1<=50) and
    Delphi 5 Pro - Delphi 10.4 Rio Community Edition - CodeTyphon 6.90 sous Windows 10 ; CT 6.40 sous Ubuntu 18.04 (VM)
    . Ignorer la FAQ Delphi et les Cours et Tutoriels Delphi nuit gravement à notre code !

  12. #12
    Membre expérimenté
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    2 420
    Détails du profil
    Informations personnelles :
    Âge : 71
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2006
    Messages : 2 420
    Points : 1 325
    Points
    1 325
    Par défaut
    @ tourlourou, mais bien entendu, je n'ai pas controlé cette ligne, merci.

    Il fallait aussi dans l'utilisation de "LotoCreate" rajouter ceci :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    for X := 0 to 999 do
      begin
        // create a random sequence
        L := LotoCreate(randByte, randByte, randByte, randByte, randByte, randByte, randByte, randByte);
     
        // while in file
        while LotoFile.IndexOf(L) <> -1 do
          // create new random sequence
          L := LotoCreate(randByte, randByte, randByte, randByte, randByte, randByte, randByte, randByte);
     
        // is ok, push the sequence !
        LotoFile.Push(L);
      end;
    Mais le résultat est totalement différent de la 1ère mouture.

    1er résultat au 13, puis au 24 et 29 sur les 100 !

    @+,

    Cincap

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Excel] Comment afficher les données d'un fichier Excel (PHP)
    Par pierrot10 dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 11/05/2006, 16h01
  2. [VB.NET]Comment afficher 1 progressbar lors d'une lecture fichier ?
    Par evlp2004@hotmail.com dans le forum Windows Forms
    Réponses: 2
    Dernier message: 04/05/2006, 10h00
  3. [FTP ouverture fichier] comment afficher le fichier FTP
    Par chouchou93 dans le forum Struts 1
    Réponses: 17
    Dernier message: 07/04/2006, 17h56
  4. [VB.NET][excel][word] comment afficher des fichiers?
    Par leptityugi dans le forum Windows Forms
    Réponses: 8
    Dernier message: 09/11/2005, 10h15
  5. Comment afficher un fichier HTML
    Par Xavier dans le forum C++Builder
    Réponses: 8
    Dernier message: 30/03/2004, 08h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo