Project - RUN will run the program IF the program is the active unit in the Editor.

Shane

git-svn-id: trunk@75 -
This commit is contained in:
lazarus 2000-12-21 20:28:34 +00:00
parent fe13dc559a
commit 56d7d8034d
3 changed files with 36 additions and 5 deletions

View File

@ -79,7 +79,7 @@ begin
ControlSelection := TControlSelection.Create(CustomForm); ControlSelection := TControlSelection.Create(CustomForm);
//the source is created when the form is created. //the source is created when the form is created.
//the TDesigner is created is MAin.pp and then TDesigner.SourceEditor := SourceNotebook.CreateFormFromUnit(CustomForm); //the TDesigner is created in Main.pp and then TDesigner.SourceEditor := SourceNotebook.CreateFormFromUnit(CustomForm);
end; end;

View File

@ -1550,6 +1550,11 @@ end;
Procedure TForm1.mnuBuildProjectClicked(Sender : TObject); Procedure TForm1.mnuBuildProjectClicked(Sender : TObject);
Begin Begin
if SourceNotebook.Empty then Begin
Application.MessageBox('No units loaded. Load a program first!','Error',mb_OK);
Exit;
end;
//for now just compile the active unit; //for now just compile the active unit;
SourceNotebook.SaveClicked(Sender); SourceNotebook.SaveClicked(Sender);
@ -1572,8 +1577,31 @@ end;
Procedure TForm1.mnuRunProjectClicked(Sender : TObject); Procedure TForm1.mnuRunProjectClicked(Sender : TObject);
var var
Filename : String; Filename : String;
Begin TheProcess : TProcess;
TheProgram : String;
begin
if SourceNotebook.Empty then Begin
Application.MessageBox('No units loaded. Load a program first!','Error',mb_OK);
Exit;
end;
TheProgram := ExtractFileName(SourceNotebook.ActiveUnitName);
//remove the extension
if pos('.',TheProgram) <> 0 then
delete(ThePRogram,pos('.',TheProgram),length(TheProgram));
if not FileExists(ExtractFilePath(SOurceNotebook.ActiveUnitName)+TheProgram) then Begin
TheProgram := 'No program called "'+TheProgram+'" found!';
Application.MessageBox(@TheProgram,'Error',MB_OK);
exit;
end;
TheProcess:=TProcess.Create(TheProgram,[poRunSuspended,poUsePipes,poNoConsole]);
TheProcess.Execute;
end; end;
@ -1728,6 +1756,10 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.23 2000/12/21 20:28:33 lazarus
Project - RUN will run the program IF the program is the active unit in the Editor.
Shane
Revision 1.22 2000/12/20 20:04:30 lazarus Revision 1.22 2000/12/20 20:04:30 lazarus
Made PRoject Build compile the active unit. This way we can actually play with it by compiling units. Made PRoject Build compile the active unit. This way we can actually play with it by compiling units.

View File

@ -602,7 +602,6 @@ Begin
end; end;
End; End;
Writeln('X = '+inttostr(x));
if SE.Editor = TempEditor then if SE.Editor = TempEditor then
Begin Begin
@ -657,7 +656,7 @@ end;
Function TSourceNotebook.GetEmpty : Boolean; Function TSourceNotebook.GetEmpty : Boolean;
Begin Begin
Result := Notebook1.Pages.Count = 0; Result := (not assigned(Notebook1)) or (Notebook1.Pages.Count = 0);
end; end;
Procedure TSourceNotebook.OpenClicked(Sender: TObject); Procedure TSourceNotebook.OpenClicked(Sender: TObject);