Autor Beitrag
Ulixes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 63

Win Vista Home Premium
Delphi 2009 Professional, XHTML, CSS, PHP
BeitragVerfasst: Mo 22.12.08 14:01 
Hey!

Ich möchte ein technischen Indikator schreiben. Folgenden Quelltext habe ich schon geschrieben:

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:
procedure renko();
var cnt2,zw,zahl,cnt,value,i,range,plus,k: integer;
arr: array of array of integer;
begin
i:= 1;
k:= form4.listbox1.items.count;
Setlength(arr, k, k);
Value := strtoint(trim(form4.listbox1.items[i]));
    while i < k do
        begin
              if strtoint(form4.listbox1.items[i]) > Value then
                begin
                  range:= strtoint(trim(form4.listbox1.items[i]))- value;
                  cnt:= range div 15;
                  plus:= range mod 15;
                  form4.ListBox1.Items[i]:= inttostr(strtoint(trim(form4.listbox1.Items[i])) + plus);
                  value:= strtoint(trim(form4.listbox1.items[i]));
                  Form4.ListBox1.Items[i]:= inttostr(0);
                  zahl:= 0;
                  arr[i][zahl]:= cnt;
                  arr[i][1]:= 0;
                  inc(i);
                end
              else
                begin
                  range:= value - strtoint(trim(form4.listbox1.items[i]));
                  cnt:= range div 15;
                  plus:= range mod 15;
                  form4.ListBox1.Items[i]:= inttostr(strtoint(trim(form4.listbox1.Items[i])) + plus);
                  value:= strtoint(trim(form4.listbox1.items[i]));
                  form4.ListBox1.items[i]:= inttostr(1);
                  zahl:= 1;
                  arr[i][zahl]:= cnt;
                  arr[i][0]:= 0;
                  inc(i);
                end;
        end;
      For i:=form4.ListBox1.Items.count downto 0 do
          begin
            <span style="color: red">cnt2:= arr[i][1];</span>
              if cnt2 > 0 then
                begin
                  dec(cnt);
                  form4.listbox1.Items.insert(i,inttostr(1));
                end;
          end;

     For i:=form4.ListBox1.Items.count downto 0 do
          begin
            cnt2:= arr[i][0];
              if cnt2 > 0 then
                begin
                  dec(cnt);
                  form4.listbox1.Items.insert(i,inttostr(0));
                end;

          end;
end;



Das Problem kommt bei der zweiten Schleife, wenn ich "cnt2" eingelesen wird.( Im Projekt project1.exe ist eine Exception der Klasse EAccesViolation aufgetreten. Meldung: Zugriffsverletzung bei Adresse 004C057E. Lesen von Adresse 000004C2 aufgetreten). Demzufolge denke ich, dass das Problem bei dem Array liegt.

Woran könnte das liegen?? Wie könnte man das lösen??

Braucht ihr noch Informationen??

Vielen Dank im Vorraus!


Moderiert von user profile iconNarses: Topic aus Dateizugriff verschoben am Mo 22.12.2008 um 13:20
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mo 22.12.08 14:07 
Abgesehen davon, dass deine Formatierung absolut grausig ist, probiers mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  k:= form4.listbox1.items.count;
  Setlength(arr, k, k); 
[...]
For i:= (form4.ListBox1.Items.count - 1) downto 0 do
  begin
     [...]

Grüße,
Marc
Ulixes Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 63

Win Vista Home Premium
Delphi 2009 Professional, XHTML, CSS, PHP
BeitragVerfasst: Mo 22.12.08 14:29 
Danke!!

Mir ist aber gerade ein inhaltlicher Fehler aufgefallen... :oops: