Autor Beitrag
skall
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 15:54 
und nochmal hallo :D

Ich versuche von einem String herauszufinden, wieviele Zeichen in diesem sind bis ein Leerzeichen kommt...

Wenn mir da jemand einen Tipp zu geben könnte :)

Danke im Vorraus
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mo 26.01.09 15:55 
Probier es doch mal mit der Pos-Funktion. ;-)

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 15:58 
einfach mal sowas wie:

ausblenden Delphi-Quelltext
1:
k := Pos(#32; buffer);					

?
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mo 26.01.09 16:03 
oder so: ;-)

ausblenden Delphi-Quelltext
1:
  k := Copy(SourceString,0,Pos(' ',SourceString));					


Sollt bei diesem string: 'HAllo ich bins' als rückgabe (also im k) haben: 'HAllo'.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 16:12 
ist es auch möglich nach mehreren Zeichen zu suchen?

Nach na XOR spezifikation...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 26.01.09 16:18 
Wie meinst du das? Mehrere gleiche Zeichen?
Dann kannst du ab ein Zeichen nach der letzten Fundstelle weitersuchen mit PosEx.

Was das mit XOR zu tun hat ist mir allerdings nicht so klar.
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 16:33 
Naja halt wenn endweder ein Leerzeichen kommt oder ein Tab, dann soll er das nehmen...

hmm Hab das dann glaube iwie verwechselt mit dem xor ^^ passiert...


Wobei das iwie komisch gerade ist :S
Nach der ersten Zahl die ich da raus haben will kommt ein tab... dadurch lässt sich damit nicht als Integer weiter arbeiten anscheint... :S
der organist
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 467
Erhaltene Danke: 17

WIN 7
NQC, Basic, Delphi 2010
BeitragVerfasst: Mo 26.01.09 16:37 
Naja, es können halt nich mehrere gleichzeitig vorkommen, aber ein OR reicht da vollkommen aus

_________________
»Gedanken sind mächtiger als Waffen. Wir erlauben es unseren Bürgern nicht, Waffen zu führen - warum sollten wir es ihnen erlauben, selbständig zu denken?« Josef Stalin
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 16:41 
Eine Frage noch...

Ich habe jetzt die länge des Strings bis das gesuchte zeichen kommt... Allerdings ist das Zeichen, hier: Tab, mit in dem kopierten String drin... kann ich das auch kopieren ohne den Tab mit drin?
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 26.01.09 16:42 
Kopier halt ein Zeichen weniger..

_________________
PROGRAMMER: A device for converting coffee into software.
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 26.01.09 16:43 
user profile iconskall hat folgendes geschrieben Zum zitierten Posting springen:
Ich habe jetzt die länge des Strings bis das gesuchte zeichen kommt... Allerdings ist das Zeichen, hier: Tab, mit in dem kopierten String drin... kann ich das auch kopieren ohne den Tab mit drin?

Zeig mal Deinen Code, wie Du den Text kopierst.

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 16:50 
ausblenden Delphi-Quelltext
1:
k := Length(Copy(buffer,0,Pos(#9, buffer)));					
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 26.01.09 16:52 
  1. Ab 1 kopieren, nicht ab 0, ein String fängt bei Zeichen Nummer 1 an.
  2. Wie gesagt von dem Ergebnis von Pos einfach 1 abziehen, damit du ein Zeichen weniger kopierst.
Aber wozu Length? Das hast du doch sowieso schon mit Pos? :shock:


Zuletzt bearbeitet von jaenicke am Mo 26.01.09 16:53, insgesamt 2-mal bearbeitet
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 26.01.09 16:52 
Der dritte Parameter von Copy ist die Anzahl der Zeichen..
ausblenden Delphi-Quelltext
1:
k := Length(Copy(buffer,0,Pos(#9, buffer)-1));					


Aber ganz ehrlich: Wenn dich sowieso nur die Länge des Ganzen interessiert, kannst du doch direkt das Ergebnis von Pos nehmen, und dir den Kram mit Copy sparen?

_________________
PROGRAMMER: A device for converting coffee into software.
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 16:55 
naja ohne Length bekomm ich den String... aber ich brauch die Länge des Strings :o
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Mo 26.01.09 16:59 
Dann brauchst du weder Length, noch Copy. Da reicht Pos() - 1 ;-)

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Mo 26.01.09 17:00 
user profile iconskall hat folgendes geschrieben Zum zitierten Posting springen:
naja ohne Length bekomm ich den String... aber ich brauch die Länge des Strings :o

Die Länge des Strings ist doch gleich der Position des ersten Auftretens des Leerzeichens (-1).
So wie Du es machst, ist es irgendwie, wie wenn man sich durch den Hintern in der Nase bohrt... :D

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 17:02 
Na damit hat der Post doch überhaupt erst angefangen :D:D:D
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 26.01.09 17:04 
user profile iconelundril hatte vermutet, dass du den entsprechenden String kopieren willst, und deshalb dies darunter geschrieben. Rein zur Positionsfindung war dein Code davor schon richtig (außer dem Semikolon statt Komma). ;-)
skall Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38



BeitragVerfasst: Mo 26.01.09 17:06 
Nochmal ne kurze doofe Frage hinten ran :S

Addition klappt doch normal mit x := y + z oder??

Weil bei mir kommt dabei x := y yz raus...

Oder verständlicher: :D

Wert := Wert + 283
kommt nahc dem zweiten mal: 283566 raus ôO


Zuletzt bearbeitet von skall am Mo 26.01.09 17:10, insgesamt 1-mal bearbeitet