Autor Beitrag
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Mo 30.06.08 18:45 
Ich habe jetzt schon bei mehreren Programmen Probleme damit gehabt und es letztendlich mit einer Zählerschleife umgangen. Entweder bin ich zu dumm und mache einen Cardinalen Fehler oder die Methode ist evtl wirklich fehlerhaft...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
function TInterpreter.Order(line: string) : String;
var
 i,NumC   : integer;
 FrLine   : Array[1..1000] of String;
 ObCount  : integer;
begin
 Numc    := 0;
 ObCount := 0;
 for i := 1 to length(line) do
 begin
  if (ord(Line[i]) > 47) and (ord(Line[i]) < 58)  then
   inc(NumC,1)
  else
  begin
   inc(ObCount,1);
   Frline[ObCount]:=Copy(Line,I-NumC,I-1);
   showmessage(Frline[ObCount]);
   NumC:=0;
  end;
 end;
...
end;


Diese Funktion soll nur alle Zahlen aus einem String auslesen und dann in ein Array schreiben.
Die Zahlen sind jeweils nur durch ein Zeichen Unterbrochen.

Die Erste Zahl ist auch komplett richtig aber bei der Nächsten Zahl kommt dann nur quatsch bei raus -.-

Er kopiert die Zahl richtig + den Rest des Strings bis zum ende, aber erst immer ab der zweiten Zahl -.-
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 30.06.08 19:00 
Probier mal so:
ausblenden Delphi-Quelltext
1:
Frline[ObCount]:=Copy(Line[1],I-NumC,I-1);					


Edit: Äh, ne. Ich glaube, ich war grade in einer ganz anderen Funktion. :oops:

_________________
We are, we were and will not be.


Zuletzt bearbeitet von Gausi am Mo 30.06.08 19:02, insgesamt 1-mal bearbeitet
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 30.06.08 19:01 
Hallo,

schau Dir mal an was die Delphi-Hilfe schreibt:
ausblenden Delphi-Quelltext
1:
function Copy(S: string; Index, Count: Integer): string;					

Copy gibt einen String zurück, der Count Zeichen ab S[Index] enthält.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Jerk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Mo 30.06.08 19:01 
@Gausi
Das würde ja bedeuten das der String fürs Copy nur ein Zeichen hat -.-
Funktioniert auch leider nicht :(


@Lanes

Frline[ObCount]:=Copy(Line,I-NumC,NumC);

Jo das wars danke!!!

Ich bin aber der Meinung das es mal String,Von,Bis war...
Naja vielen Dank!!!
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 01.07.08 10:33 
Ne, das von\Bis ist Java ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.