Autor Beitrag
Smartie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Mo 25.04.05 14:28 
Servus!

Also, es hat ja wunderbar geklappt mit dem aus der Ini lesen. Die ganze sache sah so aus:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
procedure TForm1.Button1Click(Sender: TObject);
var datei, F, rein, BN, Name, Byte, Format, Bereich, KonvertFormat : String;
    exparr: TStringDynArray;
    zeilenarr : TZStringArr;

begin
     // testen wir mal mit dem TString den Zugriff auf die ini
    if opendialog1.execute then
      datei := opendialog1.FileName

      else datei := '';

    begin
      MySList := TStringList.Create;
      MySList.LoadFromFile(datei);

      //Schau mer mal wies mit den einzelen Zeilen aussieht
      for X := 0 to MySList.Count-1 do
      zeilenarr[x] := MySList.Strings[x];

      MySList.Free;
    end;

    exparr := explode('||', zeilenarr[3]);

    F := exparr[0];
    BN := exparr[1];
    Name := exparr[2];
    Byte := exparr[3];
    Format := exparr[4];
    Bereich := exparr[5];
    KonvertFormat := exparr[6];


    label1.Caption := 'Funktion: ' + F;
    label2.Caption := 'Byte_Nr : ' + BN;
    label3.Caption := 'Name : ' + Name;
    label4.Caption := 'Bytes : ' + Byte;
    label5.Caption := 'Format : ' + Format;
    label6.Caption := 'Bereich : ' + Bereich;
    label7.Caption := 'Konvert.Format: '+ KonvertFormat;

end;


So, das war ja zu Testzwecken recht nett. Inzwischen möchte ich damit aber weiterarbeiten, und woltle das ganze in eine Funktion setzen. Nun sieht das ganze so aus:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
function INIlesen : String;
var datei, F, rein, BN, Name, Byte, Format, Bereich, KonvertFormat : String;
    exparr: TStringDynArray;
    zeilenarr : TZStringArr;

begin

    if opendialog1.execute then
      datei := opendialog1.FileName

      else datei := '';

    begin
      MySList := TStringList.Create;
      MySList.LoadFromFile(datei);

      for X := 0 to MySList.Count-1 do
      zeilenarr[x] := MySList.Strings[x];

      MySList.Free;
    end;

    exparr := explode('||', zeilenarr[3]);

    F := exparr[0];
    BN := exparr[1];
    Name := exparr[2];
    Byte := exparr[3];
    Format := exparr[4];
    Bereich := exparr[5];
    KonvertFormat := exparr[6];

    return: F, BN, Name, Byte, Format, Beriech, KonvertFormat;

end;


Jetzt meine ganz blöde Frage:

Wieso funktioniert das nicht?

Danke & Lieben Gruß

Smartie

Moderiert von user profile iconGausi: Code- durch Delphi-Tags ersetzt.
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: Mo 25.04.05 14:35 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
function INIlesen : String;
var datei, F, rein, BN, Name, Byte, Format, Bereich, KonvertFormat : String;
    exparr: TStringDynArray;
    zeilenarr : TZStringArr;

begin
// opendialog dürfte hier nicht bekannt sein. daher probier mal
    with form1 do 
   if opendialog1.execute then
      datei := opendialog1.FileName

      else datei := '';
    // ich hoffe mal, dass dir klar ist, dass dieses begin hier völlig nutzlos ist...
    // was möchtest du mit diesem Block?
    begin
      MySList := TStringList.Create;
      MySList.LoadFromFile(datei);

      for X := 0 to MySList.Count-1 do
      zeilenarr[x] := MySList.Strings[x];

      MySList.Free;
    end;

    exparr := explode('||', zeilenarr[3]);

    F := exparr[0];
    BN := exparr[1];
    Name := exparr[2];
    Byte := exparr[3];
    Format := exparr[4];
    Bereich := exparr[5];
    KonvertFormat := exparr[6];
    //der Rückgabewert ist vom Typ String, also sollte das
    return: F, BN, Name, Byte, Format, Beriech, KonvertFormat;
    //irgendwie so aussehen
    result:= F+','+ BN +','+ Name +','+ Byte +','+ Format +','+ Beriech +','+ KonvertFormat;
end;

Mehr Sachen fallen mir auf Anhib nicht auf. Zumindest nicht ohne einen Hinweis, was denn für Fehlermeldungen kommen...

_________________
We are, we were and will not be.
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Mo 25.04.05 14:48 
Danke, aber... wenn ich den Result so mache, wie du es vorschlägst, dann ist der Result wieder nur ein doofer String. GENAU Das hab ich ja verhindern wollen, und will JEDE dieser Variablen einzeln wieder nutzen können.

Oh... ähm... wärs dann evtl. günstiger, dies (BN, Byte, format...) als globale Variablen du deklarieren, und das ganze als Prozedur laufen zu lassen, weil ich dan nkeinen Rückgabewert benötige?

Lieben Gruß

Smartie
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: Mo 25.04.05 15:04 
du kannst in etwa so tun:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
type TmeineDaten
F:string;
BN:string;
//...
end;
//...
function INIlesen:TmeineDaten;
begin
//der ganze Code, wo du aus der ini das array ausliest
//und dann in etwa:
result.F:=exparray[1];
//...
end;

_________________
We are, we were and will not be.