Autor Beitrag
ingo.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Mo 24.01.05 16:08 
Hy,

ich kenne von der PHP-Programmierung den +=Operand (weiß nicht wie der namentlich heisst), der es ermöglicht z. B. an einen String, einen weiteren anzufügen:

ausblenden Delphi-Quelltext
1:
2:
3:
$string = "hallo";
$string += " du";
// $string jetzt belegt mit "hallo du";


Wollte nun fragen ob es sowas für Delphi gibt. Finde nämlich diese Methode ein wenig 'schreibintensiv':
ausblenden Delphi-Quelltext
1:
2:
 Memo1.Text:='hallo';
 Memo1.Text:=Memo1.Text+' du';
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Mo 24.01.05 16:12 
ich dachte bei strings in php geht sowas so :
ausblenden Quelltext
1:
2:
$String = "Hallo ";
$String .= "du";

und das += ist doch:
ausblenden Quelltext
1:
2:
3:
4:
$x = $x + 5; 
//kann man auch als
$x += 5;
//schreiben


mfg matze

_________________
si tacuisses, philosophus mansisses.


Zuletzt bearbeitet von matze.de am Mo 24.01.05 16:16, insgesamt 2-mal bearbeitet
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Mo 24.01.05 16:15 
+= in java kann man zum addieren udn anfügen von strings nehmen

in delphi gibt es sowas leider nicht
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: Mo 24.01.05 21:22 
Für Zahlen kannst Du Inc(X, 5); nehmen ...

BTW: Wenn Du in PHP mit + Strings zusammenführst, wird die PHP garantiert ne Warnung ausgeben ;-)

_________________
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.
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Mo 24.01.05 21:36 
BenBE hat folgendes geschrieben:

BTW: Wenn Du in PHP mit + Strings zusammenführst, wird die PHP garantiert ne Warnung ausgeben ;-)


ich sag doch strings mit ".=" erweitern :D

_________________
si tacuisses, philosophus mansisses.
ingo. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 37



BeitragVerfasst: Di 25.01.05 14:33 
Ahrgs,

ja '+=' war bei JavaScript z. B. document.forms[0].elements[0].value+="hinzu";.
.= bei PHP :)

schade das sowas nicht in Delphi gibt.
ScorpionKing
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1150

Win XP

BeitragVerfasst: Di 25.01.05 14:58 
Mach doch folgendes:

ausblenden Delphi-Quelltext
1:
string := Conact(string,' du');					


das müsste klappen, ist aber somit gesehen eigentlich schwachsinn, da folgendes einfacher ist:

ausblenden Delphi-Quelltext
1:
string := string + ' du';					


MfG, Scorpion!

_________________
Aus dem Urlaub zurück!
MitschL
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 211

Win 98 SE, Win 2000
D5 Pers, D6 Pers und D7 Pro
BeitragVerfasst: Di 25.01.05 15:10 
Oder,
du nimmst eine globale ( :puke: ) Methode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure MCC( var s1,s2: String );
begin 
  s1 := s1 + s2;
end;

und hätt'st dann:
MCC( Memo1.Text, 'du' ); :arrow: :shock: :idea: :shock:

Naja ... Nich so toll, oder?

gegrüßt!

_________________
"Bloßes Ignorieren ist noch keine Toleranz." (Theodor Fontane)
I.MacLeod
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 109



BeitragVerfasst: Di 25.01.05 15:28 
Da TMemo.Text ne gekapselte Property ist geht das nicht. (Und auf eine Wiederholung der "alles-was-global-im-Namen-hat-ist-böse"-Diskussion hab ich gerade keine Lust, abgesehen davon dass es OT ist :roll:)
MitschL
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 211

Win 98 SE, Win 2000
D5 Pers, D6 Pers und D7 Pro
BeitragVerfasst: Di 25.01.05 16:18 
Ähm,

der Sinn nach einer Diskussion stand mitnichten in meinem Post. :?

Daß ich ein dummes Beispiel wählte, unterstrich die Stilblüte nur.

gegrüßt!

_________________
"Bloßes Ignorieren ist noch keine Toleranz." (Theodor Fontane)