Autor Beitrag
FlameDiver
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 15:39 
also ih möchte den text eines eingabefeldes in ein array packen.
geht das einfach mit arrayvar := edit1.text?

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Mo 01.11.2004 um 09:43

_________________
From Hell and back again
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: So 31.10.04 15:41 
Nein, aber so ähnlich. Was ist denn arrayvar für ein Array? Allgemein kannst du dir schonmal den Befehle Move anschauen.

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
FlameDiver Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 15:43 
array of string

_________________
From Hell and back again
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: So 31.10.04 15:49 
FlameDiver hat folgendes geschrieben:
array of string

:shock:

ausblenden Delphi-Quelltext
1:
arrayvar[index]:=edit1.text					

Da ich jetzt nicht weiß, wie fit du im Umgang mit dynamischen Arrays bist, sag ichs mal vorsorglich: Achte auch drauf, dass du vorher die Arraylänge festlegst.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
FlameDiver Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 15:53 
also

ausblenden Delphi-Quelltext
1:
2:
var
text1:array[0..20of String;


vieleicht sollte ich noch sagen das ich jeden buchstaben als einzelnes array element haben will
edit1.text = asdasd
also soll das erste array element a das 2te s und das 3 d und so weiter sein

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

_________________
From Hell and back again
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: So 31.10.04 15:59 
Das ist aber schon ganz schön gewaltig was anderes als ein "array of string":
ausblenden Delphi-Quelltext
1:
arrayvar : array[0..20of Char;					

Die Zuweisung von dem String kannst du nicht direkt machen. Hier hilf das von mir schon angesprochene Move:
ausblenden Delphi-Quelltext
1:
Move(Edit1.Text[1],arrayvar[0],21);					

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Luzzifus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 200

Win2K
D6 Prof
BeitragVerfasst: So 31.10.04 16:02 
dann würde aber ein array of char reichen:
ausblenden Delphi-Quelltext
1:
2:
var  
  text1: array of Char;


dann kannst du das so zuweisen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure bla(S: String);
begin
  SetLength(text1, S);
  for i:=1 to length(S) do 
    text1[i]:=S[i];
end;


da aber ein string eigentlich auch nix anderes ist als ein array of char, kannst du auch direkt über den element-index auf die einzelnen buchstaben des strings zugreifen (S[i], siehe prozedur), je nachdem was du damit machen willst, brauchst du dein array also gar nicht.


**edit: da war jemand schneller ^^''


Zuletzt bearbeitet von Luzzifus am So 31.10.04 16:02, insgesamt 1-mal bearbeitet
FlameDiver Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 16:02 
ok besten dank :D
jetzt gehts so wie ichs mir vorgestellt hab

_________________
From Hell and back again
FlameDiver Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 16:12 
ähm noch ne frage wie "leere" ich einen array den wieder?

_________________
From Hell and back again
Luzzifus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 200

Win2K
D6 Prof
BeitragVerfasst: So 31.10.04 16:18 
bei dynamischen arrays hast du dieses problem nicht, da das array (wenn du das vernünftig programmierst) immer nur so lang ist, wie auch wirklich elemente darin sind.

bei statischen arrays musst du's manuell machen, das sieht für ein array of char z.b. so aus:
ausblenden Delphi-Quelltext
1:
2:
for i:=0 to length(array1)-1 do
  array1[i]:=CHR(0);
FlameDiver Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 16:24 
ausblenden Delphi-Quelltext
1:
2:
for i:=0 to length(array1)-1 do
  array1[i]:=CHR(0);

das geht nicht wenn ich den array danach ausgebe ist er immernoch "voll"


*edit* ups ne sorry war wo andres der fehler

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

_________________
From Hell and back again


Zuletzt bearbeitet von FlameDiver am So 31.10.04 16:26, insgesamt 1-mal bearbeitet
Luzzifus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 200

Win2K
D6 Prof
BeitragVerfasst: So 31.10.04 16:26 
inwiefern voll? :shock:
FlameDiver Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 104

WIN XP
D6 Pers
BeitragVerfasst: So 31.10.04 16:31 
es sind noch elemente drin aber das war ein anderer fehler wo ich ne variable ned zurück gesetzt hab

_________________
From Hell and back again