You can execute OS commands in Free Pascal / Lazarus by using TProcess component that exists in System component palatte.
TProcess also can open external applications from your Lazarus project.
1. Create new application, put Edit box, a button, TProcess and a Memo in main form:
2. Change UsePiples property to True in TProcess.Options.
3. Write this code in button’s OnClick:
procedure TForm1.Button1Click(Sender: TObject); begin Process1.CommandLine:= Edit1.Text; Process1.Execute; Memo1.Lines.LoadFromStream(Process1.Output); end;
4. Run the application and write any commands like (ls in Linux, dir in Windows) and click the button. You will get the result of text commands in the memo:
You can also run applications, like calculator, text editor, or any other application.