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 :

Over Stack error


Sujet :

Langage Delphi

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2003
    Messages
    803
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2003
    Messages : 803
    Par défaut Over Stack error
    Bonjour,

    Dans ma form principale je fais les déclarations suivantes :
    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
    const
      MaxPixelCount = 65536;
    type
      TSegment = record
        Num : Integer;
        Code : String[4];
        LMin,LMax,CMin,CMax,hMin,hMax: single;
        NbPix: integer;
        PerCent: single;
        LMean,CMean,hMean: single;
        Color: TColor;
      end;
      TSeg5x5x36= array[0..799] of TSegment;
      RGBTripleArray = array[0..MaxPixelCount-1] of TRGBTriple;
      pRGBTripleArray = ^RGBTripleArray;
      TMainForm = class(TForm)
    Sans déclaration supplémentaire dans OnCreate pas de problème.
    Mais dés que j'initialise la structure tableau TSeg5x5x36 dans CreateForm je provoque une Over Stack error.
    J'ai donc essayé de tracer le problème en éditant un fichier texte lors de l'initialisation du tableau avec le code suivant :
    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
      AssignFile(F,'TextFile.txt');
      Rewrite(F);
        I:= 0;
        for L := 0 to 4 do
          for C := 0 to 4 do
            for H := 0 to 35 do
              begin
      S:= '';
                fillChar(CurSeg[I],Sizeof(TSegment),#0);
                CurSeg[I].Num := I;
      S:= S+IntToStr(I)+#9;
                CurSeg[I].Code:= IntToStr(L)+IntToStr(C)+
                                  Tools_LeftJustifyZero(IntToStr(H),2);
      S:= S+CurSeg[I].Code+#9;
                CurSeg[I].LMin:= L*20;
      S:= S+FloatToStrF(CurSeg[I].LMin,ffFixed,5,0)+#9;
                CurSeg[I].LMax:= Succ(L)*20;
      S:= S+FloatToStrF(CurSeg[I].LMax,ffFixed,5,0)+#9;;
                CurSeg[I].CMin:= C*20;
      S:= S+FloatToStrF(CurSeg[I].CMin,ffFixed,5,0)+#9;
                CurSeg[I].CMax:= Succ(C)*20;
      S:= S+FloatToStrF(CurSeg[I].CMax,ffFixed,5,0)+#9;
                CurSeg[I].hMin:= H*10;
      S:= S+FloatToStrF(CurSeg[I].HMin,ffFixed,5,0)+#9;
                CurSeg[I].hMax:= 10+H*10;
      S:= S+FloatToStrF(CurSeg[I].HMax,ffFixed,5,0);
      WriteLn(F,S);
                Inc(I);
              end;
      CloseFile(F);
    L'erreur OverFlow apparait édition du fichier texte ou pas.
    Dès la première ligne du fichier texte je constate une anomalie sur la dernière colonne du tableau
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    0	0000	0	20	0	20	0	1E2	
    1	0001	0	20	0	20	10	1.1E2	
    2	0002	0	20	0	20	20	1.2E2	
    3	0003	0	20	0	20	30	1.3E2	
    4	0004	0	20	0	20	40	1.4E2	
    5	0005	0	20	0	20	50	1.5E2	
    6	0006	0	20	0	20	60	1.6E2	
    7	0007	0	20	0	20	70	1.7E2	
    8	0008	0	20	0	20	80	1.8E2	
    9	0009	0	20	0	20	90	1.9E2
    et de surcroît le tableau devrait comprendre 899 lignes et il s'arrête à la 896ème !!!

    Quelqu'un peut-il venir à mon secours ?

  2. #2
    Membre Expert Avatar de philnext
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    1 553
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 1 553
    Par défaut
    Je ne vois pas où est le code de l'initialisation qui te déclenche l'erreur.

  3. #3
    Membre Expert
    Avatar de Dr.Who
    Inscrit en
    Septembre 2009
    Messages
    980
    Détails du profil
    Informations personnelles :
    Âge : 47

    Informations forums :
    Inscription : Septembre 2009
    Messages : 980
    Par défaut
    5 x 5 x 36 = 900 et non 799 !

    Code est mieux si stocké en Word, plus facile à comparer/manipuler, plus performant et si tu veux stocker les TSegment dans un Stream ce sera plus simple à gérer.


    Packed ! histoire d’aligner les tableaux et records

    Format et TStringList plutôt que les imbuvables suites de Int/FloatToStr et utilisations aberrante en 2013 de AssignFile, Reset/Rewrite, CloseFile,

    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
     
    type
      TSegment = packed record
        Num     : Integer;
        Code    : word; // Word ! min = 1101 max = 5536
        LMin,
        LMax,
        CMin,
        CMax,
        hMin,
        hMax    : single;
        NbPix   : integer;
        PerCent : single;
        LMean,
        CMean,
        hMean   : single;
        Color   : TColor;
      end;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
      TSeg5x5x36 = packed array[0..(5*5*36)-1] of TSegment;
     
      RGBTripleArray  = packed array[0..0] of TRGBTriple; // like PChar !
      pRGBTripleArray = ^RGBTripleArray;
    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
     
    procedure TFormX.FormCreate(Sender: TObject);
    var I,L,C,H: integer;
        CurSeg : TSeg5x5x36;
    begin
      with TStringList.Create do
      try
        I := 0;
     
        fillChar(CurSeg, Length(CurSeg)*SizeOf(TSegment), 0);
     
        for L := 0 to 4 do
          for C := 0 to 4 do
            for H := 0 to 35 do
            begin
              CurSeg[I].Num := I;
              CurSeg[I].Code:= (L+1)*1000+(C+1)*100+(H+1);
              CurSeg[I].LMin:= L * 20;
              CurSeg[I].LMax:= Succ(L) * 20;
              CurSeg[I].CMin:= C * 20;
              CurSeg[I].CMax:= Succ(C) * 20;
              CurSeg[I].hMin:= H * 10;
              CurSeg[I].hMax:= 10 + H * 10;
     
              add( format('%.3d'+#9+ // 000..900
                          '%.4d'+#9+ // 1101..5536
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f',
                   [ I,
                     CurSeg[I].Code,
                     CurSeg[I].LMin,
                     CurSeg[I].LMax,
                     CurSeg[I].CMin,
                     CurSeg[I].CMax,
                     CurSeg[I].HMin,
                     CurSeg[I].HMax
                   ]));
     
                Inc(I);
              end;
     
        SaveToFile(ExtractFilePath(ParamStr(0))+ 'TextFile.txt');
      finally
        Free;
      end;
    end;
     
    end.

    Le fichier rendus (extrait des 30 premières lignes) :
    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
     
    000	1101	0.00000	20.00000	0.00000	20.00000	0.00000	10.00000
    001	1102	0.00000	20.00000	0.00000	20.00000	10.00000	20.00000
    002	1103	0.00000	20.00000	0.00000	20.00000	20.00000	30.00000
    003	1104	0.00000	20.00000	0.00000	20.00000	30.00000	40.00000
    004	1105	0.00000	20.00000	0.00000	20.00000	40.00000	50.00000
    005	1106	0.00000	20.00000	0.00000	20.00000	50.00000	60.00000
    006	1107	0.00000	20.00000	0.00000	20.00000	60.00000	70.00000
    007	1108	0.00000	20.00000	0.00000	20.00000	70.00000	80.00000
    008	1109	0.00000	20.00000	0.00000	20.00000	80.00000	90.00000
    009	1110	0.00000	20.00000	0.00000	20.00000	90.00000	100.00000
    010	1111	0.00000	20.00000	0.00000	20.00000	100.00000	110.00000
    011	1112	0.00000	20.00000	0.00000	20.00000	110.00000	120.00000
    012	1113	0.00000	20.00000	0.00000	20.00000	120.00000	130.00000
    013	1114	0.00000	20.00000	0.00000	20.00000	130.00000	140.00000
    014	1115	0.00000	20.00000	0.00000	20.00000	140.00000	150.00000
    015	1116	0.00000	20.00000	0.00000	20.00000	150.00000	160.00000
    016	1117	0.00000	20.00000	0.00000	20.00000	160.00000	170.00000
    017	1118	0.00000	20.00000	0.00000	20.00000	170.00000	180.00000
    018	1119	0.00000	20.00000	0.00000	20.00000	180.00000	190.00000
    019	1120	0.00000	20.00000	0.00000	20.00000	190.00000	200.00000
    020	1121	0.00000	20.00000	0.00000	20.00000	200.00000	210.00000
    021	1122	0.00000	20.00000	0.00000	20.00000	210.00000	220.00000
    022	1123	0.00000	20.00000	0.00000	20.00000	220.00000	230.00000
    023	1124	0.00000	20.00000	0.00000	20.00000	230.00000	240.00000
    024	1125	0.00000	20.00000	0.00000	20.00000	240.00000	250.00000
    025	1126	0.00000	20.00000	0.00000	20.00000	250.00000	260.00000
    026	1127	0.00000	20.00000	0.00000	20.00000	260.00000	270.00000
    027	1128	0.00000	20.00000	0.00000	20.00000	270.00000	280.00000
    028	1129	0.00000	20.00000	0.00000	20.00000	280.00000	290.00000
    029	1130	0.00000	20.00000	0.00000	20.00000	290.00000	300.00000
    030	1131	0.00000	20.00000	0.00000	20.00000	300.00000	310.00000
    [ Sources et programmes de Dr.Who | FAQ Delphi | FAQ Pascal | Règlement | Contactez l'équipe ]
    Ma messagerie n'est pas la succursale du forum... merci!

  4. #4
    Membre Expert
    Avatar de Dr.Who
    Inscrit en
    Septembre 2009
    Messages
    980
    Détails du profil
    Informations personnelles :
    Âge : 47

    Informations forums :
    Inscription : Septembre 2009
    Messages : 980
    Par défaut
    Single n'est pas justifié partout apparement :

    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
     
      TSegment = packed record
        Num     : Integer;
        Code    : word; // Word ! min = 1101 max = 5536
        LMin,
        LMax,
        CMin,
        CMax,
        hMin,
        hMax,
        NbPix   : integer;
        PerCent : single;
        LMean,
        CMean,
        hMean   : single;
        Color   : TColor;
      end;
    Une variante pour te montrer les possibilité de souplesses :

    type TSeg5x5x36 :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
      TSeg5x5x36 = packed record
        case integer of
          0:(LCH: array[0..4,0..4,0..35] of TSegment);
          1:(I  : array[0..5*5*36-1] of TSegment);
      end;
    Init et remplissage :

    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
    var L,C,H: integer;
        CurSeg : TSeg5x5x36;
    begin
      with TStringList.Create do
      try
     
        fillChar(CurSeg, Length(CurSeg.I)*SizeOf(TSegment), 0);
     
        for L := 0 to 4 do
          for C := 0 to 4 do
            for H := 0 to 35 do
            begin
              with CurSeg.LCH[L, C, H] do
              begin
                Num :=  H + (36 * C) + (180*L); // 0..899
                Code:= L*1000+C*100+H; // 0000..4435
                LMin:= L * 20;
                LMax:= (L+1) * 20;
                CMin:= C * 20;
                CMax:= (C+1) * 20;
                hMin:= H * 10;
                hMax:= 10 + H * 10;
     
                add(
                  format(
                    '%.3d'+#9+ '%.4d'+#9+ '%d'+#9+ '%d'+#9+ '%d'+#9+ '%d'+#9+ '%d'+#9+ '%d',
                  [  Num,       Code,      LMin,    LMax,    CMin,    CMax,    HMin,    HMax
                  ])
                );
              end;
            end;
        SaveToFile(ExtractFilePath(ParamStr(0))+ 'TextFile.txt');
      finally
        Free;
      end;
    end;

    Fichier 2 fois moins gros (59Ko -> 26Ko)
    Génération 2 fois plus rapide.

    Extrait :
    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
     
    000	1101	0	20	0	20	0	10
    001	1102	0	20	0	20	10	20
    002	1103	0	20	0	20	20	30
    003	1104	0	20	0	20	30	40
    004	1105	0	20	0	20	40	50
    005	1106	0	20	0	20	50	60
    006	1107	0	20	0	20	60	70
    007	1108	0	20	0	20	70	80
    008	1109	0	20	0	20	80	90
    009	1110	0	20	0	20	90	100
    010	1111	0	20	0	20	100	110
    011	1112	0	20	0	20	110	120
    012	1113	0	20	0	20	120	130
    013	1114	0	20	0	20	130	140
    014	1115	0	20	0	20	140	150
    015	1116	0	20	0	20	150	160
    016	1117	0	20	0	20	160	170
    017	1118	0	20	0	20	170	180
    018	1119	0	20	0	20	180	190
    019	1120	0	20	0	20	190	200
    020	1121	0	20	0	20	200	210
    021	1122	0	20	0	20	210	220
    022	1123	0	20	0	20	220	230
    023	1124	0	20	0	20	230	240
    024	1125	0	20	0	20	240	250
    025	1126	0	20	0	20	250	260
    026	1127	0	20	0	20	260	270
    027	1128	0	20	0	20	270	280
    028	1129	0	20	0	20	280	290
    029	1130	0	20	0	20	290	300
    [ Sources et programmes de Dr.Who | FAQ Delphi | FAQ Pascal | Règlement | Contactez l'équipe ]
    Ma messagerie n'est pas la succursale du forum... merci!

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2003
    Messages
    803
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2003
    Messages : 803
    Par défaut Merci mais gros problème !!!
    J'ai réécrit le code comme conseillé mais delphi ne reconnait pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
              add( format('%.3d'+#9+ // 000..900
                          '%.4d'+#9+ // 1101..5536
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f'+#9+
                          '%.5f',
    il m'adresse un message d'erreur de format à cause de %.3d
    J'essaie de corriger avec les formats plus traditionnels

  6. #6
    Membre Expert
    Avatar de Dr.Who
    Inscrit en
    Septembre 2009
    Messages
    980
    Détails du profil
    Informations personnelles :
    Âge : 47

    Informations forums :
    Inscription : Septembre 2009
    Messages : 980
    Par défaut
    quel version de Delphi as tu ?
    [ Sources et programmes de Dr.Who | FAQ Delphi | FAQ Pascal | Règlement | Contactez l'équipe ]
    Ma messagerie n'est pas la succursale du forum... merci!

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Juillet 2003
    Messages
    803
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2003
    Messages : 803
    Par défaut
    Delphi 2007

Discussions similaires

  1. ModernCv : \href dans \homepage stack error
    Par nostroyo dans le forum Débuter
    Réponses: 2
    Dernier message: 09/03/2015, 11h21
  2. Stack Overflow Error
    Par bousnguar dans le forum JSF
    Réponses: 5
    Dernier message: 11/08/2008, 12h28
  3. CXX0069: Error: variable needs stack frame
    Par stof dans le forum Visual C++
    Réponses: 7
    Dernier message: 22/07/2008, 18h41
  4. [TP] Error stack over flow 202
    Par Full62fr dans le forum Turbo Pascal
    Réponses: 2
    Dernier message: 05/02/2008, 18h34
  5. Error Stack OverFlow
    Par fabred dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 14/05/2007, 14h54

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