Hallo,
ich sitze jetzt schon Stunden an folgenden Problem:
ich erstelle ein dynamisches Array von einem Record. Danach will ich diese Array an eine Prozedur übergeben - was aber nicht funktioniert...
... wo liegt jetzt das Problem???
Code: Alles auswählen
program maint_cli;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, Windows, CustApp, RegExpr
{ you can add units after this };
type
spflotR = record
tester : string;
dns_nn : string;
ip_nn : string;
dns_cc : string;
ip_cc : string;
end;
{ maint_app }
maint_app = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
procedure Logic; virtual;
procedure CC; virtual;
end;
{ maint_app }
procedure maint_app.DoRun;
var
ErrorMsg, par: String;
dnsL, sl : TStringList;
i,ii : Integer;
dnsA : Array of spflotR;
begin
// quick check parameters
if ParamCount = 0 then begin
WriteHelp;
Terminate;
Exit;
end;
ErrorMsg:=CheckOptions('h t: typ: fqNF: destD:','help');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
// parse parameters
if HasOption('h','help') then begin
WriteHelp;
Terminate;
Exit;
end;
// fill Array of Record
dnsL := TStringList.Create;
sl := TStringList.Create;
dnsL.LoadFromFile('dnsLST1.txt');
SetLength(dnsA,dnsL.Count-1);
for i:=1 to dnsL.Count-1 do
begin
SplitRegExpr('\t+?',dnsL[i],sl);
ii := i-1;
dnsA[ii].tester:=sl[0];
WriteLn(dnsA[ii].tester);
dnsA[ii].dns_nn:=sl[1];
dnsA[ii].ip_nn:=sl[2];
dnsA[ii].dns_cc:=sl[3];
dnsA[ii].ip_cc:=sl[4];
WriteLn(dnsA[ii].ip_cc);
end;
dnsL.Free;
sl.Free;
// parse Typ
par := GetOptionValue('t');
writeln('Arr_Länge = ' + intToStr(High(dnsA)));
case LowerCase(par) of
'logic' : Logic(); <-------- hier soll das Array übergeben werden -> Logic(dnsA)
'cc' : CC();
end;
// stop program loop
Terminate;
end;
constructor maint_app.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor maint_app.Destroy;
begin
inherited Destroy;
end;
procedure maint_app.WriteHelp;
begin
{ add your help code here }
writeln();
writeln('Usage: ',ExeName,' Options [-h|--help -t|typ [Logic|CC|both] -fqNF FullQualifidNameFile -destD destination Directory]');
writeln();
writeln(#9,'h|help - show this output');
writeln(#9,'t|typ - which Partition will use');
writeln(#9,'fqNF - Name of the File that should copy - fqn with path');
writeln(#9,'dest - Destination Path');
writeln();
end;
procedure maint_app.Logic(var Arg : ???);
begin
writeln('bin in Proc logic');
// for i:=0 do dns_Arr.
end;
procedure maint_app.CC;
begin
writeln('bin in Proc CC');
end;
var
Application: maint_app;
begin
Application:=maint_app.Create(nil);
Application.Title:='Maint Suite';
Application.Run;
Application.Free;
end.