Autor Beitrag
ialla
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Mi 08.02.06 21:51 
Hallo Leute :-)

ich habe eine Prozedur die m.E. nach call by Value aufgerufen wird:

Zitat:

procedure TForm1.SaveToFileVerschluesselt(DateiName : string; ListenName : TStringList);


die ich so aufrufe:
Zitat:

SaveToFileVerschluesselt(datei, Liste);


datei ist eine Konstante in welcher der Dateiname steht in der gespeichert werden soll. Liste ist eine globale Variable vom Typen TStringList. Sobald ich die Prozedur aufgerufen habe, ist die Variable Liste verändert. Innerhalb der Prozedur wird die Liste linear verschoben und dann gespeichert um den Inhalt unleserlich zu machen :-)
Aber die globale Variable Liste wird darin nicht verwendet.
Was mache ich falsch?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 08.02.06 22:02 
Kompliziertere Datentypen werden als Referenz übergeben, auch wenn das nicht explizit angegeben wird. D.h. es wird nicht die komplette Liste auf den Stack kopiert.

_________________
We are, we were and will not be.
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Mi 08.02.06 22:04 
Hallo,

danke für deine Antwort. D.h. ich muss in der Prozedur ne Kopie der Variable erstellen und die dann verändern?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 08.02.06 22:09 
Für den String nicht, der wird zwar auch nur als Zeiger übergeben, aber automatsich umkopiert, wenn man ihn ändert (ist bei Strings ja generell so).

Ansonsten: Ja. Du muss du Liste in eine neue Liste kopieren und diese dann verändert abspeichern. Evtl. ist es aber sinnvoller, die Strings einzeln aus der Liste zu ziehen, diese zu verändern und zu speichern. Kommt drauf an, wie deine "Verschlüsselung" genau aussieht...

_________________
We are, we were and will not be.
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Mi 08.02.06 22:15 
Moin,

naja ist nur eine lineare Verschiebung *g*

ok dank dir wieder was dazugelernt :-)
schönen Abend noch