Autor Beitrag
Lemon
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: So 07.03.04 10:41 
hallo,

habe eine programm geschrieben, dass die log-dateien meiner website auswertet.
soweit kein problem. funktioniert alles, wie ich das moechte.
nur wenn ich jetzt eine neue komponente auf meiner form haben will, egal ob button, checkbox oder stringgrid, kommt beim ausfuehren des programms immer das cpu fenster mit der meldung access violation.
warum???

lemon
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: So 07.03.04 15:52 
da würde ich doch mal ganz grob auf einen compiler fehler tippen.

allerdings hab ich keine ahnung wie man das problem beheben könnte :nixweiss:

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: So 07.03.04 17:37 
hab' jetzt festgestellt, dass delphi den quatsch nicht nur mit komponenten macht.
auch wenn ich neue ereignisse erstellen moechte, wie z.b. das OnDrawCell vom stringgrid, kommt diese meldung beim ausfuehren des programms.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 07.03.04 17:41 
Hallo

wo jetzt genau? Beim Draufpacken auf die Form oder zur Laufzeit des Programmes?

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: So 07.03.04 20:01 
der fehler kommt immer zur laufzeit.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 07.03.04 20:03 
Lemon hat folgendes geschrieben:
der fehler kommt immer zur laufzeit.


Dann poste code, z.B. was hast du im formcreate stehen, bzw. starte die Anwendung im Einzelschitt, um den Fehler einzugrenzen

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Mo 08.03.04 18:04 
im formcreate steht gar nichts. aber wie geht das mit dem einzelanwendung ausfuehren???
Gosa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Mo 08.03.04 18:09 
Einfach F7 drücken dann geht er schritt für schritt dadurch (Bei jedem F7 einen schritt weiter).
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Mo 08.03.04 20:21 
ich poste jetzt wohl doch besser mal meinen quelltext.

hier ein kleiner ausschnitt der logdatei...

:klick:7:1:1:8:2003:10:10:35:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
:klick:2:1:1:8:2003:10:10:40:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
:zeit:159:1:1:8:2003:10:13:16:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
:klick:7:1:1:8:2003:10:15:46:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
:klick:7:1:1:8:2003:10:15:50:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
:klick:0:1:1:8:2003:10:15:53:Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)


hier die procedure...

ausblenden volle Höhe Delphi-Quelltext
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:
procedure TForm1.Button1Click(Sender: TObject);
var
  logs : TStrings;
  i, j, besucher, prozent : Integer;
  browser, text : String;
  monate, tage, uhrzeit, menuepunkte : array of Integer;
  monate0, tage0, menuepunkte0 : array of String;
  array0 : array of String;
  rect : TRect;
begin
  //erst mal das array fuer die monatszaehlung erstellen und jedem element den wert 0 zuweisen...
  setLength(monate,12);
  for i := 0 to Length(monate) do monate[i] := 0;
  //dann auch noch diemonatsnamen
  setLength(monate0,12);
  monate0[0] := 'Januar';
  monate0[1] := 'Februar';
  monate0[2] := 'März';
  monate0[3] := 'April';
  monate0[4] := 'Mai';
  monate0[5] := 'Juni';
  monate0[6] := 'Juli';
  monate0[7] := 'August';
  monate0[8] := 'September';
  monate0[9] := 'Oktober';
  monate0[10] := 'November';
  monate0[11] := 'Dezember';
  //und das gleiche fuer die tage...
  setLength(tage,7);
  for i := 0 to Length(tage) do tage[i] := 0;
  setLength(tage0,7);
  tage0[0] := 'Sonntag';
  tage0[1] := 'Montag';
  tage0[2] := 'Dienstag';
  tage0[3] := 'Mittwoch';
  tage0[4] := 'Donnerstag';
  tage0[5] := 'Freitag';
  tage0[6] := 'Samstag';
  //...die uhrzeit...
  setLength(uhrzeit,24);
  for i := 0 to Length(uhrzeit) do uhrzeit[i] := 0;
  //und die zugriffe auf die menuepunkte
  setLength(menuepunkte,8);
  for i := 0 to Length(menuepunkte) do menuepunkte[i] := 0;
  setLength(menuepunkte0,8);
  menuepunkte0[0] := 'Aktuell';
  menuepunkte0[1] := 'Wir über uns';
  menuepunkte0[2] := 'Angebote';
  menuepunkte0[3] := 'Service';
  menuepunkte0[4] := 'Impressum';
  menuepunkte0[5] := 'Kontakt';
  menuepunkte0[6] := 'Gästebuch';

  besucher := 0;

  //logdatei laden...
  logs := TStringList.Create;
  logs.LoadFromFile('logs\logs_2003.txt');
  StringGrid1.ColWidths[0] := 160;
  StringGrid1.ColWidths[1] := 380;
  ProgressBar1.Max := logs.Count-1;
  for i := 0 to logs.Count-1 do
  begin
    //einezelne zeile der variable text zuweisen, um spaeter in array zu splitten...
    text := logs[i] + ':';
    setLength(array0,0);
    browser := logs[i];
    //split in array...
    //extrahieren des browsers
    for j := 0 to 9 do
    begin
      setLength(array0,Length(array0)+1);
      array0[High(array0)] := Trim(Copy(text,1,Pos(':',text)-1));
      Delete(text,1,Pos(':',text));
      browser := Copy(browser,pos(':',browser)+1,Length(browser));
    end;
    //zugriffszaehlung: bei klick und 7 werden die werte von monate, tage und uhrzeit erhoeht...
    if lowercase(array0[1]) = 'klick' then
    begin
      if StrtoInt(array0[2]) = 7 then
      begin
        inc(besucher);
        inc(monate[StrtoInt(array0[5])]);
        inc(tage[StrtoInt(array0[3])]);
        inc(uhrzeit[StrtoInt(array0[7])]);
      end
      //...andernfalls die der menuepunkte...
      else inc(menuepunkte[StrtoInt(array0[2])]);
    end;
    ProgressBar1.Position := i;
    Application.ProcessMessages;
  end;

  //und dann folgt die ausgabe im stringrid...

  StringGrid1.RowCount := 53;

  for i := 0 to 11 do
  begin
    prozent := round(monate[i]*100/besucher);
    StringGrid1.Cells[1,i] := InttoStr(monate[i]) + ' Besucher (' + InttoStr(prozent) + ' %)';
    StringGrid1.Cells[0,i] := monate0[i];
  end;
  for i := 0 to 6 do
  begin
    prozent := round(tage[i]*100/besucher);
    StringGrid1.Cells[1,i+13] := InttoStr(tage[i]) + ' Besucher (' + InttoStr(prozent) + ' %)';
    StringGrid1.Cells[0,i+13] := tage0[i];
  end;
  for i := 0 to 23 do
  begin
    prozent := round(uhrzeit[i]*100/besucher);
    StringGrid1.Cells[1,i+21] := InttoStr(uhrzeit[i]) + ' Besucher (' + InttoStr(prozent) + ' %)';
    StringGrid1.Cells[0,i+21] := InttoStr(i+1);
  end;
  for i := 0 to 6 do
  begin
    prozent := round(menuepunkte[i]*100/besucher);
    StringGrid1.Cells[1,i+46] := InttoStr(menuepunkte[i]) + ' Besucher (' + InttoStr(prozent) + ' %)';
    StringGrid1.Cells[0,i+46] := menuepunkte0[i];
  end;

  ProgressBar1.Position := 0;

  logs.destroy;

end;


Moderiert von user profile iconPeter Lustig: BBCode aktiviert
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 09.03.04 09:06 
Hallo

auf den ersten Blick:
*
Zitat:

setLength(tage,7);
for i := 0 to Length(tage) do tage[i] := 0;

sollte heißen:
ausblenden Delphi-Quelltext
1:
2:
  setLength(tage,7); 
  for i := 0 to Length(tage)-1 do tage[i] := 0;

die array beginnen bei 0 zu zählen. und bei Length(tage) bist du außerhalb des arrays

* setlength sollte man nicht immer in Schleifen aufrufen

*
Zitat:
logs.destroy;
Destroy ruft man nicht direkt auf (siehe OH), nimm free

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Di 09.03.04 15:10 
danke, jetzt geht's
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Di 09.03.04 17:04 
habe hier noch eine neue prozedur, die ich eingebaut habe, dass die hintergrundfarbe der einzelnen zellen verschiedenfarbig angezeigt werden.
geht ja auch eigentlich, allerdings wird nach dem faerben wieder das ereignis ondrawcell aufgerufen, sodass die zellen wieder weiss erscheinen.
kann man das irgendwie unterdruecken??
hier auf jeden fall mal die prozedur und der aufruf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.faerben(rect: TRect; ACol, ARow : Integer; farbe : TColor);
begin
  with StringGrid1.Canvas do
  begin
    Brush.Color := farbe;
    FillRect(Rect);
    TextOut(Rect.Left+2,Rect.Top+2,StringGrid1.Cells[ACol,ARow]);
  end;
end;

    rect := StringGrid1.CellRect(1,i); //die variable i stammt aus der zaehlerschleife, mir der ich die auswertung in das stringgrid schreibe...
    faerben(rect,1,i,clFuchsia);
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 09.03.04 18:55 
Das hat jetzt aber wirklich überhaupt nix mit deiner Ausgangsfrage zu tun ? neue Frage, neuer Thread :roll:

so wie due das machst, wird das nix. Der code zum Färben gehört ins ondrawcell , dort bekommst du arow und acol übergeben, undweist entsprechend eine Farbe zu. Da sollte es auch ein Haufen Einträge im Forum dazu geben.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Lemon Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 96

Win XP
D5 Standart
BeitragVerfasst: Di 09.03.04 19:56 
ich weiss, dass das eigentlich ins ondrawcell gehoert, aber das muss doch auch so gehen.
ich meine, wenn ich die obige prozedur auf einen button lege, dann geht das doch auch...
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 09.03.04 20:18 
Lemon hat folgendes geschrieben:
ich weiss, dass das eigentlich ins ondrawcell gehoert, aber das muss doch auch so gehen.

geht es nicht ;)

mit dem Button zeichnest du zwar was, aber alles, was ein Drawcell auslöst, wird dein gezeichnetes übermalt. Und ein drawcell wird of ausgelöst (Zellenwechsel, Scrollen,. aneres Fenster überdeckt Grid etc. pp)

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)