Autor Beitrag
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Di 18.02.03 12:19 
Morje... ähnliche Frage gabs zwar schonma, aber mich interessiert dann doch eher das fortgeschrittene Prob:

Wenn ich eine Zahl um 'n' erhöhen will, geht das nur über den umständlichen Weg:
ausblenden Quelltext
1:
2:
3:
4:
5:
Variable := Variable + 5;

bzw.

Variable := Variable - 4;


oder gibts da auch sowas wie bei den Strings: Add?
In der Delphi-Hilfe hab ich dazu leider nix gefunden, und ich muss eine Variable rnd. 15 mal mit verschiedenen Zahlen inkrementieren, und wollt mir daher das Code-Gewühl ersparen...

mfG
kiwicht
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 18.02.03 12:24 
Hallo, schau dir inc und dec an.
ausblenden Quelltext
1:
2:
3:
4:
inc(Variable);  //Variable+1
inc(Variable,5);
inc(Variable,-5);
dec(Variable,4);


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
DaRkFiRe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 526

WinXP Home & Professional
C, C++, Delphi
BeitragVerfasst: Di 18.02.03 14:12 
Weiß nicht, was an dieser einen Zeile Variable := Variable - 5; so umständlich sein soll!? Wo liegt das Problem!?

_________________
Lang ist der Weg durch Lehren - kurz und wirksam durch Beispiele! Seneca
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Di 18.02.03 14:18 
Hallo,
kiwicht hat folgendes geschrieben:
oder gibts da auch sowas wie bei den Strings: Add?

bei Strings kenne ich kein Add, nur bei tStrings, das ist aber etwas anderes als:
ausblenden Quelltext
1:
MyStr := MyStr + ' Hallo';					

Für Strings gibt es noch Concat.

Gurß
Klabautermann
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: Di 18.02.03 14:21 
Hallo,

die Tipps von Keldorn gelten nur für Integer!!

Bei Float-Typen und Eigenschaften von Objekten, bleibt Dir gar kein anderer Weg als Wert:=Wert+Increment.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Di 18.02.03 14:39 
genau, kiwicht hat ja auch nach integer gefragt .

Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
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: Di 18.02.03 14:41 
Hallo,

alles klar, steht ja in der Überschrift.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Di 18.02.03 20:59 
Man könnte für floats aber leicht eine eigene funktion "bauen"...

:D

Fiji-Fighter
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Di 18.02.03 21:00 
könnte man machen, aber hier gehts doch um integer :roll:
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Di 18.02.03 21:08 
smiegel hat folgendes geschrieben:
Hallo,

die Tipps von Keldorn gelten nur für Integer!!

Bei Float-Typen und Eigenschaften von Objekten, bleibt Dir gar kein anderer Weg als Wert:=Wert+Increment.


Hätte schon vorher quoten sollen...

mir gings um obige Aussage...

Fiji-Fighter
kiwicht Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Mi 19.02.03 08:33 
huii... was für ne resonanz... erstmal vielen dank dafür! :D :D

also:

@keldorn: danke, werd ich gleich ma ausprobieren.... ich dachte inc und dec sind DEFINITV nur für standard-inkrementierung, deswechen hab ich mir dazu auch nicht die hilfe reingezogen... hätt ich ma tun solln... :roll:

@darkfire: ist doch doch ganz offensichtlich, welche methode kürzer ist, und ich brauche diese Funktion (sehr) oft, das spart also ne menge tippzeit und quell-code

@klabautermann: naja, stimmt schon, ist zwar nicht das gleiche, aber äquivalent zu dem inc(xxx,n)-befehl ist schon irgendwie...

@fiji-filter: naja, ehrlich gesagt, ich benutz keine echten integer, eigentlich nur ganze zahlen von 0 - 32 in 2´er abständen, aber damits mit dem "inc" klappt, lass ich die auch als integer durchgehen... ;) aber ich werd drüber nachdenken... :)

@ die andern: vielen dank für die mühen

mfg
kiwicht
DaRkFiRe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 526

WinXP Home & Professional
C, C++, Delphi
BeitragVerfasst: Mi 19.02.03 15:28 
Ich will ja keine Verwirrung stiften, aber INC und DEC gelten auch für Zeiger! *mich-duck*

Ja, das mit der Schreibarbeit ist schon richtig! Gut, ich bevorzuge bei einstufiger De-/Inkrementation auch DEC und INC, aber wenn mal mehr aufaddiert werden muss, dann überlade ich die Methode nicht, sondern schreibe es aus.

_________________
Lang ist der Weg durch Lehren - kurz und wirksam durch Beispiele! Seneca
kiwicht Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Do 20.02.03 12:14 
je suis "verwirrt"... :lol:
DaRkFiRe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 526

WinXP Home & Professional
C, C++, Delphi
BeitragVerfasst: Do 20.02.03 14:14 
Ce n'etait pas mon "Absicht" *g*

_________________
Lang ist der Weg durch Lehren - kurz und wirksam durch Beispiele! Seneca