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

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

Programmation et administration système Perl Discussion :

Pobléme affichage avec le padding


Sujet :

Programmation et administration système Perl

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    Points : 104
    Points
    104
    Par défaut Pobléme affichage avec le padding
    J'ai un probléme d'affichage d'une valeur !

    Je veux qu'elle est le format en sortie avec un padding de 11 ( complété par des 0).

    voila mon script :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
     
    $sql = qq{select FCP.FCP_MANUEL_SAISIES.DATE_OP, 
    			fcp.FCP_MANUEL_SAISIES.c_etab, 
    			fcp.FCP_MANUEL_SAISIES.c_agence, 
    			fcp.FCP_MANUEL_SAISIES.n_contrat,
    			fcp.FCP_MANUEL_SAISIES.c_isin, 
    			fcp.FCP_MANUEL_SAISIES.MONTANT
    		from fcp.FCP_MANUEL_SAISIES
    		};
     
    #######################La requete sql#########
     
     
    while(@dat = $st->fetchrow)	{
    		$ligne=$dat[0];
    		for ($i=0;$i<=@dat;$i++) {
     
     
     
    			if ($i == 5) {
     
    				printf "Test1 : ".$dat[5]."\n" ;
    				$montantPadding = $dat[5] ;
    				$montantPadding =~ s/,+/ /;	
    				$montantPadding =~ s/\s+//g;
    				$montantPadding = printf("%011d\n", $montantPadding) ;	
    				printf $montantPadding."\n" ;
    				$dat[5] = $montantPadding ;
     
     
    				printf "dat[5] = ".$dat[5]."\n" ;
     
    			}
    			#printf $dat[5]."\n" ;
     
    			$ligne=$ligne.";".$dat[$i];
     
    		}
     
    		$compteurLigne = $compteurLigne + 1 ; 	
    		$entete = printf("%.02d;", 24) ;
    		$cptLigne = printf("%.06d;", $compteurLigne) ;	
    		$codeStructure = printf("%.02d;", 60) ;				
    		$ligne=$ligne."\n";
     
    		print FCP_MANUEL_SAISIES $ligne;
    	}
    }
    Da boucle du for, dans le test je veuc avoir en sorti pour la commande suivante
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    printf $montantPadding."\n" ;
    juste le nomtant avec le padding.

    Sauf que je récupére un 1 en plus !

    Je ne vois pas d'où peux venir l'erreur, est ce qu'une personne aurait une idée la dessus !

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    264
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 264
    Points : 104
    Points
    104
    Par défaut
    C'est bon j'ai trouvé , erreur de formatage

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    while(@dat = $st->fetchrow)	{
    		$ligne="";
    		#printf $ligne."\n" ;
    		for ($i=0;$i<@dat-1;$i++) {
     
     
    			#$ligne=$ligne.";".$dat[$i];
    			$ligne=$ligne.";".$dat[$i];
    		}
    		#$ligne= $ligne."                                                                                                                               ";
    		$compteurLigne = $compteurLigne + 1 ; 
    		$entete = printf("%.02d;", 24) ;		
    		$cptLigne = sprintf("%.06d;", $compteurLigne) ;
    		$NB_MOUV = $cptLigne ; 
    		$NB_MOUV = printf("%.06d;",$NB_MOUV) ;
    		$codeStructure = printf("%.02d;", 60) ;
     
    		#$ligne=$ligne."\n";			
     
    			$montantPadding = $dat[6] ;
    			$montantPadding =~ s/,+/ /;	
    			$montantPadding =~ s/\s+//g;
    			$montantPadding = sprintf("%.11d", $montantPadding) ;	
    			$ligne = $ligne.";".$montantPadding ;
     
    		$ligne = $ligne.";".$montantPadding."\n" ;		
     
    		print FCP_MANUEL_SAISIES $ligne;
    	}
     
     
    	$cptLigne = $cptLigne + 1 ;
    	$cptLigne = sprintf("%.06d", $cptLigne) ;
    	$NB_MOUV = sprintf("%.07d", $cptLigne -2 ) ;
    Pour ceux qui veulent @++

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

Discussions similaires

  1. problème d'affichage avec printf
    Par sorari dans le forum C++
    Réponses: 12
    Dernier message: 08/03/2005, 18h30
  2. Réponses: 6
    Dernier message: 19/10/2004, 13h46
  3. Resolution d'affichage avec x11
    Par cosmos38240 dans le forum Applications et environnements graphiques
    Réponses: 4
    Dernier message: 06/06/2004, 23h26
  4. Pb affichage avec un PaintBox (pour eviter scintillement)
    Par juan64 dans le forum C++Builder
    Réponses: 7
    Dernier message: 08/04/2004, 09h21
  5. Problème d'affichage avec trace
    Par WriteLN dans le forum Flash
    Réponses: 10
    Dernier message: 22/10/2003, 16h59

Partager

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