Autor Beitrag
Ice
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 31.01.03 09:49 
Hallo Leute,

ich habe folgendes Problem:
Ich suche in einem String nach Leerzeichen und zerhacke den String vor jedem dieser Leerzeichen und lese dann diesen SubString in ein Record. Mein Problem ist nun wie bekomme ich den letzten Substring in dieses Record ohne hinter ihm noch ein Leerzeichen einzugeben?
vielen dank für die Hilfe schonmal im voraus.

mfg Ice
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Fr 31.01.03 09:52 
Poste mal Deinen Code, dann kömmer was sagen. Aber ich würde Dir empfehlen, die Laufvariable mit der Anzahl der Zeichen im String zu vergleichen. Wenn Du dann am Ende angelangt bist, den String noch hinzufügen. Also zwei Bedingungen in if mit OR verknüpft.

Gruß
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 31.01.03 10:14 
Danke für den Tip. Hier der Code:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
var
 i,k,x : shortint;
 handlestr1,handlestr2 : shortstring;
begin
 handlestr1 := Edit1.text;
 for i := 0 to length(Edit1.Text) do
  begin
    k := pos(' ',handlestr1);
    handlestr2 := copy(handlestr1,0,k-1);
    handlestr1 := copy(handlestr1,k+1,length(HandleStr1));
    StringSet[i]:=HandleStr2;
  end;
 for x := 0 to 64 do
  begin
   Memo1.Lines.Add(StringSet[x]);
  end;
end;


mfg Ice

Moderiert von user profile iconKlabautermann: Code-Tags hizugefügt.
foxy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Fr 31.01.03 10:34 
wenn ich ma fragen darf, geht es dir nur darum die leerzeichen weg zu bekommen??
also würdest duStringSet[i]:=HandleStr2+HandleStr1;
machen wenn ja dann hab ich netten code für dich ... wenn du das getrennt auflisten willst in deiner memo dann sag nomma bescheit pls

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Fr 31.01.03 10:41 
Hallo,

so müsste es gehen:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
var 
  i,k : shortint; 
  handlestr1: shortstring; 
begin 
  handlestr1 := Edit1.text; 
  i:=0;
  repeat
    k:=pos(' ', handlestr1); 
    if (k>0) then
    begin
      StringSet[i]:=copy(handlestr1, 1, k-1);
      System.Delete(handlestr1, 1, k);
      Inc(i);
    end; // if
  until (k=0);
  if (Length(handlestr1)>0) then StringSet[i]:=handlestr1;

  for x := 0 to 64 do 
  begin 
   Memo1.Lines.Add(StringSet[x]); 
  end; // for i
end;

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 31.01.03 11:00 
@foxi: Nein das wird alles einzeln aufgelistet , das sollen hexadezimale Zeichen sein z.B. FF 8 bit lang und werden dann nachdem sie einzeln in das Byte Format umgewandelt wurden zur RS232 gesendet. deswegen brauche ich sie einzeln und ohne Leerzeichen.
@smiegel : vielen Dank für den Code, funktioniert prächtig... :D

euch beiden nochmal vielen Dank für die Schnelle Antwort

mfg Ice