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

Langage Delphi Discussion :

Boucle et booléen


Sujet :

Langage Delphi

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut Boucle et booléen
    Bonjour,

    Voici mon code :

    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
     
      // On recherche les commandes dont le TCD est à 8 :
      oq_Tcd8.Close; oq_Tcd8.SQL.Clear;
      oq_Tcd8.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT=''P''');
      oq_Tcd8.SQL.Add('and TCDXENT=''8'' and LDCXENT=''Y'' group by CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT');
      TestRequete1(oq_Tcd8, 'OPENREQ', 'Echec sélection TCD8 (UnitChgtML - 001)', os_Session);
     
     
      // On recherche toutes les commandes dont le TCD = 3
      oq_Tcd3.Close; oq_Tcd3.SQL.Clear;
      oq_Tcd3.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+''' and TCDXENT=''3''');
      oq_Tcd3.SQL.Add('and CHGXENT <> ''Y'' and LDCXENT=''Y'' ORDER BY CHGXENT DESC');
      TestRequete1(oq_Tcd3, 'OPENREQ', 'Echec sélection TCD3 (UnitChgtML - 002)', os_Session);
     
      if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          if (oq_Tcd8.FieldAsString('CHGXENT') = 'S') or (oq_Tcd8.FieldAsString('CHGXENT') = 'P') then
          begin
            x_cmd := '';
            b_RecupDonnees := True;
            b_RecupList := True;                // Ne prend que celui-ci pq ?
            b_RecupNbCmd := True;
          end
          else
          begin
            b_RecupList := True
          end;
        end;...
    Mon problème se trouve dans le commentaire si je me met en pas à pas je me rend compte qu'il n'y a que mon booléen b_recupList qui est passé à True, le programme ne passe pas sur b_RecupDonnees ni sur b_RecupNbCmd alors qu'ils sont soit juste avant soit juste après...

    Je ne comprend pas...
    Windows XP
    Delphi 7

    WinDev Mobile 17

  2. #2
    Membre expérimenté
    Avatar de retwas
    Homme Profil pro
    Développeur Java/Delphi
    Inscrit en
    Mars 2010
    Messages
    698
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 32
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Développeur Java/Delphi
    Secteur : Finance

    Informations forums :
    Inscription : Mars 2010
    Messages : 698
    Points : 1 608
    Points
    1 608
    Billets dans le blog
    4
    Par défaut
    Je pense que tu passe dans le else ou il y a uniquement b_RecupList de mis a true

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Non non, pourtant, je passe bien dans le if et sur cette ligne :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    b_RecupList := True;                // Ne prend que celui-ci pq ?
    Mais pas sur les deux autres...

    J'ai même rajouté un autre booléen :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    b_GenerationList := False;                         // prend celui ci aussi
    Et là aussi on passe bien sur cette ligne mais pas sur les deux autres...
    Windows XP
    Delphi 7

    WinDev Mobile 17

  4. #4
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 046
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 046
    Points : 40 962
    Points
    40 962
    Billets dans le blog
    62
    Par défaut
    bonjour,

    c'est peut être du a une 'optimisation' du compilateur ?
    il suffit que ces deux variables ne soit pas utilisées et
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  5. #5
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    J'aimerai bien mais non ces variables sont bien utilisées je fais un if sur chacun des booléens juste en dessous du code que je vous ai copié ...
    Windows XP
    Delphi 7

    WinDev Mobile 17

  6. #6
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2012
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2012
    Messages : 92
    Points : 159
    Points
    159
    Par défaut
    le mieux, c'est que tu copies/colles ta fonction au complet pour éviter d'avoir des réponses erronées même si elles peuvent être bonnes

  7. #7
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
     Try
      // On recherche les commandes dont le TCD est à 8 :
      oq_Tcd8.Close; oq_Tcd8.SQL.Clear;
      oq_Tcd8.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT=''P''');
      oq_Tcd8.SQL.Add('and TCDXENT=''8'' and LDCXENT=''Y'' group by CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT');
      TestRequete1(oq_Tcd8, 'OPENREQ', 'Echec sélection TCD8 (UnitChgtML - 001)', os_Session);
     
     
      // On recherche toutes les commandes dont le TCD = 3
      oq_Tcd3.Close; oq_Tcd3.SQL.Clear;
      oq_Tcd3.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+''' and TCDXENT=''3''');
      oq_Tcd3.SQL.Add('and CHGXENT <> ''Y'' and LDCXENT=''Y'' ORDER BY CHGXENT DESC');
      TestRequete1(oq_Tcd3, 'OPENREQ', 'Echec sélection TCD3 (UnitChgtML - 002)', os_Session);
     
        if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          if (oq_Tcd8.FieldAsString('CHGXENT') = 'S') or (oq_Tcd8.FieldAsString('CHGXENT') = 'P') then
          begin
            x_cmd := '';
     
            b_RecupList := True;                // Ne prend que celui-ci pq ?
            b_GenerationList := False;                         // prend celui ci aussi
     
            b_RecupNbCmd := True;
            b_RecupDonnees := True;
          end
          else
          begin
            b_RecupList := True
          end;
        end;
        If not oq_Tcd3.Eof then
        begin
          x_cmd := oq_Tcd3.FieldasString('CDEXENT');
          x_chg := oq_Tcd3.FieldasString('CHGXENT');
          x_tcd := oq_Tcd3.FieldasString('TCDXENT');
          if oq_Tcd3.FieldAsString('CHGXENT') = 'S' then
          begin
            b_RecupDonnees := True;
            b_RecupList := True;
            b_RecupNbCmd := True;
          end
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'P' then
          begin
            b_RecupDonnees := True;
            b_GenerationList := True;
            b_RecupNbCmd := True;
          end
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'N' then
          begin
            x_cmd := '';
            b_GenerationList := True;
            // JA : 24/10/13 : Rajout des 3 affectations suivantes, pour ne pas passer dans des conditions inutiles
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
          else
          begin
            envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
            maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
            exit;
          end;
        end
        else
        begin
          envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
          maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
          exit;
        end;
     
      if b_RecupNbCmd then
      begin
        oq_NbCmdCharge.Close; oq_NbCmdCharge.SQL.Clear;
        oq_NbCmdCharge.SQL.Add('Select count(*) as TOTAL from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT='''+x_chg+''' and TCDXENT='''+x_tcd+''' and ');
        oq_NbCmdCharge.SQL.Add('LDCXENT=''Y''');
        TestRequete1(oq_NbCmdCharge, 'OPENREQ', 'Echec calcul cmd en cours de chgt(UnitChgtML - 026)', os_Session);
        if not oq_NbCmdCharge.Eof then
          n_CmdEnCours := oq_NbCmdCharge.FieldAsInteger('TOTAL')
        else                                                                           // plus besoin ?
          n_CmdEnCours := 0;
      end;
     
      oq_CmdACharger.Close; oq_CmdACharger.SQL.Clear;
      oq_CmdACharger.SQL.Add('select TOUXCHG, CDEXCHG, LISXCHG, ACTXCHG from CHGXRES where CDEXCHG='''+x_cmd+'''');
      oq_CmdACharger.SQL.Add('and DEPXCHG='''+x_dep+'''');
      TestRequete1(oq_CmdACharger, 'OPENREQ', 'Echec récupération données(UnitChgtML - 003)', os_Session);
      if not oq_CmdACharger.Eof then             // if rajoutée par JA le 21/06/2013
      begin
        if b_RecupList then
        begin
          if x_aEnvoyer = '' then
          begin
            x_aEnvoyer := oq_CmdACharger.FieldAsString('LISXCHG');
            x_typeEnvoi := 'A';
          end
          else
            x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('LISXCHG');          //récup liste chgt
        end;
      end;
      if b_RecupDonnees then
      begin
        {*oq_NbPal.Close;
        oq_NbPal.SQL.Clear;
        // JA : 23/04/13 : Modif suite ajouts champs LNUXUCM, LLIXUCM, LORXUCM dans UCMXRES
        oq_NbPal.SQL.Add('select count(distinct(CUMXUCM)) as TOT from UCMXRES where LNUXUCM='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
          n_nbPal := oq_NbPal.FieldAsInteger('TOT')
        else
          n_nbPal := 0;
     
        oq_NbPalLues.Close;
        oq_NbPalLues.SQL.Clear;
        oq_NbPalLues.SQL.Add('select count(distinct(CUMXUCM)) as TOT from UCMXRES where LNUXUCM='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400''');
        if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005)', os_Session) then
          n_nbPalLues := oq_NbPalLues.FieldAsInteger('TOT')
        else
          n_nbPalLues := 0;      *}
     
        //JA 05/11/2013 : Modification calcul nb pal lues et nb pal à charger pour que les UMS soient pris en compte
        //Récupération du nombre de palette UM à charger pour la commande
        oq_NbPal.Close; oq_NbPal.SQL.Clear;
        oq_NbPal.SQL.Add('Select Count(distinct(CUMXUCM)) NBUM from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380'' and CUMXUCM<>''0''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
          n_nbPal := oq_NbPal.FieldAsInteger('NBUM')
        else
          n_nbPal := 0;
     
        //Récupération du nombre de palettes UMS à charger pour la commande
        oq_NbPal1.Close; oq_NbPal1.SQL.Clear;
        oq_NbPal1.SQL.Add('Select Count(distinct(CUCXUCM)) NBUMS from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380'' and CUMXUCM=''0''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004(2))', os_Session) then
          n_nbPal := n_nbPal + oq_NbPal1.FieldAsInteger('NBUMS');
     
        //Récupération du nombre de palettes déjà chargées pour la commande
        oq_NbPalLues.Close; oq_NbPalLues.SQL.Clear;
        oq_NbPalLues.SQL.Add('Select Count(distinct(CUMXUCM)) NBPALLUUM from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400'' and CUMXUCM<>''0''');
        if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005(2))', os_Session) then
          n_nbPalLues := oq_NbPalLues.FieldAsInteger('NBPALLUUM')
        else
          n_nbPalLues := 0;
     
        //Récupération du nombre de palettes UMS déjà chargées pour la commande
        oq_NbPalLues1.Close; oq_NbPalLues1.SQL.Clear;
        oq_NbPalLues1.SQL.Add('Select Count(distinct(CUCXUCM)) NBPALLUUMS from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400'' and CUMXUCM=''0''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb pal lues(UnitChgtML - 005)', os_Session) then
          n_nbPalLues := n_nbPalLues + oq_NbPalLues1.FieldAsInteger('NBPALLUUMS');
     
        if x_aEnvoyer = '' then
        begin
          n_nbPalLues := 0; // BI 26-27-28/03/2013
          x_aEnvoyer := oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'C';
        end
        else
        begin
          x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'B';
        end;
      end;
      if b_GenerationList then
      begin
        x_listCharge := GenerationList(x_user, x_AdIp, '1', x_mod, x_action, os_session, ss_sock, n_idConnect, m_TraceServeur);
        if x_aEnvoyer = '' then
        begin
          x_aEnvoyer := x_listCharge;
          x_typeEnvoi := 'D';
        end
        else
        begin
          x_aEnvoyer := x_aEnvoyer +TAB+ x_listCharge;
          x_typeEnvoi := 'C';
        end;
      end;
     
      maj_raoxres(x_User, x_lec, x_Mod, x_Action, x_cmd, '', '', x_dep,'' , 'CHGT ML - Renvoi des infos OK', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'N', 'N', 'N', 'A', os_Session);
      envoiMsgSocket(n_idConnect, x_dep, x_typeEnvoi + TAB+ IntToStr(n_CmdEnCours) +TAB+ x_aEnvoyer, ss_Sock, m_TraceServeur);
     
     Finally
    Windows XP
    Delphi 7

    WinDev Mobile 17

  8. #8
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2012
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2012
    Messages : 92
    Points : 159
    Points
    159
    Par défaut
    wha !!!

    quelle est la valeur d’initialisation pour :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
            b_RecupList 
            b_GenerationList 
     
            b_RecupNbCmd 
            b_RecupDonnees
    trop de boolean tue le boolean

    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
     
        if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          if (oq_Tcd8.FieldAsString('CHGXENT') = 'S') or (oq_Tcd8.FieldAsString('CHGXENT') = 'P') then
          begin
            b_RecupList := True;                // Ne prend que celui-ci pq ?
          end
          else
          begin
            b_RecupList := True
          end;
        end;
    c'est la même chose que ça ?
    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
     
        if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
     
          if (x_chg = 'S') or (x_chg = 'P') then
          begin
            x_cmd := '';
     
            b_GenerationList := False;                         // prend celui ci aussi
     
            b_RecupNbCmd := True;
            b_RecupDonnees := True;
          end;
     
          b_RecupList := True
        end;
    si ta valeur par d'initialisation pour
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    b_RecupDonnees := True;
    tu peux supprimer partout
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    b_RecupDonnees := True;
    pour ne laisser que le
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    b_RecupDonnees := False;
    et ceci permettra d'alléger ton code.
    pareil pour les autres variables


    pourquoi tous ces champs
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    oq_CmdACharger.SQL.Add('select TOUXCHG, CDEXCHG, LISXCHG, ACTXCHG from CHGXRES where CDEXCHG='''+x_cmd+'''');
    si ce n'est que pour utiliser
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    x_aEnvoyer := oq_CmdACharger.FieldAsString('LISXCHG');
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('LISXCHG');
    EDIT :
    j'ai vu : beaucoup plus loin
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
     if x_aEnvoyer = '' then
        begin
          n_nbPalLues := 0; // BI 26-27-28/03/2013
          x_aEnvoyer := oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'C';
        end
    donc ignore ma remarque sur les champs non utilisés

  9. #9
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    b_RecupDonnees := False;
    b_RecupList := False;
    b_GenerationList := False;
    b_RecupNbCmd := False;
    Oui oui c'est bien la même chose ...
    Windows XP
    Delphi 7

    WinDev Mobile 17

  10. #10
    Membre habitué
    Inscrit en
    Juillet 2007
    Messages
    113
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Juillet 2007
    Messages : 113
    Points : 170
    Points
    170
    Par défaut
    Citation Envoyé par SergioMaster Voir le message
    bonjour,

    c'est peut être du a une 'optimisation' du compilateur ?
    il suffit que ces deux variables ne soit pas utilisées et
    Dans la suite de ton code tu fais :
    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
     If not oq_Tcd3.Eof then
        begin
          ...
          if oq_Tcd3.FieldAsString('CHGXENT') = 'S' then
          begin
            b_RecupDonnees := True;
            b_RecupList := True;
            b_RecupNbCmd := True;
          end
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'P' then
          begin
            b_RecupDonnees := True;
            b_GenerationList := True;
            b_RecupNbCmd := True;
          end
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'N' then
          begin
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
          else
          begin
            ...
            exit;
          end;
    J'ai un peut nettoyer ci-dessus, mais en gros dans le bloc suivant (If not oq_Tcd3.Eof) tu écrase les valeurs dans ces variables dans tous les cas et si tu ne passe pas dans ce bloc, tu vas dans le else ou tu fais un exit de ta fonction... donc ta première affectation de valeur n'est jamais utilisée et donc SergioMaster a raison, c'est l'optimisation.

  11. #11
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Citation Envoyé par tenpigs Voir le message
    Dans la suite de ton code tu fais :
    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
     If not oq_Tcd3.Eof then
        begin
          ...
          if oq_Tcd3.FieldAsString('CHGXENT') = 'S' then
          begin
            b_RecupDonnees := True;
            b_RecupList := True;
            b_RecupNbCmd := True;
          end
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'P' then
          begin
            b_RecupDonnees := True;
            b_GenerationList := True;
            b_RecupNbCmd := True;
          end
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'N' then
          begin
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
          else
          begin
            ...
            exit;
          end;
    J'ai un peut nettoyer ci-dessus, mais en gros dans le bloc suivant (If not oq_Tcd3.Eof) tu écrase les valeurs dans ces variables dans tous les cas et si tu ne passe pas dans ce bloc, tu vas dans le else ou tu fais un exit de ta fonction... donc ta première affectation de valeur n'est jamais utilisée et donc SergioMaster a raison, c'est l'optimisation.


    Mais dans cette partie là :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'N' then
          begin
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
    Il faut bien que je passe mon :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            x_cmd := '';
            b_GenerationList := True;
    non ? C'est tout ce que tu as enlevé ?
    Windows XP
    Delphi 7

    WinDev Mobile 17

  12. #12
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2012
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2012
    Messages : 92
    Points : 159
    Points
    159
    Par défaut
    Citation Envoyé par juju1988 Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    b_RecupDonnees := False;
    b_RecupList := False;
    b_GenerationList := False;
    b_RecupNbCmd := False;
    Oui oui c'est bien la même chose ...
    personnellement, dans ton cas, je ferai le contraire.
    j'initialise à true, et je met à false que si necessaire.
    cela permettrait de diminuer le nb de ligne et ainsi gagner en fluidité de lecture et de compréhension du code.

    de plus, j'essayerai de ne faire qu'une seule requête.
    exemple : pour oq_NbPalLues et oq_NbPalLues1, tu peux faire fusionner

    le fait de ne pas connaitre tes données, je me demande pourquoi par exemple x_cmd est pris sur oq_Tcd8 et sur oq_Tcd3 et pourquoi il est effacé

    pourquoi stocker des valeurs si elles ne sont pas utilisées aprés pour les tests ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    x_cmd := oq_Tcd8.FieldasString('CDEXENT');
    x_chg := oq_Tcd8.FieldasString('CHGXENT');
    x_tcd := oq_Tcd8.FieldasString('TCDXENT');
    if (oq_Tcd8.FieldAsString('CHGXENT') = 'S') or (oq_Tcd8.FieldAsString('CHGXENT') = 'P') then
    deviendrait

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    x_cmd := oq_Tcd8.FieldasString('CDEXENT');
    x_chg := oq_Tcd8.FieldasString('CHGXENT');
    x_tcd := oq_Tcd8.FieldasString('TCDXENT');
    if (x_chg = 'S') or (x_chg = 'P') then

    sur ce code là :
    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
     
    oq_CmdACharger.Close; oq_CmdACharger.SQL.Clear;
      oq_CmdACharger.SQL.Add('select TOUXCHG, CDEXCHG, LISXCHG, ACTXCHG from CHGXRES where CDEXCHG='''+x_cmd+'''');
      oq_CmdACharger.SQL.Add('and DEPXCHG='''+x_dep+'''');
      TestRequete1(oq_CmdACharger, 'OPENREQ', 'Echec récupération données(UnitChgtML - 003)', os_Session);
      if not oq_CmdACharger.Eof then             // if rajoutée par JA le 21/06/2013
      begin
        if b_RecupList then
        begin
          if x_aEnvoyer = '' then
          begin
            x_aEnvoyer := oq_CmdACharger.FieldAsString('LISXCHG');
            x_typeEnvoi := 'A';
          end
          else
            x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('LISXCHG');          //récup liste chgt
        end;
      end;
    ou est initialisé x_aEnvoyer ?
    pourquoi x_typeEnvoi est initialisé seulement si x_aEnvoyer = ''
    parce que dans le contexte je ne comprends pas.

    donc soit le code que tu donnes est très incomplet, soit ....
    en gros, un petit travail de ré-écriture permettrait de mieux comprendre

  13. #13
    Membre habitué
    Inscrit en
    Juillet 2007
    Messages
    113
    Détails du profil
    Informations personnelles :
    Âge : 40

    Informations forums :
    Inscription : Juillet 2007
    Messages : 113
    Points : 170
    Points
    170
    Par défaut
    Citation Envoyé par juju1988 Voir le message
    Mais dans cette partie là :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
          else if oq_Tcd3.FieldAsString('CHGXENT') = 'N' then
          begin
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
    Il faut bien que je passe mon :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
            x_cmd := '';
            b_GenerationList := True;
    non ? C'est tout ce que tu as enlevé ?
    j'ai juste nettoyé pour montrer que dans ton code tu écrases toujours le contenu des variables b_RecupDonnees et b_RecupNbCmd. Donc le compilateur optimise le code généré en ne faisant pas les premières affectation

  14. #14
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Voici mon code complet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    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
    //
    //  CU02 : Vérif code déposant + verif si cmd en cours de chargement
    //
    procedure VerifDep(x_AdIp : string; x_User :string; x_dep : string; x_Mod : string; x_Action : string; os_Session : TOracleSession; ss_Sock : TServerSocket; n_idConnect : integer; m_TraceServeur : TMemo);
    var
      oq_Tcd8, oq_Tcd3, oq_CmdACharger, oq_NbPal,oq_NbPal1, oq_NbPalLues,oq_NbPalLues1, oq_NbCmdCharge : TOracleQuery;
      x_cmd, x_tournee, x_listCharge, x_aEnvoyer, x_lec, x_typeEnvoi, x_chg, x_tcd : string;
      b_RecupDonnees, b_RecupList, b_GenerationList, b_RecupNbCmd : boolean;
      n_nbPal, n_nbPalLues, n_CmdEnCours : integer;
    begin
    x_cmd := '';
    x_tournee := '';
    x_listCharge := '';
    x_cmd := '';
    x_aEnvoyer := '';
    x_listCharge := '';
    x_typeEnvoi := '';
    n_nbPal := 0;
    n_nbPalLues := 0;
    n_CmdEnCours := 0;
    b_RecupDonnees := False;
    b_RecupList := False;
    b_GenerationList := False;
    b_RecupNbCmd := False;
    oq_Tcd8:=TOracleQuery.Create(Nil); oq_Tcd8.Session := os_Session;
    oq_Tcd3:=TOracleQuery.Create(Nil); oq_Tcd3.Session := os_Session;
    oq_CmdACharger:=TOracleQuery.Create(Nil); oq_CmdACharger.Session := os_Session;
    oq_NbPal:=TOracleQuery.Create(Nil); oq_NbPal.Session := os_Session;
    oq_NbPal1:=TOracleQuery.Create(Nil); oq_NbPal1.Session := os_Session;
    oq_NbPalLues:=TOracleQuery.Create(Nil); oq_NbPalLues.Session := os_Session;
    oq_NbPalLues1:=TOracleQuery.Create(Nil); oq_NbPalLues1.Session := os_Session;
    oq_NbCmdCharge:=TOracleQuery.Create(Nil); oq_NbCmdCharge.Session := os_Session;
     
    zx_dejaPasse := 'N';
     
    x_lec := RetourneNomScan(x_AdIp, os_Session);
     Try
      // On recherche les commandes dont le TCD est à 8 :
      oq_Tcd8.Close; oq_Tcd8.SQL.Clear;
      oq_Tcd8.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT=''P''');
      oq_Tcd8.SQL.Add('and TCDXENT=''8'' and LDCXENT=''Y'' group by CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT');
      TestRequete1(oq_Tcd8, 'OPENREQ', 'Echec sélection TCD8 (UnitChgtML - 001)', os_Session);
     
     
      // On recherche toutes les commandes dont le TCD = 3
      oq_Tcd3.Close; oq_Tcd3.SQL.Clear;
      oq_Tcd3.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+''' and TCDXENT=''3''');
      oq_Tcd3.SQL.Add('and CHGXENT <> ''Y'' and LDCXENT=''Y'' ORDER BY CHGXENT DESC');
      TestRequete1(oq_Tcd3, 'OPENREQ', 'Echec sélection TCD3 (UnitChgtML - 002)', os_Session);
     
        if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          if (x_chg = 'S') or (x_chg = 'P') then
          begin
            x_cmd := '';
     
            b_RecupList := True;                // Ne prend que celui-ci pq ?
            b_GenerationList := False;                         // prend celui ci aussi
     
            b_RecupNbCmd := True;
            b_RecupDonnees := True;
          end
          else
          begin
            b_RecupList := True
            b_GenerationList := False;
     
            b_RecupNbCmd := False;
            b_RecupDonnees := False;
          end;
        end;
        If not oq_Tcd3.Eof then
        begin
          x_cmd := oq_Tcd3.FieldasString('CDEXENT');
          x_chg := oq_Tcd3.FieldasString('CHGXENT');
          x_tcd := oq_Tcd3.FieldasString('TCDXENT');
          if oq_Tcd3.FieldAsString('CHGXENT') = 'S' then
          begin
            b_RecupDonnees := True;
            b_RecupList := True;
            b_RecupNbCmd := True;
          end
          else if x_chg = 'P' then
          begin
            b_RecupDonnees := True;
            b_GenerationList := True;
            b_RecupNbCmd := True;
          end
          else if x_chg = 'N' then
          begin
            x_cmd := '';
            b_GenerationList := True;
            // JA : 24/10/13 : Rajout des 3 affectations suivantes, pour ne pas passer dans des conditions inutiles
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
          else
          begin
            b_RecupList := False;
            b_GenerationList := False;
     
            b_RecupNbCmd := False;
            b_RecupDonnees := False;
            envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
            maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
            exit;
          end;
        end
        else
        begin
          envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
          maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
          exit;
        end;
     
      if b_RecupNbCmd then
      begin
        oq_NbCmdCharge.Close; oq_NbCmdCharge.SQL.Clear;
        oq_NbCmdCharge.SQL.Add('Select count(*) as TOTAL from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT='''+x_chg+''' and TCDXENT='''+x_tcd+''' and ');
        oq_NbCmdCharge.SQL.Add('LDCXENT=''Y''');
        TestRequete1(oq_NbCmdCharge, 'OPENREQ', 'Echec calcul cmd en cours de chgt(UnitChgtML - 026)', os_Session);
        if not oq_NbCmdCharge.Eof then
          n_CmdEnCours := oq_NbCmdCharge.FieldAsInteger('TOTAL')
        else                                                                           // plus besoin ?
          n_CmdEnCours := 0;
      end;
     
      oq_CmdACharger.Close; oq_CmdACharger.SQL.Clear;
      oq_CmdACharger.SQL.Add('select TOUXCHG, CDEXCHG, LISXCHG, ACTXCHG from CHGXRES where CDEXCHG='''+x_cmd+'''');
      oq_CmdACharger.SQL.Add('and DEPXCHG='''+x_dep+'''');
      TestRequete1(oq_CmdACharger, 'OPENREQ', 'Echec récupération données(UnitChgtML - 003)', os_Session);
      if not oq_CmdACharger.Eof then             // if rajoutée par JA le 21/06/2013
      begin
        if b_RecupList then
        begin
          if x_aEnvoyer = '' then
          begin
            x_aEnvoyer := oq_CmdACharger.FieldAsString('LISXCHG');
            x_typeEnvoi := 'A';
          end
          else
            x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('LISXCHG');          //récup liste chgt
        end;
      end;
      if b_RecupDonnees then
      begin
        {*oq_NbPal.Close;
        oq_NbPal.SQL.Clear;
        // JA : 23/04/13 : Modif suite ajouts champs LNUXUCM, LLIXUCM, LORXUCM dans UCMXRES
        oq_NbPal.SQL.Add('select count(distinct(CUMXUCM)) as TOT from UCMXRES where LNUXUCM='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
          n_nbPal := oq_NbPal.FieldAsInteger('TOT')
        else
          n_nbPal := 0;
     
        oq_NbPalLues.Close;
        oq_NbPalLues.SQL.Clear;
        oq_NbPalLues.SQL.Add('select count(distinct(CUMXUCM)) as TOT from UCMXRES where LNUXUCM='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400''');
        if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005)', os_Session) then
          n_nbPalLues := oq_NbPalLues.FieldAsInteger('TOT')
        else
          n_nbPalLues := 0;      *}
     
        //JA 05/11/2013 : Modification calcul nb pal lues et nb pal à charger pour que les UMS soient pris en compte
        //Récupération du nombre de palette UM à charger pour la commande
        oq_NbPal.Close; oq_NbPal.SQL.Clear;
        oq_NbPal.SQL.Add('Select Count(distinct(CUMXUCM)) NBUM from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380'' and CUMXUCM<>''0''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
          n_nbPal := oq_NbPal.FieldAsInteger('NBUM')
        else
          n_nbPal := 0;
     
        //Récupération du nombre de palettes UMS à charger pour la commande
        oq_NbPal1.Close; oq_NbPal1.SQL.Clear;
        oq_NbPal1.SQL.Add('Select Count(distinct(CUCXUCM)) NBUMS from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''380'' and CUMXUCM=''0''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004(2))', os_Session) then
          n_nbPal := n_nbPal + oq_NbPal1.FieldAsInteger('NBUMS');
     
        //Récupération du nombre de palettes déjà chargées pour la commande
        oq_NbPalLues.Close; oq_NbPalLues.SQL.Clear;
        oq_NbPalLues.SQL.Add('Select Count(distinct(CUMXUCM)) NBPALLUUM from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400'' and CUMXUCM<>''0''');
        if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005(2))', os_Session) then
          n_nbPalLues := oq_NbPalLues.FieldAsInteger('NBPALLUUM')
        else
          n_nbPalLues := 0;
     
        //Récupération du nombre de palettes UMS déjà chargées pour la commande
        oq_NbPalLues1.Close; oq_NbPalLues1.SQL.Clear;
        oq_NbPalLues1.SQL.Add('Select Count(distinct(CUCXUCM)) NBPALLUUMS from UCMXRES where LNUXUCM ='''+oq_Tcd3.FieldAsString('NUMXENT')+''' and ETAXUCM=''400'' and CUMXUCM=''0''');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb pal lues(UnitChgtML - 005)', os_Session) then
          n_nbPalLues := n_nbPalLues + oq_NbPalLues1.FieldAsInteger('NBPALLUUMS');
     
        if x_aEnvoyer = '' then
        begin
          n_nbPalLues := 0; // BI 26-27-28/03/2013
          x_aEnvoyer := oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'C';
        end
        else
        begin
          x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'B';
        end;
      end;
      if b_GenerationList then
      begin
        x_listCharge := GenerationList(x_user, x_AdIp, '1', x_mod, x_action, os_session, ss_sock, n_idConnect, m_TraceServeur);
        if x_aEnvoyer = '' then
        begin
          x_aEnvoyer := x_listCharge;
          x_typeEnvoi := 'D';
        end
        else
        begin
          x_aEnvoyer := x_aEnvoyer +TAB+ x_listCharge;
          x_typeEnvoi := 'C';
        end;
      end;
     
      maj_raoxres(x_User, x_lec, x_Mod, x_Action, x_cmd, '', '', x_dep,'' , 'CHGT ML - Renvoi des infos OK', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'N', 'N', 'N', 'A', os_Session);
      envoiMsgSocket(n_idConnect, x_dep, x_typeEnvoi + TAB+ IntToStr(n_CmdEnCours) +TAB+ x_aEnvoyer, ss_Sock, m_TraceServeur);
     
     Finally
      oq_Tcd8.Close; oq_Tcd8.Free;
      oq_Tcd3.Close; oq_Tcd3.Free;
      oq_CmdACharger.Close; oq_CmdACharger.Free;
      oq_NbPal.Close; oq_NbPal.Free;
      oq_NbPal1.Close; oq_NbPal1.Free;
      oq_NbPalLues.Close; oq_NbPalLues.Free;
      oq_NbPalLues1.Close; oq_NbPalLues1.Free;
      oq_NbCmdCharge.Close; oq_NbCmdCharge.Free;
     End;
     
    end;
    Comme ça tu vois où est initialisé x_AEnvoyer. X_typeenvoi me permet de voir dans quel cas je me trouve (génération d'un num liste, récupération d'un num liste, récupération num list + récupération données ...)

    Je vais reprendre le code en suivant tes conseils

    EDIT : Comment veux tu que je fusionne mes requêtes NbPalLues et NbPalLues1 ? Elles ont un ETAXUCM <> ...
    Windows XP
    Delphi 7

    WinDev Mobile 17

  15. #15
    Membre habitué
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2012
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2012
    Messages : 92
    Points : 159
    Points
    159
    Par défaut
    Citation Envoyé par juju1988 Voir le message
    Voici mon code complet :


    Comme ça tu vois où est initialisé x_AEnvoyer. X_typeenvoi me permet de voir dans quel cas je me trouve (génération d'un num liste, récupération d'un num liste, récupération num list + récupération données ...)

    Je vais reprendre le code en suivant tes conseils

    ici, tu peux virer tout les false puisque tu as un exit
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    begin
            b_RecupList := False;
            b_GenerationList := False;
     
            b_RecupNbCmd := False;
            b_RecupDonnees := False;
            envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
            maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
            exit;
          end;
    EDIT : Comment veux tu que je fusionne mes requêtes NbPalLues et NbPalLues1 ? Elles ont un ETAXUCM <> ...
    il suffit de jouer avec les mot clé "SUM" "UNION" ... qui te permet de balancer tes 2 requêtes et c'est ta base qui t'additionne les calculs

  16. #16
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    J'ai repris mon code mais maintenant ça me fait la même chose sur la partie en gras :

    Et également sur la deuxième ligne en gras, en pas à pas je passe dessus puis me retrouve directement sur le finally... je continue de bosser dessus

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    procedure VerifDep(x_AdIp : string; x_User :string; x_dep : string; x_Mod : string; x_Action : string; os_Session : TOracleSession; ss_Sock : TServerSocket; n_idConnect : integer; m_TraceServeur : TMemo);
    var
      oq_Tcd8, oq_Tcd3, oq_CmdACharger, oq_NbPal, oq_NbPalLues, oq_NbCmdCharge : TOracleQuery;
      x_cmd, x_tournee, x_listCharge, x_aEnvoyer, x_lec, x_typeEnvoi, x_chg, x_tcd, x_num : string;
      b_RecupDonnees, b_RecupList, b_GenerationList, b_RecupNbCmd : boolean;
      n_nbPal, n_nbPalLues, n_CmdEnCours : integer;
    begin
    x_cmd := '';
    x_tournee := '';
    x_listCharge := '';
    x_cmd := '';
    x_aEnvoyer := '';
    x_listCharge := '';
    x_typeEnvoi := '';
    n_nbPal := 0;
    n_nbPalLues := 0;
    n_CmdEnCours := 0;
    b_RecupDonnees := True;
    b_RecupList := True;
    b_GenerationList := True;
    b_RecupNbCmd := True;
    oq_Tcd8:=TOracleQuery.Create(Nil); oq_Tcd8.Session := os_Session;
    oq_Tcd3:=TOracleQuery.Create(Nil); oq_Tcd3.Session := os_Session;
    oq_CmdACharger:=TOracleQuery.Create(Nil); oq_CmdACharger.Session := os_Session;
    oq_NbPal:=TOracleQuery.Create(Nil); oq_NbPal.Session := os_Session;
    oq_NbPalLues:=TOracleQuery.Create(Nil); oq_NbPalLues.Session := os_Session;
    oq_NbCmdCharge:=TOracleQuery.Create(Nil); oq_NbCmdCharge.Session := os_Session;
    
    zx_dejaPasse := 'N';
    
    x_lec := RetourneNomScan(x_AdIp, os_Session);
     Try
      // On recherche les commandes dont le TCD est à 8 :
      oq_Tcd8.Close; oq_Tcd8.SQL.Clear;
      oq_Tcd8.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT=''P''');
      oq_Tcd8.SQL.Add('and TCDXENT=''8'' and LDCXENT=''Y'' group by CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT');
      TestRequete1(oq_Tcd8, 'OPENREQ', 'Echec sélection TCD8 (UnitChgtML - 001)', os_Session);
    
    
      // On recherche toutes les commandes don t le TCD = 3
      oq_Tcd3.Close; oq_Tcd3.SQL.Clear;
      oq_Tcd3.SQL.Add('Select CDEXENT, DEPXENT, NUMXENT, CHGXENT, TCDXENT from ENTXRES where DEPXENT ='''+x_dep+''' and TCDXENT=''3''');
      oq_Tcd3.SQL.Add('and CHGXENT <> ''Y'' and LDCXENT=''Y'' ORDER BY CHGXENT DESC');
      TestRequete1(oq_Tcd3, 'OPENREQ', 'Echec sélection TCD3 (UnitChgtML - 002)', os_Session);
    
        if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          x_num := oq_Tcd8.FieldasString('NUMXENT');
          if (x_chg = 'S') or (x_chg = 'P') then
          begin
            x_cmd := '';
            b_GenerationList := False;
          end
          else
          begin
            b_GenerationList := False;
            b_RecupNbCmd := False;
            b_RecupDonnees := False;
          end;
        end;
        If not oq_Tcd3.Eof then
        begin
          x_cmd := oq_Tcd3.FieldasString('CDEXENT');
          x_chg := oq_Tcd3.FieldasString('CHGXENT');
          x_tcd := oq_Tcd3.FieldasString('TCDXENT');
          x_num := oq_Tcd3.FieldasString('NUMXENT');
          if oq_Tcd3.FieldAsString('CHGXENT') = 'S' then
          begin
            b_RecupDonnees := True;
            b_RecupNbCmd := True;
            b_GenerationList := False;
          end
          else if x_chg = 'P' then
          begin
            b_RecupDonnees := True;
            b_GenerationList := True;
            b_RecupNbCmd := True;
          end
          else if x_chg = 'N' then
          begin
            x_cmd := '';
            b_GenerationList := True;
            b_RecupDonnees := False;
            b_RecupList := False;
            b_RecupNbCmd := False;
          end
          else
          begin
            envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
            maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
            exit;
          end;
        end
        else
        begin
          envoiMsgSocket(n_idConnect, x_dep, uppercase('NOCMDCHARGE'), ss_Sock, m_TraceServeur);
          maj_raoxres(x_User, x_lec, x_Mod, x_Action, '', '', '', x_dep,'' , 'CHGT ML - Pas de commande à charger pour ce déposant', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'Y', 'N', 'N', 'A', os_Session);
          exit;
        end;
    
      if b_RecupNbCmd then
      begin
        oq_NbCmdCharge.Close; oq_NbCmdCharge.SQL.Clear;
        oq_NbCmdCharge.SQL.Add('Select count(*) as TOTAL from ENTXRES where DEPXENT ='''+x_dep+'''and CHGXENT='''+x_chg+''' and TCDXENT='''+x_tcd+''' and ');
        oq_NbCmdCharge.SQL.Add('LDCXENT=''Y''');
        TestRequete1(oq_NbCmdCharge, 'OPENREQ', 'Echec calcul cmd en cours de chgt(UnitChgtML - 026)', os_Session);
        if not oq_NbCmdCharge.Eof then
          n_CmdEnCours := oq_NbCmdCharge.FieldAsInteger('TOTAL')
        else                                                                           // plus besoin ?
          n_CmdEnCours := 0;
      end;
    
      oq_CmdACharger.Close; oq_CmdACharger.SQL.Clear;
      oq_CmdACharger.SQL.Add('select TOUXCHG, CDEXCHG, LISXCHG, ACTXCHG from CHGXRES where CDEXCHG='''+x_cmd+'''');
      oq_CmdACharger.SQL.Add('and DEPXCHG='''+x_dep+'''');
      TestRequete1(oq_CmdACharger, 'OPENREQ', 'Echec récupération données(UnitChgtML - 003)', os_Session);
      if not oq_CmdACharger.Eof then             // if rajoutée par JA le 21/06/2013
      begin
        if b_RecupList then
        begin
          if x_aEnvoyer = '' then
          begin
            x_aEnvoyer := oq_CmdACharger.FieldAsString('LISXCHG');
            x_typeEnvoi := 'A';
          end
          else
            x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('LISXCHG');          //récup liste chgt
        end;
      end;
      if b_RecupDonnees then
      begin
        //JA 05/11/2013 : Modification calcul nb pal lues et nb pal à charger pour que les UMS soient pris en compte
        //Récupération du nombre de palette UM à charger pour la commande (CUMXCUM <> 0) + nb palettes UMS à charger pour la cmd (CUMXUCM = 0)
        // JA 19/11/2013 : Regroupement du calcul au lieu de faire une req pr calculer UM et UMS à charger pr la cmd. On n'en fait plus qu'une.
    
        oq_NbPal.Close; oq_NbPal.SQL.Clear;
        oq_NbPal.SQL.Add('Select SUM(NB) as TOT from');
        oq_NbPal.SQL.Add('(Select Count(distinct(CUMXUCM)) as NB from UCMXRES where LNUXUCM ='''+x_num+''' and ETAXUCM=''380'' and CUMXUCM<>''0''');
        oq_NbPal.SQl.Add('UNION');
        oq_NbPal.SQL.Add('Select Count(distinct(CUCXUCM)) as NB from UCMXRES where LNUXUCM ='''+x_num+''' and ETAXUCM=''380'' and CUMXUCM=''0'')');
        if TestRequete1(oq_NbPal, 'OPENREQ', 'Echec calcul nb palettes à charger(UnitChgtML - 004)', os_Session) then
          n_nbPal := oq_NbPal.FieldAsInteger('TOT')
        else
          n_nbPal := 0;
    
        //JA 19/11/2013 : Même chose pr le nb de palettes déjà chargées pr la cmd  
        //Récupération du nombre de palettes déjà chargées pour la commande
        oq_NbPalLues.Close; oq_NbPalLues.SQL.Clear;
        oq_NbPalLues.SQL.Add('Select SUM(NBPALLU) as PALLU from');
        oq_NbPalLues.SQL.Add('(Select Count(distinct(CUMXUCM)) as NBPALLU from UCMXRES where LNUXUCM ='''+x_num+''' and ETAXUCM=''400'' and CUMXUCM<>''0''');
        oq_NbPalLues.SQL.Add('UNION');
        oq_NbPalLues.SQL.Add('Select Count(distinct(CUCXUCM)) as NBPALLU from UCMXRES where LNUXUCM ='''+x_num+''' and ETAXUCM=''400'' and CUMXUCM=''0'')');
        if TestRequete1(oq_NbPalLues, 'OPENREQ', 'Echec calcul nb pal lues (UnitChgtML - 005(2))', os_Session) then
          n_nbPalLues := oq_NbPalLues.FieldAsInteger('PALLU')
        else
          n_nbPalLues := 0;
    
        if x_aEnvoyer = '' then
        begin
          n_nbPalLues := 0; // BI 26-27-28/03/2013
          x_aEnvoyer := oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          //x_aEnvoyer := oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'C';
        end
        else
        begin
          x_aEnvoyer := x_aEnvoyer +TAB+ oq_CmdACharger.FieldAsString('CDEXCHG') +TAB+ oq_CmdACharger.FieldAsString('TOUXCHG') +TAB+ oq_CmdACharger.FieldAsString('ACTXCHG') +TAB+ IntToStr(n_nbPal) +TAB+ IntToStr(n_nbPalLues);
          x_typeEnvoi := 'B';
        end;
      end;
      if b_GenerationList then
      begin
        x_listCharge := GenerationList(x_user, x_AdIp, '1', x_mod, x_action, os_session, ss_sock, n_idConnect, m_TraceServeur);
        if x_aEnvoyer = '' then
        begin
          x_aEnvoyer := x_listCharge;
          x_typeEnvoi := 'D';
        end
        else
        begin
          x_aEnvoyer := x_aEnvoyer +TAB+ x_listCharge;
          x_typeEnvoi := 'C';
        end;
      end;
    
      maj_raoxres(x_User, x_lec, x_Mod, x_Action, x_cmd, '', '', x_dep,'' , 'CHGT ML - Renvoi des infos OK', '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 'N', 'N', 'N', 'A', os_Session);
      envoiMsgSocket(n_idConnect, x_dep, x_typeEnvoi + TAB+ IntToStr(n_CmdEnCours) +TAB+ x_aEnvoyer, ss_Sock, m_TraceServeur);
    
     Finally
      oq_Tcd8.Close; oq_Tcd8.Free;
      oq_Tcd3.Close; oq_Tcd3.Free;
      oq_CmdACharger.Close; oq_CmdACharger.Free;
      oq_NbPal.Close; oq_NbPal.Free;
      oq_NbPalLues.Close; oq_NbPalLues.Free;
      oq_NbCmdCharge.Close; oq_NbCmdCharge.Free;
     End;
    
    end;
    Windows XP
    Delphi 7

    WinDev Mobile 17

  17. #17
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 046
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 046
    Points : 40 962
    Points
    40 962
    Billets dans le blog
    62
    Par défaut
    Bonjour,
    'erreur' encore due au compilateur (noter le entre guillemet)
    que ce soit selon condition ou hors condition le résultat de b_GenerationList est false !

    donc il vaudrait mieux écrire

    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
       if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          x_num := oq_Tcd8.FieldasString('NUMXENT');
          b_GenerationList := False;
          if (x_chg = 'S') or (x_chg = 'P') then
          begin
            x_cmd := '';
          end
          else
          begin
            b_RecupNbCmd := False;
            b_RecupDonnees := False;
          end;
        end;
    ceci dit je trouve que le code n'a pas beaucoup évolué depuis le début et qu'il est 'lourd'
    je suis d'accord avec jeromelef2 lorsqu'il disait que deux querys était une de trop, c'est certainement 'optimisable' . Personnellement je suis loin d'être un fan : - des variables de travail j'en utilise le moins possible
    - des requêtes non paramétrées sauf impossibilité de faire autrement
    - des variables booléennes ou la valeur est mise dans un if (il est simple de mettre un code de ce style
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     b_GenerationList :=not ((x_chg = 'S') or (x_chg = 'P'))
    // ou
     b_GenerationList := (x_chg <> 'S') AND (x_chg <> 'P');
    // je n'ai pas le courage d'améliorer d'avantage
    ce qui aurait pointé du doigt cette erreur de programmation
    - et enfin je n'aime pas trop tester sur des EOF de query
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  18. #18
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Citation Envoyé par SergioMaster Voir le message
    Bonjour,
    'erreur' encore due au compilateur (noter le entre guillemet)
    que ce soit selon condition ou hors condition le résultat de b_GenerationList est false !

    donc il vaudrait mieux écrire

    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
       if not oq_Tcd8.Eof then
        begin
          x_cmd := oq_Tcd8.FieldasString('CDEXENT');
          x_chg := oq_Tcd8.FieldasString('CHGXENT');
          x_tcd := oq_Tcd8.FieldasString('TCDXENT');
          x_num := oq_Tcd8.FieldasString('NUMXENT');
          b_GenerationList := False;
          if (x_chg = 'S') or (x_chg = 'P') then
          begin
            x_cmd := '';
          end
          else
          begin
            b_RecupNbCmd := False;
            b_RecupDonnees := False;
          end;
        end;
    ceci dit je trouve que le code n'a pas beaucoup évolué depuis le début et qu'il est 'lourd'
    je suis d'accord avec jeromelef2 lorsqu'il disait que deux querys était une de trop, c'est certainement 'optimisable' . Personnellement je suis loin d'être un fan : - des variables de travail j'en utilise le moins possible
    - des requêtes non paramétrées sauf impossibilité de faire autrement
    - des variables booléennes ou la valeur est mise dans un if (il est simple de mettre un code de ce style
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     b_GenerationList :=not ((x_chg = 'S') or (x_chg = 'P'))
    // ou
     b_GenerationList := (x_chg <> 'S') AND (x_chg <> 'P');
    // je n'ai pas le courage d'améliorer d'avantage
    ce qui aurait pointé du doigt cette erreur de programmation
    - et enfin je n'aime pas trop tester sur des EOF de query

    Et bien j'ai regroupé mes requêtes avec le UNION au lieu de 4 je n'en ai plus que 2.

    Qu'appelle tu des variables de travail ?

    Pour les requêtes non paramétrés on m'a dit sur ce forum que c'était moins lourd comme cela en mettant directement la variable, mais je peux encore changer hein !

    Je vais regarder pour mon b_GenerationList...

    EDIT :

    J'ai fait exactement comme tu m'as dit, par contre j'ai toujours un problème sur ma deuxième ligne en gras, une fois sur mon x_aEnvoyer je passe directement au Finally. Je vais voir ce que je peux encore optimiser.
    Windows XP
    Delphi 7

    WinDev Mobile 17

  19. #19
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 046
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 046
    Points : 40 962
    Points
    40 962
    Billets dans le blog
    62
    Par défaut
    Citation Envoyé par juju1988 Voir le message
    Qu'appelle tu des variables de travail ?
    tous ces x_machins , quand je vois
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        x_chg := oq_Tcd8.FieldasString('CHGXENT');
         ....
          if (x_chg = 'S') or (x_chg = 'P') then
    je préfère
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
       if (oq_Tcd8.FieldasString('CHGXENT')='S') 
        OR (oq_Tcd8.FieldasString('CHGXENT')='P') 
      then
    mais bon je n'ai lu le code qu'en diagonale , la preuve un peu plus bas
    Citation Envoyé par juju1988 Voir le message
    Pour les requêtes non paramétrés on m'a dit sur ce forum que c'était moins lourd comme cela en mettant directement la variable, mais je peux encore changer hein !
    qui a bien pu dire ça !! , au moins utilises des quotedstr(mavariable) ce qui éviterait des casses-têtes de comptage de '
    quant aux paramètres : oui ça fait écrire des lignes de code en plus , mais quand il y a des dates en jeu .....

    j'ai toujours un problème sur ma deuxième ligne en gras, une fois sur mon x_aEnvoyer je passe directement au Finally. Je vais voir ce que je peux encore optimiser.
    je n'avais vu que la première ligne en gras (code trop long pour un matin)
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

  20. #20
    Membre régulier
    Profil pro
    Inscrit en
    Février 2010
    Messages
    533
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Février 2010
    Messages : 533
    Points : 124
    Points
    124
    Par défaut
    Le deuxième problème c'était tout simplement que ma requête ne renvoyait pas de valeurs donc forcément au moment de la récupération des valeurs problème.

    Pas de soucis tu m'as déjà bien aidé. Je vais mettre en application tout ce que tu m'as dit.

    Mon problème principal des booléens sur lesquels je ne passais pas est résolu.

    Merci bien.
    Windows XP
    Delphi 7

    WinDev Mobile 17

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

Discussions similaires

  1. Booléen et boucle for
    Par Xenthys dans le forum Langage
    Réponses: 3
    Dernier message: 22/02/2013, 08h21
  2. [Turbo Pascal] Exercice/programme sur les boucles et booléens
    Par uncalamarroux dans le forum Turbo Pascal
    Réponses: 6
    Dernier message: 11/12/2010, 22h17
  3. [XSLT] Faire une boucle sur une variable [i]
    Par PoT_de_NuTeLLa dans le forum XSL/XSLT/XPATH
    Réponses: 8
    Dernier message: 07/06/2010, 12h45
  4. Sortir d'un progamme qui boucle ou qui refresh
    Par mikevador02 dans le forum C
    Réponses: 12
    Dernier message: 14/12/2002, 09h38
  5. Réponses: 2
    Dernier message: 29/05/2002, 20h43

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