Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi aus char in bestimmen index eines string kopieren (https://www.delphipraxis.net/111112-aus-char-bestimmen-index-eines-string-kopieren.html)

mkinzler 29. Mär 2008 20:50

Re: aus char in bestimmen index eines string kopieren
 
Die AV könnte auch woanders auftreten.

Klaus01 29. Mär 2008 20:52

Re: aus char in bestimmen index eines string kopieren
 
Es scheint das txt2 in der Länge nicht mit txt1 übereinstimmt.
Dann kann es zu dem Fehler kommen das auf ein Index von txt2 zugegriffen wird
der nicht vorhanden ist.


Delphi-Quellcode:
 
  for f:=1 to length(txt1) do
    begin
      k:=k+1;
      if k>length(pass)then
        begin
          k:=1;
          n:=n+1;
          if n>10 then
            n:=1;
        end;
      if (ord(txt1[f])>96) and (ord(txt1[f])<123)then
        begin
          i:=0;
          j:=0;
          repeat
             j:=j+1
          until X[n,j,1]=txt1[f];
          repeat
            i:=i+1 until X[n,1,i]=pass[k];

          if length(txt2) >= f then
            txt2[f]:=X[n,j,i]; //geht nicht
        end
      else
        if length(txt2) >= f then
          txt2[f]:=txt1[f]; //geht auch nicht!!
    end
Grüße
Klaus

dj-f 29. Mär 2008 20:56

Re: aus char in bestimmen index eines string kopieren
 
das kan natürlich sein...txt2 ist ja noch vollich lehr.
...muss ich dann so was nehmen wie setlength oder so?

Klaus01 29. Mär 2008 20:57

Re: aus char in bestimmen index eines string kopieren
 
Delphi-Quellcode:
txt2:='';
for i:=1 to length(txt1) do
  txt2:= txt2 + ' ';
Grüße
Klaus

dj-f 29. Mär 2008 21:01

Re: aus char in bestimmen index eines string kopieren
 
es tuht sich was:
[Warning] Unit1.pas(201): FOR-Loop variable 'i' may be undefined after loop
[Hint] Unit1.pas(195): Value assigned to 'i' never used

Klaus01 29. Mär 2008 21:03

Re: aus char in bestimmen index eines string kopieren
 
Versuche mal das:

Delphi-Quellcode:
while length(txt2) < length(txt1) do
  txt2 := txt2 + ' ';
Grüße
Klaus

wido 29. Mär 2008 21:04

Re: aus char in bestimmen index eines string kopieren
 
Performancetechnisch gesehen ist die Routine Selbstmord. Ein einfaches SetLength(txt2, length(txt1)) sollte es auch tun :).

dj-f 29. Mär 2008 21:05

Re: aus char in bestimmen index eines string kopieren
 
sry habs an der falscen stelle eingefügt ...es klappt...da war das also so einfach :wall: :wall: :wall: :wall: :wall: :wall: :wall: :wall: :wall:


vielen, vielen dank.


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:27 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz