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 :

Incrementer une variable de type record


Sujet :

Langage Delphi

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    63
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 63
    Points : 49
    Points
    49
    Par défaut Incrementer une variable de type record
    Bonjour,

    Je me retrouve dans une impasse, voilà j'ai déclarer
    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
    Num1     = record
             prix1  : string;
             prix2  : string;
             prix3  : string;
             prix4  : string;
             prix5  : string;
             prix6  : string;
             prix7  : string;
             prix8  : string;
             prix9  : string;
             prix10 : string;
             prix11 : string;
             prix12 : string;
             prix13 : string;
             prix14 : string;
      end;
     
       tabreserv1:array[1..1] of Num1;
    et j'aimerai trouver indice pour pouvoir lire la ligne de prix correspondant de ce genre "tabreserv1[1].prix(qui varie avec l'indice)" et je ne trouve pas



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     for i:=0 to 14 do
     begin 
        if  (controle=1) then
        begin 
           tabreserv1[1].prix(qui varie avec l'indice)  // et cela ne marche pas !!! 
        end  
     end;

    Si vous avez une idée à me proposer, merci d'avance

  2. #2
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 436
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 436
    Points : 5 851
    Points
    5 851
    Par défaut
    salut

    la variation selon l'indice est constante ou pas

    sinon tu aurais pu faire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    Tnum1 = Record 
      Prix : array[1..14] of string;
    end;
     
    tabreserv1:array[1..1] of Tnum1;
     
    for i:=1 to 14 do
    begin
      if (controle=1) then
      begin
         tabreserv1[1].prix[i] := ...;// et cela ne marche pas !!!
      end
    end
    @+ Phil

    Ps : Penser au tag code (#)

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Décembre 2007
    Messages
    63
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2007
    Messages : 63
    Points : 49
    Points
    49
    Par défaut Incrementer une variable de type record
    Salut Phil,

    J'ai fait ta méthode elle marche nickel, salut et merci encore


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    Tnum1 = Record 
      Prix : array[1..14] of string;
    end;
     
    tabreserv1:array[1..1] of Tnum1;
     
    for i:=1 to 14 do
    begin
      if (controle=1) then
      begin
         tabreserv1[1].prix[i] := ...;// et cela ne marche pas !!!
      end
    end

  4. #4
    Expert éminent sénior
    Avatar de ShaiLeTroll
    Homme Profil pro
    Développeur C++\Delphi
    Inscrit en
    Juillet 2006
    Messages
    13 609
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Développeur C++\Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 13 609
    Points : 25 296
    Points
    25 296
    Par défaut
    ou encore

    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
    type
      TNum1 = record
        case Boolean of
          True:
            (
              prix1 : shortstring;
              prix2 : shortstring;
              prix3 : shortstring;
              prix4 : shortstring;
              prix5 : shortstring;
              prix6 : shortstring;
              prix7 : shortstring;
              prix8 : shortstring;
              prix9 : shortstring;
              prix10 : shortstring;
              prix11 : shortstring;
              prix12 : shortstring;
              prix13 : shortstring;
              prix14 : shortstring;
           );
         False:
           (
             Prix : array[1..14] of shortstring;
           );
      end;

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    for i:=1 to 14 do
    begin
      if (controle=1) then
      begin
         tabreserv1[1].prix[i] := ...;// et cela ne marche pas !!!
         // mais aussi 
         tabreserv1[1].Prix1 := 'Bcp';
         tabreserv1[1].Prix2 := 'Gratuit';
      end
    end

  5. #5
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 436
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 436
    Points : 5 851
    Points
    5 851
    Par défaut
    salut

    attention cela ne marche qu'avec les shortstring


    @+ Phil

  6. #6
    Membre confirmé
    Inscrit en
    Janvier 2009
    Messages
    598
    Détails du profil
    Informations forums :
    Inscription : Janvier 2009
    Messages : 598
    Points : 628
    Points
    628
    Par défaut
    Je lui précise juste :
    Shortstring = chaine de 255 caractères maxi

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

Discussions similaires

  1. Incrementer une variable du type mysql_fetch_array
    Par furtif1 dans le forum Langage
    Réponses: 2
    Dernier message: 10/03/2007, 15h23
  2. [XSLT] incrementer une variable
    Par Landolsi dans le forum XSL/XSLT/XPATH
    Réponses: 9
    Dernier message: 02/11/2005, 10h44
  3. Réponses: 3
    Dernier message: 28/07/2005, 21h30
  4. affecter une variable de type stringstream
    Par sorari dans le forum SL & STL
    Réponses: 3
    Dernier message: 24/03/2005, 11h14
  5. Ajouter a une variable de type string, un entier
    Par Little-Freud dans le forum SL & STL
    Réponses: 12
    Dernier message: 05/03/2005, 19h33

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