Jeg er igang med at lave mit eget cmd:
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo: TMemo;
ComEdit: TEdit;
Enter: TButton;
procedure StartFunction(Command : string);
procedure MainFormActivate(Sender: TObject);
procedure Print(TextToPrint: string);
procedure EnterClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm;
UserInput: boolean;
implementation
{$R *.dfm}
procedure TForm1.EnterClick(Sender: TObject);
begin
Print(String(ComEdit));
StartFunction(String(ComEdit));
ComEdit.Text := '';
end;
procedure TForm1.MainFormActivate(Sender: TObject);
begin
UserInput := False;
end;
procedure TForm1.StartFunction(Command : string);
var
Parameters: array[0..10] of string;
CurrentPara: integer;
begin
for CurrentPara := 0 to 10 do
Parameters[CurrentPara] := '';
CurrentPara := 0;
if (Pos('(', Command) > 1) and (Pos(')', Command) > 2) then
begin
if Pos(',', Command) > 1 then
begin
while Pos(',', Command) > 1 do
begin
Parameters[CurrentPara] := Copy(Command, Pos('(', Command) + 1, Pos(',', Command) - 1);
Delete(Command, Pos('(', Command) + 1, Pos(',', Command));
Inc(CurrentPara);
end;
end
else
Parameters[0] := Copy(Command, Pos('(', Command) + 1, Pos(')', Command) - 1);
end
else
Print('ERROR: wrong syntax');
if UpperCase(Copy(Command, 0, 4)) = 'PRINT' then
Print(Parameters[0]);
end;
procedure TForm1.Print(TextToPrint: string);
begin
Memo.Lines.Add('] ' + TextToPrint);
end;
end.
Men når jeg skriver 'print(RockMySocks)' ind i ComEdit får jeg 3 Acces Violations ved denne linje:
StartFunction(String(ComEdit));
Er der nogle der ved hvorfor det opstår?
Jeg ved godt at det ikke er den mest optimale kode
, men det er bare mit problem jeg gerne vil have svar på. På forhånd tak
Indlæg senest redigeret d. 02.07.2008 02:04 af Bruger #13205