Autor Beitrag
DiamondDog
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Fr 25.07.08 09:21 
Hallo Leute,
ich hab da folgendes Problem, ich weiß zwar wie man einen Text auf eine bestimmte Zeichenzahl begrenzt nur hab ich jetzt das Problem das es nicht nur ein Text ist sondern mehrer.
Also ich hab da ein mal SenderNick der unterschiedlich lang ist und MsgText.
Alles in allem darf nur 40 Zeichen lang sein.
Ist jetzt der Nick oder die Nachricht länger soll der Text abgeschnitten werden und am Ende ... eingefügt werden ziwschen Nick und MsgText steht noch ': ' das ist aber unveränderlich, bleibt also immer gleich lang.
So sieht meine Ausgabe zur Zeit aus:
ausblenden Delphi-Quelltext
1:
Form1.WebBrowser1.Navigate('http://' + Edit1.Text + '/control/message?popup=' + plug.SenderNick + ': ' + plug.MsgText);					
wäre Super wenn mir da jemand Helfen könnte.
Danke schon mal.
Mfg Dog
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Fr 25.07.08 09:43 
Einfach Zwischenspeichern in eine Variable mit Länge 40

_________________
Markus Kinzler.
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Fr 25.07.08 10:05 
geht das nicht auch einfacher?
Ich muß doch eigendlich nur:
SenderNick + MsgText = Ergebniss1
Ergebniss1> 40 dann
40 - Ergbniss = Zulang

und alles was dann Zulang ist wird von MsgText abgeschnitten

Versuchs mal wenns Falsch ist bitte Korigieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
...
var a,b,c,d:integer;
...
SenderNick:= Length(a);
MsgText:= Length(b);
c:=(a+b);
if c>40 then c-40:=d
Msg:=MsgText[d]
so irgend wie würd ich das jetzt machen nur hab keine Ahnung ob das so richtig ist.
Würe super wenn es wer koriegieren könnte.
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Fr 25.07.08 10:39 
text begrenzen sollt doch recht einfach sein ;)

begrenztertext:=copy(ganzertext,1,maximum);

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Fr 25.07.08 11:02 
ah ok jetzt hab ich es:
ausblenden Delphi-Quelltext
1:
2:
    NickandMsg:=copy(plug.SenderNick + ': ' + plug.MsgText,1,37);
    Form1.WebBrowser1.Navigate('http://' + Edit1.Text + '/control/message?popup=' + NickandMsg + '...');
Das funktioniert 1000 Dank.
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: Fr 25.07.08 11:26 
Oder - und das ist IMHO das, was mkinzler meinte:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  Short: String[37];
begin
  Short := plug.SenderNick + ': ' + plug.MsgText;


Delphi schnippelt das dann automatisch auf 37 Zeichen. Vorteil: schneller (mehr als doppelt), aber hier natürlich nicht bemerkbar.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)