Autor Beitrag
DiamondDog
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: So 25.01.09 15:23 
Hallo Leute,
ich hab das folgendes im Netz gefunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
type
  TStrArray = array of string;

function Explode(var a: TStrArray; Border, S: string): Integer;
var
  S2: string;
begin
  Result  := 0;
  S2 := S + Border;
  repeat
    SetLength(A, Length(A) + 1);
    a[Result] := Copy(S2, 0,Pos(Border, S2) - 1);
    Delete(S2, 1,Length(a[Result] + Border));
    Inc(Result);
  until S2 = '';
end;
jetzt wollte ich das einfach mal Testen, habe dabei aber Probleme mit der einbindung unter typ. So siehts bei mir biß jetzt 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:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function Explode(var a: TStrArray; Border, S: string): Integer;
var
  S2: string;
begin
  Result  := 0;
  S2 := S + Border;
  repeat
    SetLength(A, Length(A) + 1);
    a[Result] := Copy(S2, 0,Pos(Border, S2) - 1);
    Delete(S2, 1,Length(a[Result] + Border));
    Inc(Result);
  until S2 = '';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  S: string;
  A: TStrArray;
  AnzTokens, i: Integer;
begin
  S := 'Ein=Text=durch=Geleichzeichen=getrennt';
  AnzTokens := Explode(A, '=', S);
  for i := 0 to AnzTokens -1 do
    Memo1.Lines.Add(A[i]);
end;

end.
kann mir jemand sagen wie ich das hier:
ausblenden Delphi-Quelltext
1:
TStrArray = array of string;					
bei typ mit einfügen muss?

Danke schon mal.

Mfg Dog


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am So 25.01.2009 um 23:50
Moderiert von user profile iconNarses: Titel geändert.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 25.01.09 17:20 
So wie es da steht: :gruebel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
type
  TStrArray = array of string;

type
  TForm1 = class(TForm)
...
oder kurz:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TStrArray = array of string;

  TForm1 = class(TForm)
...
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: So 25.01.09 18:01 
Omg so einfach ich habs immer unter
ausblenden Delphi-Quelltext
1:
TForm1 = class(TForm)					
gesetzt da ich es nicht besser wuste, deswegen hats auch immer zu nem Problem geführt. Besten Dank für die Hilfe.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 25.01.09 18:12 
Du deklarierst mit TForm1 = ... ja einen Typ, und wenn du einen weiteren definieren willst, dann gehört der ja nicht zur Deklaration von TForm1. ;-)

Du kannst mehrere Typdeklarationen hintereinander hinschreiben, du kannst also andere Typen auch nach der von TForm1 schreiben. Aber erst nach deren Ende, also nach dem end; ;-).
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
  TStrArray1 = array of string;

  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;

    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TStrArray2 = array of string;