unit CSUnit;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Spin;

type
  TCSDialog = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    SESteps: TSpinEdit;
    Label2: TLabel;
    EFileName: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    SaveDialog: TSaveDialog;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  CSDialog: TCSDialog;

implementation

{$R *.DFM}

uses MiscRoutines;

procedure TCSDialog.Button1Click(Sender: TObject);
begin
  if(SaveDialog.Execute) then
    EFileName.Text:=ExtractFileName(SaveDialog.FileName);
end;

procedure TCSDialog.Button2Click(Sender: TObject);
var
  c1, c2, c3 : double;
  step : double;
  S : TFileStream;
begin
  step:=1/SESteps.Value;
  //mat.Create(SESteps.Value
  S:=TFileStream.Create(SaveDialog.FileName,fmCreate);
  c1:=0;
  while(c1<=1) do
  begin
    c2:=c1;
    while(c2<=(1-c1)) do
    begin
      c2:=c2+step;
      c3:=1-(c1+c2);
      fPrint(TStream(S),Format('%f, %f, %f',[c1,c2,c3]));
    end;
    c1:=c1+step;
  end;
  S.Destroy;
end;

end.
