Je ne peux pas envoyer tout mon code par message, ni en pièce jointe car il est beaucoup trop volumineux. comment puis-je faire à part vous l'envoyer sur votre adresse personnelle ?
Version imprimable
Je ne peux pas envoyer tout mon code par message, ni en pièce jointe car il est beaucoup trop volumineux. comment puis-je faire à part vous l'envoyer sur votre adresse personnelle ?
Dès que j'ai enregistré les modifications sur mon code sous Kate, je passe sous putty, et je tape
puisCode:chmod a+x fichier3.pl
pour exécuter le fichier "fichier3.pl".Code:./perltite2 -f
Une nouvelle fenêtre s'ouvre avec l'interface graphique souhaitée.
Puis, lorsque je clique sur n'importe quelle commande, rien ne se passe, et dans la fenêtre ouverte par putty s'affiche l'habituel message d'erreur.
Ton code contient vraiment trop d'erreurs.
1- Mets les procédures après le mainloop en fin de script.
2- dans tes for (..., met un my pour déclarer ta variable $i ou $j, etc
ex :
Il y avait des variables non déclarées, etc etc.Code:
1
2
3 for ( my $i = 0; $i < scalar(@ligneFichierDon); $i++ ) { chomp( $ligneFichierDon[$i] ); }
Tu avais aussi une ligne de ce type qui se balade
Code:sed $ligneFichierDon[0];
== s'utilise pour les nombres et non chaines de caractères.Code:if ( $Don[3] == ' ' ) {
Sincèrement, prend le temps de faire les choses proprement quand tu codes, car ça deviendra de plus en plus compliqué de débugguer un script de plusieurs milliers de lignes. Idem pour pour les indentations (Utilise le script d'exemple du module perltidy pour indenter).
Bon voilà ton script, j'ai un peu corrigé, mais il y a encore des bugs, essaye de tester et faire le ménage
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 #!usr/bin/perl use warnings; use strict; use Tk; use Tk::Balloon; use Tk::NoteBook; use Tk::Dialog; use utf8; #Création du menu fichier, avec des sous-menus #tableau contenant toutes les fonctions à lancer my %fonction = ( "Nouveau fichier .INF" => \&creerAfficherInf, "Nouveau fichier .DON classique" => \&creerafficherDonClassique, "Nouveau fichier .DON canal temporel & spectral" => \&creerafficherDonavcan, "Nouveau fichier .LOI" => \&creerAfficherLoi, "Nouveau fichier .CAN" => \&creerAfficherCan, "Nouveau fichier .MASKCLA" => \&creerAfficherMaskcla, "Nouveau fichier .CANCLA" => \&creerAfficherCancla, "Nouveau fichier .CHGT" => \&creerAfficherChgt, "Nouveau fichier .CHGCLASS" => \&creerAfficherChgclass, "fichier .INF" => \&ouvrirInf, "fichier .DON" => \&ouvrirDon, "fichier .LOI" => \&ouvrirLoi, "fichier .CAN" => \&ouvrirCan, "fichier .MASKCLA" => \&ouvrirMaskcla, "fichier .CANCLA" => \&ouvrirCancla, "fichier .CHGT" => \&ouvrirChgt, "fichier .CHGCLASS" => \&ouvrirChgclass, ); #tableau contenant les noms des sous menus my @fichier = ( 'Nouveau...', 'Ouvrir' ); #tableau contenant le nom des commandes dans le sous-menu Nouveau... my @Nouveau = ( "Nouveau fichier .INF", "Nouveau fichier .DON classique", "Nouveau fichier .DON canal temporel \& spectral", "Nouveau fichier .LOI", "Nouveau fichier .CAN", "Nouveau fichier .MASKCLA", "Nouveau fichier .CANCLA", "Nouveau fichier .CHGT", "Nouveau fichier .CHGCLASS", ); #tableau contenant le nom des commandes dans le sous-menu Ouvrir my @Ouvrir = ( "fichier .INF", "fichier .DON", "fichier .LOI", "fichier .CAN", "fichier .MASKCLA", "fichier .CANCLA", "fichier .CHGT", "fichier .CHGCLASS", ); #On précise quelles commandes correspondent à quel sous-menu my %sous_menu = ( 'Nouveau...' => \@Nouveau, 'Ouvrir' => \@Ouvrir, ); my %sous_menuref; my $fenetre = new MainWindow(); $fenetre->maxsize( 640, 600 ); $fenetre->minsize( 640, 600 ); $fenetre->title("Cesbio TITE"); # création d'un menu bar (menu en entete du widget principal) my $Menu = $fenetre->Menu( -type => "menubar" ); $fenetre->configure( -menu => $Menu, ); my $SousMenuFichier = $Menu->cascade( -label => "Fichier", -tearoff => 0, ); my $SousMenuCreation = $Menu->cascade( -label => "Creation", -tearoff => 0, ); $SousMenuCreation->command( -label => 'auto_max_vrai07', -command => \&lancerAuto_max_vrai, -compound => "left", ); $SousMenuCreation->command( -label => 'auto_comp_matcnf04', -command => \&lancerAuto_comp, -compound => "left" ); # Sous menu Fichier foreach my $Label ( keys %sous_menu ) { # sous menu fichier 2 my $SousMenuFichier2 = $SousMenuFichier->cascade( -label => $Label, -tearoff => 0, ); foreach my $fichier ( @{ $sous_menu{$Label} } ) { $SousMenuFichier2->command( -label => $fichier, -command => $fonction{$fichier}, -compound => "left", ); } } $fenetre->Label( -text => "Gestion de fichier TITE" ) ->pack( -side => 'top', -anchor => 'n' ); my $zoneRecap = $fenetre->Scrolled( "Text", -width => 70, -height => 70, -background => "white" )->pack(); MainLoop();
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524 sub ouvrirInf { my @types = ( [ "Inf Files", '.inf' ], [ "All Files", '*' ], ); my $nomFichierInf = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types, ); #on regarde si le fichier est un .inf if ( $nomFichierInf =~ /(\.inf)$/ ) { open( FICH, "$nomFichierInf" ) || die("Impossible d'ouvrir $nomFichierInf"); my @donneInf = <FICH>; close(FICH); creerAfficherInf( "$donneInf[1]", "$donneInf[0]", "$donneInf[2]", "$donneInf[3]", "$donneInf[4]", "$nomFichierInf" ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Inf', -text => 'Ceci n\'est pas un fichier .inf', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherInf { my ( $ligne, $colonne, $nbCannaux, $dataFormat, $dataType, $nomdufichierInf ) = @_; chomp($ligne); chomp($colonne); chomp($nbCannaux); chomp($dataFormat); chomp($dataType); my $fenetreVisInf = $fenetre->Toplevel(); $fenetreVisInf->title("Fichier Inf"); $fenetreVisInf->raise(); if ( -f $nomdufichierInf ) { my $titre = $fenetreVisInf->Frame(); $titre->Label( -text => "$nomdufichierInf" )->pack(); $titre->pack( -fill => 'x' ); } my $visLigne = $fenetreVisInf->Frame(); $visLigne->Label( -text => "Lignes" )->pack( -side => 'left' ); $visLigne->Button( -text => "?", -relief => 'flat', -borderwidth => 1, -command => sub { my $fentreInfo = $fenetreVisInf->Toplevel(); $fentreInfo->title("Lignes"); $fentreInfo->raise(); $fentreInfo->Label( -text => "Représente \nle nombre de lignes\nde l'image" ) ->pack(); $fentreInfo->Button( -text => "Fermer", -command => sub { $fentreInfo->destroy(); } )->pack(); } )->pack( -side => "right" ); $visLigne->Entry( -background => 'white', -textvariable => \$ligne )->pack( -side => 'right' ); $visLigne->pack( -fill => 'x' ); my $visColonne = $fenetreVisInf->Frame(); $visColonne->Label( -text => "Colonnes" )->pack( -side => 'left' ); $visColonne->Button( -text => "?", -relief => 'flat', -borderwidth => 1, -command => sub { my $fentreInfo = $fenetreVisInf->Toplevel(); $fentreInfo->title("Colonnes"); $fentreInfo->raise(); $fentreInfo->Label( -text => "Représente \nle nombre de colonnes\nde l'image" ) ->pack(); $fentreInfo->Button( -text => "Fermer", -command => sub { $fentreInfo->destroy(); } )->pack(); } )->pack( -side => "right" ); $visColonne->Entry( -background => 'white', -textvariable => \$colonne )->pack( -side => 'right' ); $visColonne->pack( -fill => 'x' ); my $visNbCannaux = $fenetreVisInf->Frame(); $visNbCannaux->Label( -text => "Nombre de Cannaux" )->pack( -side => 'left' ); $visNbCannaux->Button( -text => "?", -relief => 'flat', -borderwidth => 1, -command => sub { my $fentreInfo = $fenetreVisInf->Toplevel(); $fentreInfo->title("Nombres de cannaux"); $fentreInfo->raise(); $fentreInfo->Label( -text => "Représente \nle nombre de plans\nde l'image" ) ->pack(); $fentreInfo->Button( -text => "Fermer", -command => sub { $fentreInfo->destroy(); } )->pack(); } )->pack( -side => "right" ); $visNbCannaux->Entry( -background => 'white', -textvariable => \$nbCannaux )->pack( -side => 'right' ); $visNbCannaux->pack( -fill => 'x' ); my $visDataFormat = $fenetreVisInf->Frame(); $visDataFormat->Label( -text => "Data Format" )->pack( -side => 'left' ); $visDataFormat->Button( -text => "?", -relief => 'flat', -borderwidth => 1, -command => sub { my $fentreInfo = $fenetreVisInf->Toplevel(); $fentreInfo->title("DataFormat"); $fentreInfo->raise(); $fentreInfo->Label( -text => "Indique le format\nde stockage des pixels :\n\n 1 flottant(float)\n 2 octet (unsigned char, 8 bits)\n 3 deux octets, poids fort - poids faible (16 bits, big endian)\n 4 deux octets, poids faible - poids fort (16 bits, little endian)", -justify => 'left' )->pack(); $fentreInfo->Button( -text => "Fermer", -command => sub { $fentreInfo->destroy(); } )->pack(); } )->pack( -side => "right" ); $visDataFormat->Entry( -background => 'white', -textvariable => \$dataFormat )->pack( -side => 'right' ); $visDataFormat->pack( -fill => 'x' ); my $visDataType = $fenetreVisInf->Frame(); $visDataType->Label( -text => "Data Type" )->pack( -side => 'left' ); $visDataType->Button( -text => "?", -relief => 'flat', -borderwidth => 1, -command => sub { my $fentreInfo = $fenetreVisInf->Toplevel(); $fentreInfo->title("DataType"); $fentreInfo->raise(); $fentreInfo->Label( -text => "Le DataType signifie : \n\n 0 image non SAR (optique, gradient, contours, label etc.)\n\n 1 image SAR en intensité\n\n 2 image SAR en amplitude réelle\n\n 3 image SAR en amplitude complexe, 2 fichiers \npar canal (partie réelle et imaginaire séparées)\n\n 4 image SAR polarimétrique, vecteur réel\nde la matrice de covariance expérimentale\n(un fichier par élément du vecteur)", -justify => 'left' )->pack(); $fentreInfo->Button( -text => "Fermer", -command => sub { $fentreInfo->destroy(); } )->pack(); } )->pack( -side => "right" ); $visDataType->Entry( -background => 'white', -textvariable => \$dataType )->pack( -side => 'right' ); $visDataType->pack( -fill => 'x' ); $fenetreVisInf->Button( -text => "Enregistrer", -borderwidth => 1, -command => sub { if ( -f $nomdufichierInf ) { enregistrerInf( $nomdufichierInf, $ligne, $colonne, $nbCannaux, $dataFormat, $dataType ); } else { $nomdufichierInf = $fenetreVisInf->getSaveFile( -initialdir => '.' ); enregistrerInf( $nomdufichierInf, $ligne, $colonne, $nbCannaux, $dataFormat, $dataType ); } $fenetreVisInf->destroy(); } )->pack(); } sub enregistrerInf { my ( $nomdufichierInf, $ligne, $colonne, $nbCannaux, $dataFormat, $dataType ) = @_; print " enregistrerInf $nomdufichierInf\n"; if ( $nomdufichierInf =~ /(\.inf)$/ ) { open( FICH, ">$nomdufichierInf" ) || die("Impossible de créer $nomdufichierInf"); print FICH "$colonne\n$ligne\n$nbCannaux\n$dataFormat\n$dataType\n"; close(FICH); } else { $nomdufichierInf = "$nomdufichierInf.inf"; open( FICH, ">$nomdufichierInf" ) || die("Impossible de créer $nomdufichierInf"); print FICH "$colonne\n$ligne\n$nbCannaux\n$dataFormat\n$dataType\n"; close(FICH); } $zoneRecap->insert( 'end', "Enregistrement de $nomdufichierInf" ); } sub ouvrirDon { my @types = ( [ "Don files", '.don' ], [ "All files", "*" ] ); my $nomFichierDon = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); if ( $nomFichierDon =~ /(\.don)$/ ) { open( FICH, "$nomFichierDon" ) || die("Impossible d'ouvrir $nomFichierDon"); my @ligneFichierDon = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@ligneFichierDon); $i++ ) { chomp( $ligneFichierDon[$i] ); } my @ligneColonne = split( / /, $ligneFichierDon[0] ); my (@listeFichierDon); #sed $ligneFichierDon[0]; my @Don = split( / /, $listeFichierDon[0] ); if ( $Don[3] == ' ' ) { creerafficherDonClassique( $ligneColonne[0], $ligneColonne[1], $ligneColonne[2], $ligneColonne[3], $ligneColonne[4], $ligneColonne[5], \@listeFichierDon, $nomFichierDon ); } else { creerafficherDonavcan( $ligneColonne[0], $ligneColonne[1], $ligneColonne[2], $ligneColonne[3], $ligneColonne[4], $ligneColonne[5], \@listeFichierDon, $nomFichierDon ); } } else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Don', -text => 'Ceci n\'est pas un fichier .don', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Don', -text => 'Le fichier .don doit comporter un seul espace entre type et date.', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } sub creerafficherDonClassique { my ( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, $listeFichier, $nomFichierDon ) = @_; my ( @nomDon, @typDon, @dateDon, @check ); my $fenetreDon = $fenetre->Toplevel(); $fenetreDon->title("Fichier Don"); $fenetreDon->raise; $fenetreDon->minsize( 400, 200 ); #pour savoir si on active le bouton enregistrer my $enregistrer; if ( -f $nomFichierDon ) { $enregistrer = "normal"; } else { $enregistrer = "disabled"; } my $zoneMenuDon = $fenetreDon->Frame( -relief => 'groove', -borderwidth => 1 ); $zoneMenuDon->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer', -command => sub { my (@listeFichDon); my $j = 0; for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { if ( $check[$i] == 1 ) { $listeFichDon[$j] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i] ); $j++; } } enregistrerDon( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); }, -state => "$enregistrer" ], [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierDon = $fenetreDon->getSaveFile( -initialdir => '.' ); my (@listeFichDon); my $j = 0; for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { if ( $check[$i] == 1 ) { $listeFichDon[$j] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i] ); $j++; } } enregistrerDon( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreDon->destroy() } ] ] )->pack( -side => 'left' ); $zoneMenuDon->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Ajouter des Images', -command => sub { my (@listeFichDon); for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { $listeFichDon[$i] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i] ); } ajouterImageDon( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); } ], [ 'command' => 'Supprimer les Images désélectionnées', -command => sub { my (@listeFichDon); my $j = 0; for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { if ( $check[$i] == 1 ) { $listeFichDon[$j] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i] ); $j++; } } print "yahoo @nomDon\n"; creerafficherDonClassique( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); } ], '-', [ 'command' => 'Type identique', -command => sub { my $dialogbox = $fenetreDon->DialogBox( -title => 'Nouveau projet', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Saisir le type : ' ) ->pack( -side => 'top' ); my $type; $dialogbox->add( 'Entry', -textvariable => \$type )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { for ( my $i = 0; $i < scalar(@typDon); $i++ ) { $typDon[$i] = $type; } } } ], [ 'command' => 'Date identique', -command => sub { my $dialogbox = $fenetreDon->DialogBox( -title => 'Nouveau projet', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Saisir la date : ' ) ->pack( -side => 'top' ); my $type; my $date; $dialogbox->add( 'Entry', -textvariable => \$date )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { for ( my $i = 0; $i < scalar(@dateDon); $i++ ) { $dateDon[$i] = $date; } } } ], '-', [ 'command' => 'Ouvrir Inf', -command => sub { my $nomFichierInf = $fenetreDon->getOpenFile( -initialdir => '.' ); open( FICH, $nomFichierInf ) || die("Impossible d'ouvrir $nomFichierInf"); my @ligneInf = <FICH>; close(FICH); $ligne = $ligneInf[1]; $colonne = $ligneInf[0]; chomp($ligne); chomp($colonne); } ], ] )->pack( -side => 'left' ); $zoneMenuDon->pack( -fill => 'x' ); $fenetreDon->Label( -text => "Pour vous aider d'un fichier .inf cliquez sur Edition->Ouvrir inf" ) ->pack( -anchor => 'ne', -fill => 'x' ); my $visLigne = $fenetreDon->Frame(); $visLigne->Label( -text => "Nombre de Lignes" )->pack( -side => 'left' ); $visLigne->Entry( -textvariable => \$ligne, -background => 'white' )->pack( -side => 'right' ); $visLigne->pack( -fill => 'x' ); my $visColonne = $fenetreDon->Frame(); $visColonne->Label( -text => "Nombre de Colonnes" )->pack( -side => 'left' ); $visColonne->Entry( -textvariable => \$colonne, -background => 'white' )->pack( -side => 'right' ); $visColonne->pack( -fill => 'x' ); my $imageFenetre = $fenetreDon->Frame( -relief => 'sunken', -borderwidth => 1 ); $imageFenetre->Label( -text => "Fenêtre de l'image" )->pack(); my $fenetreLigne = $imageFenetre->Frame(); $fenetreLigne->Label( -text => "Première ligne " )->pack( -side => 'left' ); $fenetreLigne->Entry( -textvariable => \$debutLigne, -background => 'white', -width => 4 )->pack( -side => 'left' ); $fenetreLigne->Entry( -textvariable => \$finLigne, -background => 'white', -width => 4 )->pack( -side => 'right' ); $fenetreLigne->Label( -text => "Dernière ligne" )->pack( -side => 'right' ); $fenetreLigne->pack( -fill => 'x' ); my $fenetreColonne = $imageFenetre->Frame(); $fenetreColonne->Label( -text => "Première colonne" )->pack( -side => 'left' ); $fenetreColonne->Entry( -textvariable => \$debutColonne, -background => 'white', -width => 4 )->pack( -side => 'left' ); $fenetreColonne->Entry( -textvariable => \$finColonne, -background => 'white', -width => 4 )->pack( -side => 'right' ); $fenetreColonne->Label( -text => "Dernière colonne" )->pack( -side => 'right' ); $fenetreColonne->pack( -fill => 'x' ); $imageFenetre->Button( -text => "Toute l'image", -command => sub { $debutLigne = 1; $debutColonne = 1; $finLigne = $ligne; $finColonne = $colonne; }, -borderwidth => 1, )->pack(); $imageFenetre->pack( -fill => 'x', ); $fenetreDon->Label( -text => "Pour ajouter ou supprimer des images allez dans Edition" ) ->pack( -anchor => 'ne', -fill => 'x' ); my $titre = $fenetreDon->Frame(); $titre->Label( -text => "Fichier(s) present(s)", -justify => 'left' ) ->pack( -side => 'left' ); $titre->Label( -text => "Date", -justify => 'left' )->pack( -side => 'right' ); $titre->Label( -text => "Type", -justify => 'left' )->pack( -side => 'right' ); $titre->pack( -fill => 'x' ); for ( my $i = 0; $i < scalar(@$listeFichier); $i++ ) { my @temp = split( / /, $$listeFichier[$i] ); $nomDon[$i] = $temp[0]; $typDon[$i] = $temp[1]; $dateDon[$i] = $temp[2]; $check[$i] = 1; my $fichierDonCont = $fenetreDon->Frame(); $fichierDonCont->Checkbutton( -text => "$nomDon[$i]", -variable => \$check[$i], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $fichierDonCont->Entry( -textvariable => \$dateDon[$i], -width => 3, -background => 'white' )->pack( -side => 'right' ); $fichierDonCont->Entry( -textvariable => \$typDon[$i], -width => 3, -background => 'white' )->pack( -side => 'right' ); $fichierDonCont->pack( -fill => 'x' ); } }
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362 sub creerafficherDonavcan { my ( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, $listeFichier, $nomFichierDon ) = @_; my ( @nomDon, @typDon, @dateDon, @canDon, @check ); my $fenetreDon = $fenetre->Toplevel(); $fenetreDon->title("Fichier Don"); $fenetreDon->raise; $fenetreDon->minsize( 400, 200 ); #pour savoir si on active le bouton enregistrer if ( -f $nomFichierDon ) { $enregistrer = "normal"; } else { $enregistrer = "disabled"; } my $zoneMenuDon = $fenetreDon->Frame( -relief => 'groove', -borderwidth => 1 ); $zoneMenuDon->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer', -command => sub { my (@listeFichDon); my $j = 0; for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { if ( $check[$i] == 1 ) { $listeFichDon[$j] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i], $canDon[$i] ); $j++; } } enregistrerDon( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); }, -state => "$enregistrer" ], [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierDon = $fenetreDon->getSaveFile( -initialdir => '.' ); my (@listeFichDon); my $j = 0; for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { if ( $check[$i] == 1 ) { $listeFichDon[$j] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i], $canDon[$i] ); $j++; } } enregistrerDon( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreDon->destroy() } ] ] )->pack( -side => 'left' ); $zoneMenuDon->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Ajouter des Images', -command => sub { my (@listeFichDon); for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { $listeFichDon[$i] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i], $canDon[$i] ); } ajouterImageDon2( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); } ], [ 'command' => 'Supprimer les Images désélectionnées', -command => sub { my (@listeFichDon); my $j = 0; for ( my $i = 0; $i < scalar(@nomDon); $i++ ) { if ( $check[$i] == 1 ) { $listeFichDon[$j] = join( " ", $nomDon[$i], $typDon[$i], $dateDon[$i], $canDon[$i] ); $j++; } } print "yahoo @nomDon\n"; creerafficherDonavcan( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, \@listeFichDon, $nomFichierDon ); $fenetreDon->destroy(); } ], '-', [ 'command' => 'Type identique', -command => sub { my $dialogbox = $fenetreDon->DialogBox( -title => 'Nouveau projet', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Saisir le type : ' ) ->pack( -side => 'top' ); my $type; $dialogbox->add( 'Entry', -textvariable => \$type )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { for ( my $i = 0; $i < scalar(@typDon); $i++ ) { $typDon[$i] = $type; } } } ], [ 'command' => 'Date identique', -command => sub { my $dialogbox = $fenetreDon->DialogBox( -title => 'Nouveau projet', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Saisir la date : ' ) ->pack( -side => 'top' ); my $type; $dialogbox->add( 'Entry', -textvariable => \$date )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { for ( my $i = 0; $i < scalar(@dateDon); $i++ ) { $dateDon[$i] = $date; } } } ], '-', [ 'command' => 'Ouvrir Inf', -command => sub { my $nomFichierInf = $fenetreDon->getOpenFile( -initialdir => '.' ); open( FICH, $nomFichierInf ) || die("Impossible d'ouvrir $nomFichierInf"); my @ligneInf = <FICH>; close(FICH); $ligne = $ligneInf[1]; $colonne = $ligneInf[0]; chomp($ligne); chomp($colonne); } ], ] )->pack( -side => 'left' ); $zoneMenuDon->pack( -fill => 'x' ); $fenetreDon->Label( -text => "Pour vous aider d'un fichier cliquez sur Edition->Ouvrir inf" ) ->pack( -anchor => 'ne', -fill => 'x' ); my $visLigne = $fenetreDon->Frame(); $visLigne->Label( -text => "Nombre de Lignes" )->pack( -side => 'left' ); $visLigne->Entry( -textvariable => \$ligne, -background => 'white' )->pack( -side => 'right' ); $visLigne->pack( -fill => 'x' ); my $visColonne = $fenetreDon->Frame(); $visColonne->Label( -text => "Nombre de Colonnes" )->pack( -side => 'left' ); $visColonne->Entry( -textvariable => \$colonne, -background => 'white' )->pack( -side => 'right' ); $visColonne->pack( -fill => 'x' ); my $imageFenetre = $fenetreDon->Frame( -relief => 'sunken', -borderwidth => 1 ); $imageFenetre->Label( -text => "Fenêtre de l'image" )->pack(); my $fenetreLigne = $imageFenetre->Frame(); $fenetreLigne->Label( -text => "Première ligne " )->pack( -side => 'left' ); $fenetreLigne->Entry( -textvariable => \$debutLigne, -background => 'white', -width => 4 )->pack( -side => 'left' ); $fenetreLigne->Entry( -textvariable => \$finLigne, -background => 'white', -width => 4 )->pack( -side => 'right' ); $fenetreLigne->Label( -text => "Dernière ligne" )->pack( -side => 'right' ); $fenetreLigne->pack( -fill => 'x' ); my $fenetreColonne = $imageFenetre->Frame(); $fenetreColonne->Label( -text => "Première colonne" )->pack( -side => 'left' ); $fenetreColonne->Entry( -textvariable => \$debutColonne, -background => 'white', -width => 4 )->pack( -side => 'left' ); $fenetreColonne->Entry( -textvariable => \$finColonne, -background => 'white', -width => 4 )->pack( -side => 'right' ); $fenetreColonne->Label( -text => "Dernière colonne" )->pack( -side => 'right' ); $fenetreColonne->pack( -fill => 'x' ); $imageFenetre->Button( -text => "Toute l'image", -command => sub { $debutLigne = 1; $debutColonne = 1; $finLigne = $ligne; $finColonne = $colonne; }, -borderwidth => 1, )->pack(); $imageFenetre->pack( -fill => 'x', ); $fenetreDon->Label( -text => "Pour ajouter des images allez dans Edition" ) ->pack( -anchor => 'ne', -fill => 'x' ); my $titre = $fenetreDon->Frame(); $titre->Label( -text => "Fichier(s) present(s)", -justify => 'left' )->pack( -side => 'left' ); $titre->Label( -text => "Canal", -justify => 'left' )->pack( -side => 'right' ); $titre->Label( -text => "Date", -justify => 'left' )->pack( -side => 'right' ); $titre->Label( -text => "Type", -justify => 'left' )->pack( -side => 'right' ); $titre->pack( -fill => 'x' ); for ( my $i = 0; $i < scalar(@$listeFichier); $i++ ) { my @temp = split( / /, $$listeFichier[$i] ); $nomDon[$i] = $temp[0]; $typDon[$i] = $temp[1]; $dateDon[$i] = $temp[2]; $canDon[$i] = $temp[3]; $check[$i] = 1; my $fichierDonCont = $fenetreDon->Frame(); $fichierDonCont->Checkbutton( -text => "$nomDon[$i]", -variable => \$check[$i], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $fichierDonCont->Entry( -textvariable => \$canDon[$i], -width => 3, -background => 'white' )->pack( -side => 'right' ); $fichierDonCont->Entry( -textvariable => \$dateDon[$i], -width => 3, -background => 'white' )->pack( -side => 'right' ); $fichierDonCont->Entry( -textvariable => \$typDon[$i], -width => 3, -background => 'white' )->pack( -side => 'right' ); $fichierDonCont->pack( -fill => 'x' ); } } sub ajouterImageDon { my ( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, $listeFichDon, $nomFichierDon ) = @_; print @$listeFichDon; my $fenetreListeImage = $fenetre->Toplevel(); $fenetreListeImage->title("Choisir Image"); $fenetreListeImage->raise(); $fenetreListeImage->Label( -text => "Sélectionnez les images qui\nvous intérresse\n Les images décochées précédemment\nseront supprimées" )->pack(); #on liste les fichiers opendir( DIR, '.' ) || die("Impossible d'ouvrir le dossier courant"); my @listefichiertemp = readdir(DIR); close(DIR); my @listefichierafficher = grep { -f $_ } @listefichiertemp; #on affiche la liste des fichier my $listefichier = $fenetreListeImage->Scrolled( "Listbox", -scrollbars => 'oe', -selectmode => 'multiple', -background => "white" ); $listefichier->insert( 'end', @listefichierafficher ); $listefichier->pack( -ipadx => 80, -ipady => 10 ); $fenetreListeImage->Button( -text => "Valider", -command => sub { my @fichier_select = $listefichier->curselection(); for ( my $i = 0; $i < scalar(@fichier_select); $i++ ) { my $temp = $listefichier->get( $fichier_select[$i] ); push( @$listeFichDon, $temp ); } $fenetreListeImage->destroy(); creerafficherDonClassique( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, $listeFichDon, $nomFichierDon ); } )->pack(); } sub ajouterImageDon2 { my ( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, $listeFichDon, $nomFichierDon ) = @_; print @$listeFichDon; my $fenetreListeImage = $fenetre->Toplevel(); $fenetreListeImage->title("Choisir Image"); $fenetreListeImage->raise(); $fenetreListeImage->Label( -text => "Sélectionnez les images qui\nvous intérresse\n Les images décochées précédemment\nseront supprimées" )->pack(); #on liste les fichiers opendir( DIR, '.' ) || die("Impossible d'ouvrir le dossier courant"); my @listefichiertemp = readdir(DIR); close(DIR); my @listefichierafficher = grep { -f $_ } @listefichiertemp; #on affiche la liste des fichier my $listefichier = $fenetreListeImage->Scrolled( "Listbox", -scrollbars => 'oe', -selectmode => 'multiple', -background => "white" ); $listefichier->insert( 'end', @listefichierafficher ); $listefichier->pack( -ipadx => 80, -ipady => 10 ); $fenetreListeImage->Button( -text => "Valider", -command => sub { my @fichier_select = $listefichier->curselection(); for ( my $i = 0; $i < scalar(@fichier_select); $i++ ) { my $temp = $listefichier->get( $fichier_select[$i] ); push( @$listeFichDon, $temp ); } $fenetreListeImage->destroy(); creerafficherDonavcan( $ligne, $colonne, $debutLigne, $finLigne, $debutColonne, $finColonne, $listeFichDon, $nomFichierDon ); } )->pack(); }
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839 sub ouvrirLoi { my @types = ( [ "Loi files", '.loi' ], [ "All files", "*" ] ); my $nomFichierLoi = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .loi if ( $nomFichierLoi =~ /(\.loi)$/ ) { open( FICH, "$nomFichierLoi" ) || die("Impossible d'ouvrir $nomFichierLoi"); my @donneLoi = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneLoi); $i++ ) { chomp( $donneLoi[$i] ); } $ligneloi = join( " ", @donneLoi ); creerAfficherLoi( $ligneloi, $nomFichierLoi, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Loi', -text => 'Ceci n\'est pas un fichier .loi', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherLoi { my ( $ligneloi, $nomdufichierLoi, $nbelt ) = @_; my $fenetreVisLoi = $fenetre->Toplevel(); $fenetreVisLoi->title("Fichier Loi"); $fenetreVisLoi->raise(); $fenetreVisLoi->maxsize( 670, 710 ); $fenetreVisLoi->minsize( 670, 710 ); $p = 0; $nbelttot = 0; $zoneMenuLoi = $fenetreVisLoi->Frame( -relief => 'groove' ); $zoneMenuLoi->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierLoi = $fenetreVisLoi->getSaveFile( -initialdir => '.' ); $lignenumcanal = join( " ", @numcanal ); $lignedate = join( " ", @date ); $ligneloi = join( " ", @loi ); $lignecoef = join( " ", @coef ); $ligneth = join( " ", @th ); $lignetv = join( " ", @tv ); enregistrerLoi( $nbelttot, $lignenumcanal, $lignedate, $ligneloi, $lignecoef, $ligneth, $lignetv, $nomFichierLoi ); $fenetreVisLoi->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreVisLoi->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuLoi->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrement de nouveaux canaux', -command => sub { my $dialogbox = $fenetreVisLoi->DialogBox( -title => 'Nombre de canaux', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux à insérer: ' ) ->pack( -side => 'top' ); my $nbcan; $dialogbox->add( 'Entry', -textvariable => \$nbcan )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); $nbelttot = $nbelttot + $nbcan; if ( $reponse eq 'Valider' ) { for ( my $j = $nbelt; $j < $nbelttot; $j++ ) { my $visLignes = $fenetreVisLoi->Frame(); $check[$j] = 1; $visLignes->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$numcanal[$j], -background => 'white', -width => 13 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$date[$j], -background => 'white', -width => 4 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$loi[$j], -background => 'white', -width => 5 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$coef[$j], -background => 'white', -width => 14 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$th[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$tv[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $visLignes->pack( -fill => 'x' ); } } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne2 = (); for ( my $j = 0; $j < $nbelt; $j++ ) { if ( $check[$j] == 1 ) { @ligne2 = ( @ligne2, $numcanal[$j] ); @ligne2 = ( @ligne2, $date[$j] ); @ligne2 = ( @ligne2, $loi[$j] ); @ligne2 = ( @ligne2, $coef[$j] ); @ligne2 = ( @ligne2, $th[$j] ); @ligne2 = ( @ligne2, $tv[$j] ); $p++; } } $lignec = join( " ", @ligne2 ); creerAfficherLoi( $lignec, $nomdufichierLoi, $p ); $fenetreVisLoi->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuLoi->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); $fenetreVisLoi->Label( -text => "Pour ajouter de nouveaux enregistrements cliquez sur Edition->Enregistrement de nouveaux canaux \n Pour supprimer les enregistrements décochés cliquez sur Edition->Supprimer les enregistrements déselectionés\n\n Numéro du canal Date Loi Coefficient du lot Taille du voisinage horizontale Taille du voisinage verticale" )->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @loi = split( / /, $ligneloi ); $nbelttot = $nbelt; for ( my $i = 0; $i < $nbelt; $i++ ) { my $visLignes = $fenetreVisLoi->Frame(); $check[$i] = 1; $visLignes->Checkbutton( -variable => \$check[$i], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$numcanal[$i], -background => 'white', -width => 13 )->pack( -side => 'left' ); $numcanal[$i] = $loi[ 6 * $i ]; $visLignes->Entry( -textvariable => \$date[$i], -background => 'white', -width => 4 )->pack( -side => 'left' ); $date[$i] = $loi[ ( 6 * $i ) + 1 ]; $visLignes->Entry( -textvariable => \$loi[$i], -background => 'white', -width => 5 )->pack( -side => 'left' ); $loi[$i] = $loi[ ( 6 * $i ) + 2 ]; $visLignes->Entry( -textvariable => \$coef[$i], -background => 'white', -width => 14 )->pack( -side => 'left' ); $coef[$i] = $loi[ ( 6 * $i ) + 3 ]; $visLignes->Entry( -textvariable => \$th[$i], -background => 'white', -width => 24 )->pack( -side => 'left' ); $th[$i] = $loi[ ( 6 * $i ) + 4 ]; $visLignes->Entry( -textvariable => \$tv[$i], -background => 'white', -width => 24 )->pack( -side => 'left' ); $tv[$i] = $loi[ ( 6 * $i ) + 5 ]; $visLignes->pack( -fill => 'x' ); } } sub enregistrerLoi { my ( $nbelttot, $lignenumcanal, $lignedate, $ligneloi, $lignecoef, $ligneth, $lignetv, $nomFichierLoi ) = @_; my ( @nc, @d, @l, @c, @lth, @ltv ); if ( $nomFichierLoi !~ /(\.loi)$/ ) { $nomFichierLoi = "$nomFichierLoi.loi"; } @nc = split( / /, $lignenumcanal ); @d = split( / /, $lignedate ); @l = split( / /, $ligneloi ); @c = split( / /, $lignecoef ); @lth = split( / /, $ligneth ); @ltv = split( / /, $lignetv ); open( FICH, ">$nomFichierLoi" ) || die("Impossible d'ouvrir $nomFichierLoi"); for ( my $i = 0; $i < $nbelttot; $i++ ) { print FICH "$nc[$i] $d[$i] $l[$i] $c[$i] $lth[$i] $ltv[$i]\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierLoi" ); } sub ouvrirCan { my @types = ( [ "Can files", '.can' ], [ "All files", "*" ] ); my $nomFichierCan = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .can if ( $nomFichierCan =~ /(\.can)$/ ) { open( FICH, "$nomFichierCan" ) || die("Impossible d'ouvrir $nomFichierCan"); my @donneCan = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneCan); $i++ ) { chomp( $donneCan[$i] ); } $lignecan = join( " ", @donneCan ); creerAfficherCan( $lignecan, $nomFichierCan, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Can', -text => 'Ceci n\'est pas un fichier .can', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherCan { my ( $lignecan, $nomdufichierCan, $i ) = @_; my $fenetreCan = $fenetre->Toplevel(); $fenetreCan->title("Fichier Can"); $fenetreCan->raise(); $fenetreCan->maxsize( 750, 700 ); $fenetreCan->minsize( 750, 700 ); $nb = 0; $v = 0; $w = 0; $ind = 0; $j = 0; $r = 0; $p = 0; $zoneMenuCan = $fenetreCan->Frame( -relief => 'groove' ); $zoneMenuCan->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierCan = $fenetreCan->getSaveFile( -initialdir => '.' ); $lignen = join( " ", @nommask ); $lignenbvm = join( " ", @nbvm ); $lignenbcm = join( " ", @nbcm ); $lignevm = join( " ", @vm ); $lignecm = join( " ", @nc ); enregistrerCan( $i, $lignen, $lignenbvm, $lignenbcm, $lignevm, $lignecm, $nomFichierCan ); $fenetreCan->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreCan->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuCan->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Premier masque', -command => sub { my $dialogbox = $fenetreCan->DialogBox( -title => 'Indications', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de valeurs masquantes: ' ) ->pack( -side => 'top' ); my $nombvm; $dialogbox->add( 'Entry', -textvariable => \$nombvm )->pack( -side => 'top' ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux masqués: ' ) ->pack( -side => 'top' ); my $nombcm; $dialogbox->add( 'Entry', -textvariable => \$nombcm )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { $i = 0; $j = 0; $v = 0; $w = 0; $t = 0; $n = 0; $f = 1; $g = 1; my $Ligne = $fenetreCan->Frame(); $Ligne->Entry( -textvariable => \$nommask[$j], -background => 'white', -width => 15 )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nbvm[$j], -background => 'white', -width => 23 )->pack( -side => 'left' ); $nbvm[$j] = $nombvm; for ( my $k = 1; $k <= $nombvm; $k++ ) { $Ligne->Entry( -textvariable => \$vm[$v], -background => 'white', -width => 18 / $nombvm )->pack( -side => 'left' ); $v++; } $Ligne->Entry( -textvariable => \$nbcm[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $nbcm[$j] = $nombcm; for ( my $l = 1; $l <= $nombcm; $l++ ) { $Ligne->Entry( -textvariable => \$nc[$w], -background => 'white', -width => 18 / $nombcm )->pack( -side => 'left' ); $w++; $i++; $j++; } $Ligne->pack( -fill => 'x' ); } } ], [ 'command' => 'Ajouter un nouveau masque', -command => sub { my $dialogbox = $fenetreCan->DialogBox( -title => 'Indications', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de valeurs masquantes: ' ) ->pack( -side => 'top' ); my $nombvm2; $dialogbox->add( 'Entry', -textvariable => \$nombvm2 )->pack( -side => 'top' ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux masqués: ' ) ->pack( -side => 'top' ); my $nombcm2; $dialogbox->add( 'Entry', -textvariable => \$nombcm2 )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { my $Ligne = $fenetreCan->Frame(); $j++; $check[$j] = 1; $Ligne->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nommask[$j], -background => 'white', -width => 15 )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nbvm[$j], -background => 'white', -width => 23 )->pack( -side => 'left' ); $nbvm[$j] = $nombvm2; for ( my $k = 1; $k <= $nombvm2; $k++ ) { $Ligne->Entry( -textvariable => \$vm[$v], -background => 'white', -width => 15 / $nombvm2 )->pack( -side => 'left' ); $v++; } $Ligne->Entry( -textvariable => \$nbcm[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $nbcm[$j] = $nombcm2; for ( my $l = 1; $l <= $nombcm2; $l++ ) { $Ligne->Entry( -textvariable => \$nc[$w], -background => 'white', -width => 18 / $nombcm2 )->pack( -side => 'left' ); $w++; } $i++; $Ligne->pack( -fill => 'x' ); } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne4 = (); for ( my $j = 0; $j <= $i; $j++ ) { if ( $check[$j] == 1 ) { @ligne4 = ( @ligne4, $nommask[$j] ); @ligne4 = ( @ligne4, $nbvm[$j] ); for ( my $t = $f; $t < $f + $nbvm[$j]; $t++ ) { @ligne4 = ( @ligne4, $vm[$t] ); } @ligne4 = ( @ligne4, $nbcm[$j] ); for ( my $n = $g; $n < $g + $nbcm[$j]; $n++ ) { @ligne4 = ( @ligne4, $nc[$n] ); } $p++; } $f = $f + $nbvm[$j]; $g = $g + $nbcm[$j]; } $lignec = join( " ", @ligne4 ); creerAfficherCan( $lignec, $nomdufichierCan, $p ); $fenetreCan->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuCan->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); $fenetreCan->Label( -text => "Pour créer le premier enregistrement cliquez sur Fichier->Premier masque \n Pour ajouter un nouvel enregistrement cliquez sur Edition->Ajouter un nouveau masque \n\n Nom du masque Nb de valeurs masquantes Valeurs Nb de canaux masqués Numéros des canaux" )->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @can = split( / /, $lignecan ); $nbeltp = 0; for ( my $j = 0; $j < $i; $j++ ) { my $Ligne = $fenetreCan->Frame(); $check[$j] = 1; $Ligne->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nommask[$j], -background => 'white', -width => 15 )->pack( -side => 'left' ); $nommask[$j] = $can[$nbeltp]; $Ligne->Entry( -textvariable => \$nbvm[$j], -background => 'white', -width => 23 )->pack( -side => 'left' ); $nbvm[$j] = $can[ 1 + $nbeltp ]; for ( my $k = 1; $k <= $nbvm[$j]; $k++ ) { $Ligne->Entry( -textvariable => \$vm[$v], -background => 'white', -width => 15 / $nbvm[$j] )->pack( -side => 'left' ); $vm[$v] = $can[ 1 + $k + $nbeltp ]; $v++; } $Ligne->Entry( -textvariable => \$nbcm[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $nbcm[$j] = $can[ 1 + $k + $nbeltp ]; for ( my $l = 1; $l <= $nbcm[$j]; $l++ ) { $Ligne->Entry( -textvariable => \$nc[$w], -background => 'white', -width => 18 / $nbcm[$j] )->pack( -side => 'left' ); $nc[$w] = $can[ 1 + $k + $l + $nbeltp ]; $w++; } $nbelt = 3 + $nbvm[$j] + $nbcm[$j]; $nbeltp = $nbeltp + $nbelt; $Ligne->pack( -fill => 'x' ); } } sub enregistrerCan { my ( $i, $lignen, $lignenbvm, $lignenbcm, $lignevm, $lignecm, $nomFichierCan ) = @_; if ( $nomFichierCan !~ /(\.can)$/ ) { $nomFichierCan = "$nomFichierCan.can"; } @n = split( / /, $lignen ); @nvm = split( / /, $lignenbvm ); @ncm = split( / /, $lignenbcm ); @valm = split( / /, $lignevm ); @canm = split( / /, $lignecm ); $t = 0; $r = 0; open( FICH, ">$nomFichierCan" ) || die("Impossible d'ouvrir $nomFichierCan"); for ( my $j = 0; $j < $i; $j++ ) { print FICH "$n[$j] $nvm[$j]"; for ( my $p = 0; $p < $nvm[$j]; $p++ ) { print FICH " $valm[$p+$t]"; } $t = $t + $nvm[$j]; print FICH " $ncm[$j]"; for ( my $q = 0; $q < $ncm[$j]; $q++ ) { print FICH " $canm[$q+$r]"; } $r = $r + $ncm[$j]; print FICH "\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierCan" ); } sub ouvrirMaskcla { my @types = ( [ "Maskcla files", '.maskcla' ], [ "All files", "*" ] ); my $nomFichierMaskcla = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .maskcla if ( $nomFichierMaskcla =~ /(\.maskcla)$/ ) { open( FICH, "$nomFichierMaskcla" ) || die("Impossible d'ouvrir $nomFichierMaskcla"); my @donneMaskcla = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneMaskcla); $i++ ) { chomp( $donneMaskcla[$i] ); } $lignemaskcla = join( " ", @donneMaskcla ); creerAfficherMaskcla( $lignemaskcla, $nomFichierMaskcla, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Maskcla', -text => 'Ceci n\'est pas un fichier .maskcla', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherMaskcla { my ( $lignemaskcla, $nomdufichierMaskcla, $i ) = @_; my $fenetreMaskcla = $fenetre->Toplevel(); $fenetreMaskcla->title("Fichier Maskcla"); $fenetreMaskcla->raise(); $fenetreMaskcla->maxsize( 670, 700 ); $fenetreMaskcla->minsize( 670, 700 ); $f = 0; $p = 0; $zoneMenuMaskcla = $fenetreMaskcla->Frame( -relief => 'groove' ); $zoneMenuMaskcla->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierMaskcla = $fenetreMaskcla->getSaveFile( -initialdir => '.' ); $lignev = join( " ", @vm ); $lignenbci = join( " ", @nbci ); $ligneci = join( " ", @ci ); enregistrerMaskcla( $nomfic, $nbvm, $lignev, $lignenbci, $ligneci, $nomFichierMaskcla ); $fenetreMaskcla->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreMaskcla->destroy() } ] ] )->pack( -side => 'left' ); $zoneMenuMaskcla->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Ajouter une valeur masquante', -command => sub { my $dialogbox = $fenetreMaskcla->DialogBox( -title => 'Indications', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de classes interdites: ' ) ->pack( -side => 'top' ); my $nbc; $dialogbox->add( 'Entry', -textvariable => \$nbc )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { $nbvm++; my $Ligne = $fenetreMaskcla->Frame(); $check[ $nbvm - 1 ] = 1; $Ligne->Checkbutton( -variable => \$check[ $nbvm - 1 ], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$vm[ $nbvm - 1 ], -background => 'white', -width => 18 )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nbci[ $nbvm - 1 ], -background => 'white', -width => 19 )->pack( -side => 'left' ); $nbci[ $nbvm - 1 ] = $nbc; for ( my $k = 1; $k <= $nbc; $k++ ) { $Ligne->Entry( -textvariable => \$ci[$v], -background => 'white', -width => 50 / $nbc )->pack( -side => 'left' ); $v++; } $Ligne->pack( -fill => 'x' ); } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne2 = (); for ( my $j = 0; $j <= $i; $j++ ) { if ( $check[$j] == 1 ) { $p++; } } @ligne2 = ( @ligne2, $nomfic ); @ligne2 = ( @ligne2, $p ); for ( my $j = 0; $j <= $nbvm; $j++ ) { if ( $check[$j] == 1 ) { @ligne2 = ( @ligne2, $vm[$j] ); @ligne2 = ( @ligne2, $nbci[$j] ); for ( my $n = $f; $n < $f + $nbci[$j]; $n++ ) { @ligne2 = ( @ligne2, $ci[$n] ); } $p++; } $f = $f + $nbci[$j]; } $lignec = join( " ", @ligne2 ); creerAfficherMaskcla( $lignec, $nomdufichierMaskcla, $p ); $fenetreMaskcla->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuMaskcla->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @maskcla = split( / /, $lignemaskcla ); $fenetreMaskcla->Label( -text => "A la création, n'indiquez que le nom du fichier masque, \n le nombre de valeurs masquantes s'incrémentera automatiquement \n Pour ajouter une valeur masquante cliquez sur Edition->Ajouter valeur masquante" )->pack(); $fenetreMaskcla->Label( -text => "Fichier masque" )->pack(); $fenetreMaskcla->Entry( -textvariable => \$nomfic, -background => 'white', -width => 20 )->pack(); $nomfic = $maskcla[0]; $fenetreMaskcla->Label( -text => "Nombre de valeurs masquantes" )->pack(); $fenetreMaskcla->Entry( -textvariable => \$nbvm, -background => 'white', -width => 5 )->pack(); $nbvm = $maskcla[1]; $fenetreMaskcla->Label( -text => "Valeur masquante Nb de classes interdites Classes Interdites " )->pack(); $v = 0; $nbeltp = 0; for ( my $j = 0; $j < $nbvm; $j++ ) { my $Ligne2 = $fenetreMaskcla->Frame(); $check[$j] = 1; $Ligne2->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne2->Entry( -textvariable => \$vm[$j], -background => 'white', -width => 18 )->pack( -side => 'left' ); $vm[$j] = $maskcla[ 2 + $nbeltp ]; $Ligne2->Entry( -textvariable => \$nbci[$j], -background => 'white', -width => 19 )->pack( -side => 'left' ); $nbci[$j] = $maskcla[ 3 + $nbeltp ]; for ( my $k = 1; $k <= $nbci[$j]; $k++ ) { $Ligne2->Entry( -textvariable => \$ci[$v], -background => 'white', -width => 50 / $nbci[$j] )->pack( -side => 'left' ); $ci[$v] = $maskcla[ 3 + $k + $nbeltp ]; $v++; } $nbelt = 2 + $nbci[$j]; $nbeltp = $nbeltp + $nbelt; $Ligne2->pack( -fill => 'x' ); } } sub enregistrerMaskcla { my ( $nomfic, $nbvm, $lignev, $lignenbci, $ligneci, $nomFichierMaskcla ) = @_; if ( $nomFichierMaskcla !~ /(\.maskcla)$/ ) { $nomFichierMaskcla = "$nomFichierMaskcla.maskcla"; } @v = split( / /, $lignev ); @nbci = split( / /, $lignenbci ); @ci = split( / /, $ligneci ); $t = 0; open( FICH, ">$nomFichierMaskcla" ) || die("Impossible d'ouvrir $nomFichierMaskcla"); print FICH "$nomfic $nbvm\n"; for ( my $j = 0; $j < $nbvm; $j++ ) { print FICH "$v[$j] $nbci[$j]"; for ( my $p = 0; $p < $nbci[$j]; $p++ ) { print FICH " $ci[$p+$t]"; } $t = $t + $nbci[$j]; print FICH "\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierMaskcla" ); } sub ouvrirCancla { my @types = ( [ "Cancla files", '.cancla' ], [ "All files", "*" ] ); my $nomFichierCancla = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .cancla if ( $nomFichierCancla =~ /(\.cancla)$/ ) { open( FICH, "$nomFichierCancla" ) || die("Impossible d'ouvrir $nomFichierCancla"); my @donneCancla = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneCancla); $i++ ) { chomp( $donneCancla[$i] ); } $lignecancla = join( " ", @donneCancla ); creerAfficherCancla( $lignecancla, $nomFichierCancla, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Cancla', -text => 'Ceci n\'est pas un fichier .cancla', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } }
etc etcCode:
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839 sub ouvrirLoi { my @types = ( [ "Loi files", '.loi' ], [ "All files", "*" ] ); my $nomFichierLoi = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .loi if ( $nomFichierLoi =~ /(\.loi)$/ ) { open( FICH, "$nomFichierLoi" ) || die("Impossible d'ouvrir $nomFichierLoi"); my @donneLoi = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneLoi); $i++ ) { chomp( $donneLoi[$i] ); } $ligneloi = join( " ", @donneLoi ); creerAfficherLoi( $ligneloi, $nomFichierLoi, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Loi', -text => 'Ceci n\'est pas un fichier .loi', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherLoi { my ( $ligneloi, $nomdufichierLoi, $nbelt ) = @_; my $fenetreVisLoi = $fenetre->Toplevel(); $fenetreVisLoi->title("Fichier Loi"); $fenetreVisLoi->raise(); $fenetreVisLoi->maxsize( 670, 710 ); $fenetreVisLoi->minsize( 670, 710 ); $p = 0; $nbelttot = 0; $zoneMenuLoi = $fenetreVisLoi->Frame( -relief => 'groove' ); $zoneMenuLoi->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierLoi = $fenetreVisLoi->getSaveFile( -initialdir => '.' ); $lignenumcanal = join( " ", @numcanal ); $lignedate = join( " ", @date ); $ligneloi = join( " ", @loi ); $lignecoef = join( " ", @coef ); $ligneth = join( " ", @th ); $lignetv = join( " ", @tv ); enregistrerLoi( $nbelttot, $lignenumcanal, $lignedate, $ligneloi, $lignecoef, $ligneth, $lignetv, $nomFichierLoi ); $fenetreVisLoi->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreVisLoi->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuLoi->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrement de nouveaux canaux', -command => sub { my $dialogbox = $fenetreVisLoi->DialogBox( -title => 'Nombre de canaux', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux à insérer: ' ) ->pack( -side => 'top' ); my $nbcan; $dialogbox->add( 'Entry', -textvariable => \$nbcan )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); $nbelttot = $nbelttot + $nbcan; if ( $reponse eq 'Valider' ) { for ( my $j = $nbelt; $j < $nbelttot; $j++ ) { my $visLignes = $fenetreVisLoi->Frame(); $check[$j] = 1; $visLignes->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$numcanal[$j], -background => 'white', -width => 13 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$date[$j], -background => 'white', -width => 4 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$loi[$j], -background => 'white', -width => 5 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$coef[$j], -background => 'white', -width => 14 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$th[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$tv[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $visLignes->pack( -fill => 'x' ); } } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne2 = (); for ( my $j = 0; $j < $nbelt; $j++ ) { if ( $check[$j] == 1 ) { @ligne2 = ( @ligne2, $numcanal[$j] ); @ligne2 = ( @ligne2, $date[$j] ); @ligne2 = ( @ligne2, $loi[$j] ); @ligne2 = ( @ligne2, $coef[$j] ); @ligne2 = ( @ligne2, $th[$j] ); @ligne2 = ( @ligne2, $tv[$j] ); $p++; } } $lignec = join( " ", @ligne2 ); creerAfficherLoi( $lignec, $nomdufichierLoi, $p ); $fenetreVisLoi->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuLoi->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); $fenetreVisLoi->Label( -text => "Pour ajouter de nouveaux enregistrements cliquez sur Edition->Enregistrement de nouveaux canaux \n Pour supprimer les enregistrements décochés cliquez sur Edition->Supprimer les enregistrements déselectionés\n\n Numéro du canal Date Loi Coefficient du lot Taille du voisinage horizontale Taille du voisinage verticale" )->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @loi = split( / /, $ligneloi ); $nbelttot = $nbelt; for ( my $i = 0; $i < $nbelt; $i++ ) { my $visLignes = $fenetreVisLoi->Frame(); $check[$i] = 1; $visLignes->Checkbutton( -variable => \$check[$i], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$numcanal[$i], -background => 'white', -width => 13 )->pack( -side => 'left' ); $numcanal[$i] = $loi[ 6 * $i ]; $visLignes->Entry( -textvariable => \$date[$i], -background => 'white', -width => 4 )->pack( -side => 'left' ); $date[$i] = $loi[ ( 6 * $i ) + 1 ]; $visLignes->Entry( -textvariable => \$loi[$i], -background => 'white', -width => 5 )->pack( -side => 'left' ); $loi[$i] = $loi[ ( 6 * $i ) + 2 ]; $visLignes->Entry( -textvariable => \$coef[$i], -background => 'white', -width => 14 )->pack( -side => 'left' ); $coef[$i] = $loi[ ( 6 * $i ) + 3 ]; $visLignes->Entry( -textvariable => \$th[$i], -background => 'white', -width => 24 )->pack( -side => 'left' ); $th[$i] = $loi[ ( 6 * $i ) + 4 ]; $visLignes->Entry( -textvariable => \$tv[$i], -background => 'white', -width => 24 )->pack( -side => 'left' ); $tv[$i] = $loi[ ( 6 * $i ) + 5 ]; $visLignes->pack( -fill => 'x' ); } } sub enregistrerLoi { my ( $nbelttot, $lignenumcanal, $lignedate, $ligneloi, $lignecoef, $ligneth, $lignetv, $nomFichierLoi ) = @_; my ( @nc, @d, @l, @c, @lth, @ltv ); if ( $nomFichierLoi !~ /(\.loi)$/ ) { $nomFichierLoi = "$nomFichierLoi.loi"; } @nc = split( / /, $lignenumcanal ); @d = split( / /, $lignedate ); @l = split( / /, $ligneloi ); @c = split( / /, $lignecoef ); @lth = split( / /, $ligneth ); @ltv = split( / /, $lignetv ); open( FICH, ">$nomFichierLoi" ) || die("Impossible d'ouvrir $nomFichierLoi"); for ( my $i = 0; $i < $nbelttot; $i++ ) { print FICH "$nc[$i] $d[$i] $l[$i] $c[$i] $lth[$i] $ltv[$i]\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierLoi" ); } sub ouvrirCan { my @types = ( [ "Can files", '.can' ], [ "All files", "*" ] ); my $nomFichierCan = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .can if ( $nomFichierCan =~ /(\.can)$/ ) { open( FICH, "$nomFichierCan" ) || die("Impossible d'ouvrir $nomFichierCan"); my @donneCan = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneCan); $i++ ) { chomp( $donneCan[$i] ); } $lignecan = join( " ", @donneCan ); creerAfficherCan( $lignecan, $nomFichierCan, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Can', -text => 'Ceci n\'est pas un fichier .can', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherCan { my ( $lignecan, $nomdufichierCan, $i ) = @_; my $fenetreCan = $fenetre->Toplevel(); $fenetreCan->title("Fichier Can"); $fenetreCan->raise(); $fenetreCan->maxsize( 750, 700 ); $fenetreCan->minsize( 750, 700 ); $nb = 0; $v = 0; $w = 0; $ind = 0; $j = 0; $r = 0; $p = 0; $zoneMenuCan = $fenetreCan->Frame( -relief => 'groove' ); $zoneMenuCan->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierCan = $fenetreCan->getSaveFile( -initialdir => '.' ); $lignen = join( " ", @nommask ); $lignenbvm = join( " ", @nbvm ); $lignenbcm = join( " ", @nbcm ); $lignevm = join( " ", @vm ); $lignecm = join( " ", @nc ); enregistrerCan( $i, $lignen, $lignenbvm, $lignenbcm, $lignevm, $lignecm, $nomFichierCan ); $fenetreCan->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreCan->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuCan->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Premier masque', -command => sub { my $dialogbox = $fenetreCan->DialogBox( -title => 'Indications', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de valeurs masquantes: ' ) ->pack( -side => 'top' ); my $nombvm; $dialogbox->add( 'Entry', -textvariable => \$nombvm )->pack( -side => 'top' ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux masqués: ' ) ->pack( -side => 'top' ); my $nombcm; $dialogbox->add( 'Entry', -textvariable => \$nombcm )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { $i = 0; $j = 0; $v = 0; $w = 0; $t = 0; $n = 0; $f = 1; $g = 1; my $Ligne = $fenetreCan->Frame(); $Ligne->Entry( -textvariable => \$nommask[$j], -background => 'white', -width => 15 )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nbvm[$j], -background => 'white', -width => 23 )->pack( -side => 'left' ); $nbvm[$j] = $nombvm; for ( my $k = 1; $k <= $nombvm; $k++ ) { $Ligne->Entry( -textvariable => \$vm[$v], -background => 'white', -width => 18 / $nombvm )->pack( -side => 'left' ); $v++; } $Ligne->Entry( -textvariable => \$nbcm[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $nbcm[$j] = $nombcm; for ( my $l = 1; $l <= $nombcm; $l++ ) { $Ligne->Entry( -textvariable => \$nc[$w], -background => 'white', -width => 18 / $nombcm )->pack( -side => 'left' ); $w++; $i++; $j++; } $Ligne->pack( -fill => 'x' ); } } ], [ 'command' => 'Ajouter un nouveau masque', -command => sub { my $dialogbox = $fenetreCan->DialogBox( -title => 'Indications', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de valeurs masquantes: ' ) ->pack( -side => 'top' ); my $nombvm2; $dialogbox->add( 'Entry', -textvariable => \$nombvm2 )->pack( -side => 'top' ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux masqués: ' ) ->pack( -side => 'top' ); my $nombcm2; $dialogbox->add( 'Entry', -textvariable => \$nombcm2 )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { my $Ligne = $fenetreCan->Frame(); $j++; $check[$j] = 1; $Ligne->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nommask[$j], -background => 'white', -width => 15 )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nbvm[$j], -background => 'white', -width => 23 )->pack( -side => 'left' ); $nbvm[$j] = $nombvm2; for ( my $k = 1; $k <= $nombvm2; $k++ ) { $Ligne->Entry( -textvariable => \$vm[$v], -background => 'white', -width => 15 / $nombvm2 )->pack( -side => 'left' ); $v++; } $Ligne->Entry( -textvariable => \$nbcm[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $nbcm[$j] = $nombcm2; for ( my $l = 1; $l <= $nombcm2; $l++ ) { $Ligne->Entry( -textvariable => \$nc[$w], -background => 'white', -width => 18 / $nombcm2 )->pack( -side => 'left' ); $w++; } $i++; $Ligne->pack( -fill => 'x' ); } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne4 = (); for ( my $j = 0; $j <= $i; $j++ ) { if ( $check[$j] == 1 ) { @ligne4 = ( @ligne4, $nommask[$j] ); @ligne4 = ( @ligne4, $nbvm[$j] ); for ( my $t = $f; $t < $f + $nbvm[$j]; $t++ ) { @ligne4 = ( @ligne4, $vm[$t] ); } @ligne4 = ( @ligne4, $nbcm[$j] ); for ( my $n = $g; $n < $g + $nbcm[$j]; $n++ ) { @ligne4 = ( @ligne4, $nc[$n] ); } $p++; } $f = $f + $nbvm[$j]; $g = $g + $nbcm[$j]; } $lignec = join( " ", @ligne4 ); creerAfficherCan( $lignec, $nomdufichierCan, $p ); $fenetreCan->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuCan->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); $fenetreCan->Label( -text => "Pour créer le premier enregistrement cliquez sur Fichier->Premier masque \n Pour ajouter un nouvel enregistrement cliquez sur Edition->Ajouter un nouveau masque \n\n Nom du masque Nb de valeurs masquantes Valeurs Nb de canaux masqués Numéros des canaux" )->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @can = split( / /, $lignecan ); $nbeltp = 0; for ( my $j = 0; $j < $i; $j++ ) { my $Ligne = $fenetreCan->Frame(); $check[$j] = 1; $Ligne->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nommask[$j], -background => 'white', -width => 15 )->pack( -side => 'left' ); $nommask[$j] = $can[$nbeltp]; $Ligne->Entry( -textvariable => \$nbvm[$j], -background => 'white', -width => 23 )->pack( -side => 'left' ); $nbvm[$j] = $can[ 1 + $nbeltp ]; for ( my $k = 1; $k <= $nbvm[$j]; $k++ ) { $Ligne->Entry( -textvariable => \$vm[$v], -background => 'white', -width => 15 / $nbvm[$j] )->pack( -side => 'left' ); $vm[$v] = $can[ 1 + $k + $nbeltp ]; $v++; } $Ligne->Entry( -textvariable => \$nbcm[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $nbcm[$j] = $can[ 1 + $k + $nbeltp ]; for ( my $l = 1; $l <= $nbcm[$j]; $l++ ) { $Ligne->Entry( -textvariable => \$nc[$w], -background => 'white', -width => 18 / $nbcm[$j] )->pack( -side => 'left' ); $nc[$w] = $can[ 1 + $k + $l + $nbeltp ]; $w++; } $nbelt = 3 + $nbvm[$j] + $nbcm[$j]; $nbeltp = $nbeltp + $nbelt; $Ligne->pack( -fill => 'x' ); } } sub enregistrerCan { my ( $i, $lignen, $lignenbvm, $lignenbcm, $lignevm, $lignecm, $nomFichierCan ) = @_; if ( $nomFichierCan !~ /(\.can)$/ ) { $nomFichierCan = "$nomFichierCan.can"; } @n = split( / /, $lignen ); @nvm = split( / /, $lignenbvm ); @ncm = split( / /, $lignenbcm ); @valm = split( / /, $lignevm ); @canm = split( / /, $lignecm ); $t = 0; $r = 0; open( FICH, ">$nomFichierCan" ) || die("Impossible d'ouvrir $nomFichierCan"); for ( my $j = 0; $j < $i; $j++ ) { print FICH "$n[$j] $nvm[$j]"; for ( my $p = 0; $p < $nvm[$j]; $p++ ) { print FICH " $valm[$p+$t]"; } $t = $t + $nvm[$j]; print FICH " $ncm[$j]"; for ( my $q = 0; $q < $ncm[$j]; $q++ ) { print FICH " $canm[$q+$r]"; } $r = $r + $ncm[$j]; print FICH "\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierCan" ); } sub ouvrirMaskcla { my @types = ( [ "Maskcla files", '.maskcla' ], [ "All files", "*" ] ); my $nomFichierMaskcla = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .maskcla if ( $nomFichierMaskcla =~ /(\.maskcla)$/ ) { open( FICH, "$nomFichierMaskcla" ) || die("Impossible d'ouvrir $nomFichierMaskcla"); my @donneMaskcla = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneMaskcla); $i++ ) { chomp( $donneMaskcla[$i] ); } $lignemaskcla = join( " ", @donneMaskcla ); creerAfficherMaskcla( $lignemaskcla, $nomFichierMaskcla, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Maskcla', -text => 'Ceci n\'est pas un fichier .maskcla', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherMaskcla { my ( $lignemaskcla, $nomdufichierMaskcla, $i ) = @_; my $fenetreMaskcla = $fenetre->Toplevel(); $fenetreMaskcla->title("Fichier Maskcla"); $fenetreMaskcla->raise(); $fenetreMaskcla->maxsize( 670, 700 ); $fenetreMaskcla->minsize( 670, 700 ); $f = 0; $p = 0; $zoneMenuMaskcla = $fenetreMaskcla->Frame( -relief => 'groove' ); $zoneMenuMaskcla->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierMaskcla = $fenetreMaskcla->getSaveFile( -initialdir => '.' ); $lignev = join( " ", @vm ); $lignenbci = join( " ", @nbci ); $ligneci = join( " ", @ci ); enregistrerMaskcla( $nomfic, $nbvm, $lignev, $lignenbci, $ligneci, $nomFichierMaskcla ); $fenetreMaskcla->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreMaskcla->destroy() } ] ] )->pack( -side => 'left' ); $zoneMenuMaskcla->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Ajouter une valeur masquante', -command => sub { my $dialogbox = $fenetreMaskcla->DialogBox( -title => 'Indications', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de classes interdites: ' ) ->pack( -side => 'top' ); my $nbc; $dialogbox->add( 'Entry', -textvariable => \$nbc )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); if ( $reponse eq 'Valider' ) { $nbvm++; my $Ligne = $fenetreMaskcla->Frame(); $check[ $nbvm - 1 ] = 1; $Ligne->Checkbutton( -variable => \$check[ $nbvm - 1 ], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$vm[ $nbvm - 1 ], -background => 'white', -width => 18 )->pack( -side => 'left' ); $Ligne->Entry( -textvariable => \$nbci[ $nbvm - 1 ], -background => 'white', -width => 19 )->pack( -side => 'left' ); $nbci[ $nbvm - 1 ] = $nbc; for ( my $k = 1; $k <= $nbc; $k++ ) { $Ligne->Entry( -textvariable => \$ci[$v], -background => 'white', -width => 50 / $nbc )->pack( -side => 'left' ); $v++; } $Ligne->pack( -fill => 'x' ); } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne2 = (); for ( my $j = 0; $j <= $i; $j++ ) { if ( $check[$j] == 1 ) { $p++; } } @ligne2 = ( @ligne2, $nomfic ); @ligne2 = ( @ligne2, $p ); for ( my $j = 0; $j <= $nbvm; $j++ ) { if ( $check[$j] == 1 ) { @ligne2 = ( @ligne2, $vm[$j] ); @ligne2 = ( @ligne2, $nbci[$j] ); for ( my $n = $f; $n < $f + $nbci[$j]; $n++ ) { @ligne2 = ( @ligne2, $ci[$n] ); } $p++; } $f = $f + $nbci[$j]; } $lignec = join( " ", @ligne2 ); creerAfficherMaskcla( $lignec, $nomdufichierMaskcla, $p ); $fenetreMaskcla->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuMaskcla->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @maskcla = split( / /, $lignemaskcla ); $fenetreMaskcla->Label( -text => "A la création, n'indiquez que le nom du fichier masque, \n le nombre de valeurs masquantes s'incrémentera automatiquement \n Pour ajouter une valeur masquante cliquez sur Edition->Ajouter valeur masquante" )->pack(); $fenetreMaskcla->Label( -text => "Fichier masque" )->pack(); $fenetreMaskcla->Entry( -textvariable => \$nomfic, -background => 'white', -width => 20 )->pack(); $nomfic = $maskcla[0]; $fenetreMaskcla->Label( -text => "Nombre de valeurs masquantes" )->pack(); $fenetreMaskcla->Entry( -textvariable => \$nbvm, -background => 'white', -width => 5 )->pack(); $nbvm = $maskcla[1]; $fenetreMaskcla->Label( -text => "Valeur masquante Nb de classes interdites Classes Interdites " )->pack(); $v = 0; $nbeltp = 0; for ( my $j = 0; $j < $nbvm; $j++ ) { my $Ligne2 = $fenetreMaskcla->Frame(); $check[$j] = 1; $Ligne2->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $Ligne2->Entry( -textvariable => \$vm[$j], -background => 'white', -width => 18 )->pack( -side => 'left' ); $vm[$j] = $maskcla[ 2 + $nbeltp ]; $Ligne2->Entry( -textvariable => \$nbci[$j], -background => 'white', -width => 19 )->pack( -side => 'left' ); $nbci[$j] = $maskcla[ 3 + $nbeltp ]; for ( my $k = 1; $k <= $nbci[$j]; $k++ ) { $Ligne2->Entry( -textvariable => \$ci[$v], -background => 'white', -width => 50 / $nbci[$j] )->pack( -side => 'left' ); $ci[$v] = $maskcla[ 3 + $k + $nbeltp ]; $v++; } $nbelt = 2 + $nbci[$j]; $nbeltp = $nbeltp + $nbelt; $Ligne2->pack( -fill => 'x' ); } } sub enregistrerMaskcla { my ( $nomfic, $nbvm, $lignev, $lignenbci, $ligneci, $nomFichierMaskcla ) = @_; if ( $nomFichierMaskcla !~ /(\.maskcla)$/ ) { $nomFichierMaskcla = "$nomFichierMaskcla.maskcla"; } @v = split( / /, $lignev ); @nbci = split( / /, $lignenbci ); @ci = split( / /, $ligneci ); $t = 0; open( FICH, ">$nomFichierMaskcla" ) || die("Impossible d'ouvrir $nomFichierMaskcla"); print FICH "$nomfic $nbvm\n"; for ( my $j = 0; $j < $nbvm; $j++ ) { print FICH "$v[$j] $nbci[$j]"; for ( my $p = 0; $p < $nbci[$j]; $p++ ) { print FICH " $ci[$p+$t]"; } $t = $t + $nbci[$j]; print FICH "\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierMaskcla" ); } sub ouvrirCancla { my @types = ( [ "Cancla files", '.cancla' ], [ "All files", "*" ] ); my $nomFichierCancla = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .cancla if ( $nomFichierCancla =~ /(\.cancla)$/ ) { open( FICH, "$nomFichierCancla" ) || die("Impossible d'ouvrir $nomFichierCancla"); my @donneCancla = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneCancla); $i++ ) { chomp( $donneCancla[$i] ); } $lignecancla = join( " ", @donneCancla ); creerAfficherCancla( $lignecancla, $nomFichierCancla, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Cancla', -text => 'Ceci n\'est pas un fichier .cancla', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } }
etc etcCode:
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278 sub ouvrirLoi { my @types = ( [ "Loi files", '.loi' ], [ "All files", "*" ] ); my $nomFichierLoi = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .loi if ( $nomFichierLoi =~ /(\.loi)$/ ) { open( FICH, "$nomFichierLoi" ) || die("Impossible d'ouvrir $nomFichierLoi"); my @donneLoi = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneLoi); $i++ ) { chomp( $donneLoi[$i] ); } $ligneloi = join( " ", @donneLoi ); creerAfficherLoi( $ligneloi, $nomFichierLoi, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Loi', -text => 'Ceci n\'est pas un fichier .loi', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } sub creerAfficherLoi { my ( $ligneloi, $nomdufichierLoi, $nbelt ) = @_; my $fenetreVisLoi = $fenetre->Toplevel(); $fenetreVisLoi->title("Fichier Loi"); $fenetreVisLoi->raise(); $fenetreVisLoi->maxsize( 670, 710 ); $fenetreVisLoi->minsize( 670, 710 ); $p = 0; $nbelttot = 0; $zoneMenuLoi = $fenetreVisLoi->Frame( -relief => 'groove' ); $zoneMenuLoi->Menubutton( -text => 'Fichier', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrer sous', -command => sub { $nomFichierLoi = $fenetreVisLoi->getSaveFile( -initialdir => '.' ); $lignenumcanal = join( " ", @numcanal ); $lignedate = join( " ", @date ); $ligneloi = join( " ", @loi ); $lignecoef = join( " ", @coef ); $ligneth = join( " ", @th ); $lignetv = join( " ", @tv ); enregistrerLoi( $nbelttot, $lignenumcanal, $lignedate, $ligneloi, $lignecoef, $ligneth, $lignetv, $nomFichierLoi ); $fenetreVisLoi->destroy(); } ], '-', [ 'command' => 'Terminer', -command => sub { $fenetreVisLoi->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuLoi->Menubutton( -text => 'Edition', -relief => 'flat', -tearoff => 0, -menuitems => [ [ 'command' => 'Enregistrement de nouveaux canaux', -command => sub { my $dialogbox = $fenetreVisLoi->DialogBox( -title => 'Nombre de canaux', -buttons => [ 'Valider', 'Annuler' ] ); $dialogbox->add( 'Label', -text => 'Indiquer le nombre de canaux à insérer: ' ) ->pack( -side => 'top' ); my $nbcan; $dialogbox->add( 'Entry', -textvariable => \$nbcan )->pack( -side => 'top' ); my $reponse = $dialogbox->Show(); $nbelttot = $nbelttot + $nbcan; if ( $reponse eq 'Valider' ) { for ( my $j = $nbelt; $j < $nbelttot; $j++ ) { my $visLignes = $fenetreVisLoi->Frame(); $check[$j] = 1; $visLignes->Checkbutton( -variable => \$check[$j], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$numcanal[$j], -background => 'white', -width => 13 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$date[$j], -background => 'white', -width => 4 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$loi[$j], -background => 'white', -width => 5 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$coef[$j], -background => 'white', -width => 14 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$th[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$tv[$j], -background => 'white', -width => 24 )->pack( -side => 'left' ); $visLignes->pack( -fill => 'x' ); } } } ], [ 'command' => 'Supprimer les enregistrements déselectionnés', -command => sub { @ligne2 = (); for ( my $j = 0; $j < $nbelt; $j++ ) { if ( $check[$j] == 1 ) { @ligne2 = ( @ligne2, $numcanal[$j] ); @ligne2 = ( @ligne2, $date[$j] ); @ligne2 = ( @ligne2, $loi[$j] ); @ligne2 = ( @ligne2, $coef[$j] ); @ligne2 = ( @ligne2, $th[$j] ); @ligne2 = ( @ligne2, $tv[$j] ); $p++; } } $lignec = join( " ", @ligne2 ); creerAfficherLoi( $lignec, $nomdufichierLoi, $p ); $fenetreVisLoi->destroy(); } ] ] )->pack( -side => 'left' ); $zoneMenuLoi->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); $fenetreVisLoi->Label( -text => "Pour ajouter de nouveaux enregistrements cliquez sur Edition->Enregistrement de nouveaux canaux \n Pour supprimer les enregistrements décochés cliquez sur Edition->Supprimer les enregistrements déselectionés\n\n Numéro du canal Date Loi Coefficient du lot Taille du voisinage horizontale Taille du voisinage verticale" )->pack( -side => 'top', -anchor => 'n', -fill => 'x' ); @loi = split( / /, $ligneloi ); $nbelttot = $nbelt; for ( my $i = 0; $i < $nbelt; $i++ ) { my $visLignes = $fenetreVisLoi->Frame(); $check[$i] = 1; $visLignes->Checkbutton( -variable => \$check[$i], -offvalue => '0', -onvalue => '1' )->pack( -side => 'left' ); $visLignes->Entry( -textvariable => \$numcanal[$i], -background => 'white', -width => 13 )->pack( -side => 'left' ); $numcanal[$i] = $loi[ 6 * $i ]; $visLignes->Entry( -textvariable => \$date[$i], -background => 'white', -width => 4 )->pack( -side => 'left' ); $date[$i] = $loi[ ( 6 * $i ) + 1 ]; $visLignes->Entry( -textvariable => \$loi[$i], -background => 'white', -width => 5 )->pack( -side => 'left' ); $loi[$i] = $loi[ ( 6 * $i ) + 2 ]; $visLignes->Entry( -textvariable => \$coef[$i], -background => 'white', -width => 14 )->pack( -side => 'left' ); $coef[$i] = $loi[ ( 6 * $i ) + 3 ]; $visLignes->Entry( -textvariable => \$th[$i], -background => 'white', -width => 24 )->pack( -side => 'left' ); $th[$i] = $loi[ ( 6 * $i ) + 4 ]; $visLignes->Entry( -textvariable => \$tv[$i], -background => 'white', -width => 24 )->pack( -side => 'left' ); $tv[$i] = $loi[ ( 6 * $i ) + 5 ]; $visLignes->pack( -fill => 'x' ); } } sub enregistrerLoi { my ( $nbelttot, $lignenumcanal, $lignedate, $ligneloi, $lignecoef, $ligneth, $lignetv, $nomFichierLoi ) = @_; my ( @nc, @d, @l, @c, @lth, @ltv ); if ( $nomFichierLoi !~ /(\.loi)$/ ) { $nomFichierLoi = "$nomFichierLoi.loi"; } @nc = split( / /, $lignenumcanal ); @d = split( / /, $lignedate ); @l = split( / /, $ligneloi ); @c = split( / /, $lignecoef ); @lth = split( / /, $ligneth ); @ltv = split( / /, $lignetv ); open( FICH, ">$nomFichierLoi" ) || die("Impossible d'ouvrir $nomFichierLoi"); for ( my $i = 0; $i < $nbelttot; $i++ ) { print FICH "$nc[$i] $d[$i] $l[$i] $c[$i] $lth[$i] $ltv[$i]\n"; } close(FICH); $zoneRecap->insert( 'end', "Enregistrement de $nomFichierLoi" ); } sub ouvrirCan { my @types = ( [ "Can files", '.can' ], [ "All files", "*" ] ); my $nomFichierCan = $fenetre->getOpenFile( -initialdir => '.', -filetypes => \@types ); #on regarde si le fichier est un .can if ( $nomFichierCan =~ /(\.can)$/ ) { open( FICH, "$nomFichierCan" ) || die("Impossible d'ouvrir $nomFichierCan"); my @donneCan = <FICH>; close(FICH); for ( my $i = 0; $i < scalar(@donneCan); $i++ ) { chomp( $donneCan[$i] ); } $lignecan = join( " ", @donneCan ); creerAfficherCan( $lignecan, $nomFichierCan, $i ); } #sinon on affiche un message d'erreur else { my $boiteDialogue = $fenetre->Dialog( -title => 'Ouvrir Can', -text => 'Ceci n\'est pas un fichier .can', -bitmap => 'question', -default_button => 'OK', -buttons => ['OK'] )->Show(); } } ...
etc etc
Je te remercie de tes corrections djibril, c'est très sympa de ta part de t'en être occupé.
Cependant, si je fais comme tu me dit en mettant toutes mes fonctions APRES le Mainloop, il m'affiche pour chaque variable qu'il rencontre des erreurs de ce type :
C'est erreur ne sont plus présente si je mets mes fonctions avant tout ce qui concerne le Mainloop.Code:Global symbol "$i" requires explicit package name at /home/ducrot/guillaume/perlTITE/fichier4.pl line 1840.
Je sais plus quoi faire là, parce que je vois bien que tu fais ce qu'il faut pour m'aider :cry:.
Je crois que je vais passer pour un imbécile...:oops:JE viens enfin de comprendre pourquoi cela ne marche pas, car pour toutes les variables je n'ai pas précisé de my. J'ai vérifié en le rajoutant devant certaines variables, et celles-ci ne posent plus de problèmes dans la suite du programme...
Donc je pense que tu n'as pas tort en voulant que je mette le Mainloop avant tout le reste, c'est ce que je vais faire.
Merci de ton aide Djibril, je reviendrais s'il y a encore des problèmes (j'espère que non :mrgreen:)
Me revoilà (hélas). J'ai pu corriger 95% de mes erreurs sur tout mon programme, cependant quelques porblèmes subsistent. J'ai par exemple dans une fonction les erreurs suivantes :
Voici le code de la fonction, avec en commentaire le numéro de ligne sur les lignes qui ne passent pas :Code:
1
2
3
4
5
6
7
8
9
10
11
12
13 "my" variable $j masks earlier declaration in same scope at fichier3.pl line 1088. "my" variable @ligne2 masks earlier declaration in same scope at fichier3.pl line 1089. "my" variable @ligne2 masks earlier declaration in same statement at fichier3.pl line 1089. syntax error at fichier3.pl line 1050, near "$check[" syntax error at fichier3.pl line 1056, near "$numcanal[" syntax error at fichier3.pl line 1060, near "$date[" syntax error at fichier3.pl line 1064, near "$loi[" syntax error at fichier3.pl line 1068, near "$coef[" syntax error at fichier3.pl line 1072, near "$th[" syntax error at fichier3.pl line 1076, near "$tv[" syntax error at fichier3.pl line 1087, near "$check[" syntax error at fichier3.pl line 1089, near "$date[" syntax error at fichier3.pl line 1090, near "$loi["
Si vous avez des explications, je suis preneur... ça fait 24h que je me casse la tête...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 sub creerAfficherLoi { my ($ligneloi,$nomdufichierLoi,$nbelt,@check) = @_; my $fenetreVisLoi = $fenetre->Toplevel(); $fenetreVisLoi -> title("Fichier Loi"); $fenetreVisLoi -> raise(); $fenetreVisLoi -> maxsize(670,710); $fenetreVisLoi -> minsize(670,710); my $p=0; my $nbelttot=0; my $zoneMenuLoi = $fenetreVisLoi->Frame( -relief=>'groove'); $zoneMenuLoi->Menubutton( -text=>'Fichier', -relief => 'flat' , -tearoff => 0, -menuitems=>[ ['command' => 'Enregistrer sous', -command=>sub{ my $nomFichierLoi = $fenetreVisLoi -> getSaveFile(-initialdir=>'.'); my $lignenumcanal=join(" ",my @numcanal); my $lignedate=join(" ",my @date); $ligneloi=join(" ",my @loi); my $lignecoef=join(" ",my @coef); my $ligneth=join(" ",my @th); my $lignetv=join(" ",my @tv); enregistrerLoi( $nbelttot,$lignenumcanal,$lignedate,$ligneloi, $lignecoef,$ligneth,$lignetv,$nomFichierLoi); $fenetreVisLoi->destroy(); }], '-', ['command' => 'Terminer', -command=>sub{ $fenetreVisLoi -> destroy() }] ])->pack(-side=>'left'); $zoneMenuLoi->Menubutton( -text=>'Edition', -relief => 'flat' , -tearoff => 0, -menuitems=>[ ['command' => 'Enregistrement de nouveaux canaux', -command=>sub{ my $dialogbox = $fenetreVisLoi -> DialogBox( -title=>'Nombre de canaux', -buttons => [ 'Valider' , 'Annuler' ]); $dialogbox-> add ( 'Label' , -text => 'Indiquer le nombre de canaux à insérer: ')-> pack ( -side => 'top' ) ; my $nbcan; $dialogbox-> add ('Entry' , -textvariable => \$nbcan )-> pack ( -side => 'top' ) ; my $reponse = $dialogbox -> Show ( ) ; $nbelttot=$nbelttot+$nbcan; if($reponse eq 'Valider'){ for(my $j=$nbelt;$j<$nbelttot;$j++){ my $visLignes = $fenetreVisLoi -> Frame(); my $check[$j]=1; $visLignes -> Checkbutton( -variable=>$check[$j],#ligne 1050 -offvalue=>'0', -onvalue=>'1')->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $numcanal[$j],#ligne 1056 -background=>'white', -width=>13)->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $date[$j],#ligne 1060 -background=>'white', -width=>4)->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $loi[$j],#ligne 1064 -background=>'white', -width=>5)->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $coef[$j],#ligne 1068 -background=>'white', -width=>14)->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $th[$j],#ligne 1072 -background=>'white', -width=>24)->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $tv[$j],#ligne 1076 -background=>'white', -width=>24)->pack(-side=>'left'); $visLignes-> pack(-fill=>'x'); } } }], ['command' => 'Supprimer les enregistrements déselectionnés', -command=>sub{ my @ligne2=(); for(my $j=0;$j<$nbelt;$j++){ if(my $check[$j] == 1){#ligne 1087 @ligne2=(@ligne2,my $numcanal[$j]);#ligne 1088 @ligne2=(@ligne2,my $date[$j]);#ligne 1089 @ligne2=(@ligne2,my $loi[$j]);#ligne 1090 @ligne2=(@ligne2,my $coef[$j]); @ligne2=(@ligne2,my $th[$j]); @ligne2=(@ligne2,my $tv[$j]); my $p++; } } my $lignec=join(" ",@ligne2); creerAfficherLoi($lignec,$nomdufichierLoi,$p); $fenetreVisLoi->destroy(); }] ])->pack(-side=>'left'); $zoneMenuLoi->pack( -side=>'top', -anchor=>'n', -fill=>'x'); $fenetreVisLoi -> Label( -text=>"Pour ajouter de nouveaux enregistrements cliquez sur Edition->Enregistrement de nouveaux canaux \n Pour supprimer les enregistrements décochés cliquez sur Edition->Supprimer les enregistrements déselectionés\n\n Numéro du canal Date Loi Coefficient du lot Taille du voisinage horizontale Taille du voisinage verticale")->pack( -side=>'top', -anchor=>'n', -fill=>'x'); @loi=split(/ /,$ligneloi); $nbelttot=$nbelt; for($i=0;$i<$nbelt;$i++){ my $visLignes = $fenetreVisLoi -> Frame(); my $check[$i]=1; $visLignes -> Checkbutton( -variable=>my $check[$i], -offvalue=>'0', -onvalue=>'1')->pack(-side=>'left'); $visLignes -> Entry( -textvariable=>my $numcanal[$i], -background=>'white', -width=>13)->pack(-side=>'left'); $numcanal[$i]=$loi[6*$i]; $visLignes -> Entry( -textvariable=>my $date[$i], -background=>'white', -width=>4)->pack(-side=>'left'); $date[$i]=$loi[(6*$i)+1]; $visLignes -> Entry( -textvariable=>my $loi[$i], -background=>'white', -width=>5)->pack(-side=>'left'); $loi[$i]=$loi[(6*$i)+2]; $visLignes -> Entry( -textvariable=>my $coef[$i], -background=>'white', -width=>14)->pack(-side=>'left'); $coef[$i]=$loi[(6*$i)+3]; $visLignes -> Entry( -textvariable=>my $th[$i], -background=>'white', -width=>24)->pack(-side=>'left'); $th[$i]=$loi[(6*$i)+4]; $visLignes -> Entry( -textvariable=>my $tv[$i], -background=>'white', -width=>24)->pack(-side=>'left'); $tv[$i]=$loi[(6*$i)+5]; $visLignes-> pack(-fill=>'x'); } }
Tes erreurs sont pure Perl et non Perl Tk.
Tu te mélanges dans les déclarations de variables.
Tu ne dois pas écrire
De plus, cette écriture me déplait un peu car toutes les variables sont de toute façon nulle à l'initialisation.Code:
1
2
3
4
5
6 my $check[$j]=1; ... my $tv[$j] ... my $tv[$j] ...
Donc j'écrirais ainsi :Code:
1
2
3
4
5
6 my $lignenumcanal = join( " ", my @numcanal ); my $lignedate = join( " ", my @date ); $ligneloi = join( " ", my @loi ); my $lignecoef = join( " ", my @coef ); my $ligneth = join( " ", my @th ); my $lignetv = join( " ", my @tv );
Ensuite partout ou tu as mis my $numcanal[$j], il faut mettre plutot $numcanal[$j].Code:
1
2
3
4
5 my ( @numcanal, @date, @loi, @coef, @th, @tv ) = (); my ( $lignenumcanal, $lignedate, $lignecoef, $ligneth, $lignetv ) = (); $ligneloi = join( " ", @loi );
Par contre tu auras toujours un souci car à aucun moment dans ton script tu as remplit le tableau @numcanal, idem pour les autres.
Pour rajouter des données dans un tableau, il faut utiliser push.
Voilà, avec ces infos, débogue ton script
Bonjour !
Eh bien cela faisait longtemps que je n'étais pas venu, mais j'attendais de voir si des grosses erreurs ne venaient pas pourrir mon code :mrgreen:.
Je viens de finir les dernières corrections pour les variables non déclarés, et miracle, je n'ai plus d'erreurs !!! Certes mon code aurait je pense pu être plus simple, mais n'ayant pas d'énormes connaissance en Perl j'ai fait avec les moyens du bord.
Maintenant que ce sujet est résolu, je souhaiterais remercier tous ceux qui ont essayé de m'aider, que ce soit activement (Djibril), mais je pense aussi aux personnes qui ont certainement essayer de m'aider mais qui n'ont pas trouver de solution.
Merci beaucoup à tous !