From ada93c9da7373367ce29daa3d57cb35ea90f54e5 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 10 Jul 2015 14:56:48 +0200 Subject: initialer Commit --- stabile.lpr | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 stabile.lpr (limited to 'stabile.lpr') diff --git a/stabile.lpr b/stabile.lpr new file mode 100644 index 0000000..b65017e --- /dev/null +++ b/stabile.lpr @@ -0,0 +1,95 @@ +program stabile; + +uses grampsunit, sysutils, crt, grampstypen, grampsmath, matheunit; + +var + S: String; + c: char; + Stb: TStabile; + +procedure Status(Level: Longint); +begin + case Level of + 0: + writeln('Fehler: obiger Fehler!'); + 2: + writeln('Fehler: Korrupte Zwischenstand-Datei!'); + else begin + writeln('Verwendung: '+Paramstr(0)+' (e|E)[bM]* input.xml/input.gramps'); + writeln('oder: '+Paramstr(0)+' l Zwischenzustand.txt'); + end; + end{of case}; + if Assigned(Stb) then Stb.destroy; + halt; +end; + +begin + if GetEnvironmentVariable('randseed')<>'' then + randseed:=strtoint(GetEnvironmentVariable('randseed')); + + if (Paramcount<>2) or + (length(Paramstr(1))<1) or + ((length(Paramstr(1))<>1) and + (leftStr(Paramstr(1),1)='l')) then Status(1); + case Paramstr(1)[1] of + 'e','E': begin // aus gramps-xml lesen + if ((rightStr(Paramstr(2),4)<>'.xml') and + (rightStr(Paramstr(2),7)<>'.gramps')) or + not fileexists(Paramstr(2)) then Status(1); + Stb:=TStabile.create; + if not Stb.LadeXML(Paramstr(2)) then begin + Stb.destroy; + halt; + end; + Stb.printStatus(0); + Stb.generiereFehlendeInfos; + Stb.printStatus(1); + + if (length(Paramstr(1))=1) or (pos('b',Paramstr(1))>0) or (pos('i',Paramstr(1))>0) then + Stb.nurGroeszteZusammenhangskomponente; + + Stb.printStatus(2); + if not Stb.analysiereInteraktionen then begin + Stb.destroy; + halt; + end; + Stb.printStatus(3); + + if Paramstr(1)[1]='E' then + Stb.blaetterAbschneiden; + + Stb.Initialisiere(10000,rightStr(Paramstr(1),length(Paramstr(1))-1)); + end; + 'l': begin // aus Zwischenstandsdatei einlesen + if Paramcount<>2 then Status(1); + if not fileexists(Paramstr(2)) then Status(1); + Stb:=TStabile.create; + if not Stb.LadeVonDatei(Paramstr(2)) then Status(2); + Stb.printStatus(4); + end; + end{of Case}; +// Stb.optimiere; +// Stb.downHillSimplex; + Stb.gradientenOptimierung; + writeln('Du hattest '+myTimeToStr(Stb.Zeit)+' Geduld.'); + write('Möchtest du den Fortschritt speichern? (j/n) '); + c:=readkey; + while not (c in ['j','J','n','N']) do begin + writeln; + writeln(''''+c+''' verstehe ich nicht, aber ich wiederhole die Frage gerne noch einmal:'); + write('Möchtest du den Fortschritt speichern? (j/n) '); + c:=readkey; + end; + writeln; + if c in ['j','J'] then begin + writeln('Und wohin?'); + readln(S); + while not Stb.SpeichereInDatei(S) do begin + writeln('Die Datei '''+S+''' existiert bereits, nimm bitte eine andere!'); + readln(S); + end; + end; + writeln; + Stb.destroy; +end. + -- cgit v1.2.3-54-g00ecf