Autor Beitrag
Freeman_6
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Mo 18.10.04 22:33 
gibt es eine möglichkeit, mit derman allen unterbereichen eines dynamischen arrays of string '' zuweisen kann und die einfacherer ist als folgende?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var 
arraystring : array of string;
i : integer;
...
setlength(arraystring,10);

FOR i:=0 TO length(arraystring)-1 DO
arraystring[i]:='';


danke und mfg

Freeman_6

edit: jetzt stimmt der code, danke an Christian S.

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.


Zuletzt bearbeitet von Freeman_6 am Mo 18.10.04 23:15, insgesamt 1-mal bearbeitet
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 18.10.04 22:35 
Hallo!

Mir fällt kein besserer Weg ein. Aber Dein Code ist fehlerhaft. Der Index läuft bis Length(...)-1, weil die Indizierung bei 0 beginnt.

MfG
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
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 18.10.04 23:50 
Ansonsten kannst du die Funktion High Verwenden. Die erledigt diese Anpassung automatisch:

ausblenden Delphi-Quelltext
1:
For X := 0 To High(DeinArray) do ...					


Aber es gibt nicht wirklich eine bessere Möglichkeit.

_________________
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.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Di 19.10.04 05:51 
Die durch SetLength allozierten Speicherbereiche werden doch mit 0ern aufgefüllt?
So ist die Schleife doch eigentlich gar nicht nötig, da der String eh "leer" ist. :gruebel:

_________________
JSXGraph