unit unitmain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, shellapi, ExtCtrls, unit1;
type
TForm1 =
class(TForm)
OpenDialog1: TOpenDialog;
Memo1: TMemo;
Panel1: TPanel;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure press(Sender: TObject;
var Key: Char);
private
{ Private-Deklarationen }
public
procedure splitString(
const Source:
String;
const Delimiter:
String;
const Dest: TStringlist);
procedure leseein;
procedure dobe;
procedure add(s:
string);
{ Public-Deklarationen }
end;
var
Form1: TForm1;
sl:tstringlist;
// sl= liste in die das script geladen wird
c:int64;
// c=cursor
forgo:integer;
// forgo = gehe hinter befehle
be:tstringlist;
//be = befehl für verarbeitung
max:int64;
//max = länge der primären stringliste
filename:
string;
b:boolean;
// für das beenden
e:boolean;
// für eingabe
es:
string;
// befehl für eingabe
// für script
implementation
{$R *.dfm}
function Starte(verz, appname:
string): boolean;
var StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
if verz[length(verz)]<>'
\'
then verz:=verz+'
\';
FillChar(StartupInfo, SizeOf(TStartupInfo),0);
StartupInfo.cb:=SizeOf(TStartupInfo);
if CreateProcess(
nil, PChar(verz+appname),
nil,
nil, false,
NORMAL_PRIORITY_CLASS,
nil,
nil, startupinfo, ProcessInfo)
then begin
try
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
finally
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
end;
result:=true;
end
else
result:=false;
end;
procedure TForm1.splitString(
const Source:
String;
const Delimiter:
String;
const Dest: TStringlist);
var count: Integer;
LStartpos, LEndepos, LSourcelength: Integer;
LDelimiterLength : Integer;
begin
Dest.Clear;
count := 1;
LStartpos := 0;
LEndepos := 0;
LSourcelength := length(Source);
LDelimiterLength := Length(Delimiter);
while count <= LSourcelength
do begin
if copy(Source, count, LDelimiterLength) = Delimiter
then begin
LEndepos := count;
dest.Add(copy(Source, LStartpos + 1, LEndepos - LStartpos - 1));
LStartpos := count + LDelimiterLength - 1;
inc(count,LDelimiterLength);
end
else begin
inc(count);
end;
end;
if LEndePos <> Count - LDelimiterLength
then
dest.Add(copy(Source, LStartpos + 1, count - LStartpos - 1));
end;
procedure TForm1.leseein;
var z1,z2:
String;
begin
z1:=sl[0];
// scriptnamen ermitteln
z2:=z1+'
- abu_scrit by arbutus';
form1.Caption:=copy(z2,7,Length(z2));
if copy(z1,0,6)<>'
script'
then begin
showmessage('
Die Datei ist kein gültiges abu script');
exit;
end;
// hinter befehle gehen
repeat forgo:=forgo+1;
until sl[forgo]='
befehle';
c:=forgo;
max:=sl.Count;
dobe;
end;