Précédent   Forum du club des développeurs et IT Pro > Environnements de développement > Delphi > Débutant
Débutant Pour bien débuter avec Delphi
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 03/01/2013, 22h48   #1
Duan
Membre régulier
 
Inscription : mai 2003
Messages : 141
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 141
Points : 77
Points : 77
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.
Citation:
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.
Duan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2013, 01h18   #2
Dr.Who
Membre Expert
 
Avatar de Dr.Who
 
Inscription : septembre 2009
Messages : 980
Détails du profil
Informations personnelles :
Âge : 34

Informations forums :
Inscription : septembre 2009
Messages : 980
Points : 1 175
Points : 1 175
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 :
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 :
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!
Dr.Who est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2013, 03h03   #3
Duan
Membre régulier
 
Inscription : mai 2003
Messages : 141
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 141
Points : 77
Points : 77
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 :
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.
Duan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/01/2013, 06h01   #4
Paul TOTH
Expert Confirmé Sénior
 
Avatar de Paul TOTH
 
Homme Paul TOTH
Freelance
Inscription : novembre 2002
Messages : 4 427
Détails du profil
Informations personnelles :
Nom : Homme Paul TOTH
Âge : 43
Localisation : Réunion

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

Informations forums :
Inscription : novembre 2002
Messages : 4 427
Points : 10 827
Points : 10 827
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
Produits : UPnP, RemoteOffice, FlashPascal
Embarcadero : Ile de la Réunion, Dephi, C++Builder, RADPHP...TVA à 8,5%
Paul TOTH est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2013, 03h05   #5
Duan
Membre régulier
 
Inscription : mai 2003
Messages : 141
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 141
Points : 77
Points : 77
Un gros merci à vous deux; je débroussaille tout cela. Je marque résolu. Bonne année à tous.
Duan est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2013, 10h20   #6
cincap
Membre émérite
 
Inscription : janvier 2006
Messages : 1 396
Détails du profil
Informations personnelles :
Âge : 60

Informations forums :
Inscription : janvier 2006
Messages : 1 396
Points : 891
Points : 891
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
cincap est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 03h08   #7
Dr.Who
Membre Expert
 
Avatar de Dr.Who
 
Inscription : septembre 2009
Messages : 980
Détails du profil
Informations personnelles :
Âge : 34

Informations forums :
Inscription : septembre 2009
Messages : 980
Points : 1 175
Points : 1 175
@cincap :

oui il suffit de modifier en conséquence :
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
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!
Dr.Who est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 09h39   #8
cincap
Membre émérite
 
Inscription : janvier 2006
Messages : 1 396
Détails du profil
Informations personnelles :
Âge : 60

Informations forums :
Inscription : janvier 2006
Messages : 1 396
Points : 891
Points : 891
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 :
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
cincap est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 10h13   #9
tourlourou
Modérateur
 
Homme Yves Lemaire
Biologiste ; Progr(amateur)
Inscription : mars 2005
Messages : 1 684
Détails du profil
Informations personnelles :
Nom : Homme Yves Lemaire
Âge : 50
Localisation : France, Yvelines (Île de France)

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

Informations forums :
Inscription : mars 2005
Messages : 1 684
Points : 3 097
Points : 3 097
Pour le 1), il doit suffire d'ajouter les parenthèses autour de chaque test < et >
__________________
Delphi 5 Pro et Code Typhon 2.80 sous Win 7 64 bits - Code Typhon 2.70 / Ubuntu 12.04 64 bits
tourlourou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 10h57   #10
cincap
Membre émérite
 
Inscription : janvier 2006
Messages : 1 396
Détails du profil
Informations personnelles :
Âge : 60

Informations forums :
Inscription : janvier 2006
Messages : 1 396
Points : 891
Points : 891
@ tourlourou, merci de ta réponse, après correction j'obtiens plus qu'une seule erreur au niveau de la ligne 74 :

Citation:

[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 :
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 :
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
cincap est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 11h26   #11
tourlourou
Modérateur
 
Homme Yves Lemaire
Biologiste ; Progr(amateur)
Inscription : mars 2005
Messages : 1 684
Détails du profil
Informations personnelles :
Nom : Homme Yves Lemaire
Âge : 50
Localisation : France, Yvelines (Île de France)

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

Informations forums :
Inscription : mars 2005
Messages : 1 684
Points : 3 097
Points : 3 097
Code :
1
2
cEuroMillion :      Result :=    / ici !
      (aLoto.N1>0) and (aLoto.N1<=50) and
__________________
Delphi 5 Pro et Code Typhon 2.80 sous Win 7 64 bits - Code Typhon 2.70 / Ubuntu 12.04 64 bits
tourlourou est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2013, 12h08   #12
cincap
Membre émérite
 
Inscription : janvier 2006
Messages : 1 396
Détails du profil
Informations personnelles :
Âge : 60

Informations forums :
Inscription : janvier 2006
Messages : 1 396
Points : 891
Points : 891
@ tourlourou, mais bien entendu, je n'ai pas controlé cette ligne, merci.

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

Code :
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
cincap est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Cette discussion est résolue.
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 09h08.


 
 
 
 
Partenaires

Hébergement Web