program Goldshmau_hoched_teba_otodrat;
 uses graph, crt,
      MX;  {moy unit s moey graphikoy}

 var
  textbox1 : mxInpTextBox;  {smotri v MX unit}
  listbox1 : mxListBox;
  listbox2 : mxListBox;

{--- Perevod iz real v string ---}
 function floattostr(x:real):string;
 var s:string;
 begin
  str(x, s);
  floattostr:=s;
 end;



{--- Inicilizacia obolochki + graphiki ---}
 function  Init_shell : integer;
  var grDriver : Integer;
       grMode : Integer;
       ErrCode : Integer;
       i : integer;
   Begin
   grDriver:=Detect;
   InitGraph(grDriver, grMode, '');
     ErrCode:=GraphResult;

  if ErrCode <> grOk Then
  begin
   writeLn('Error graph: ', GraphErrorMsg(ErrCode));
   exit;
  end;



   { Inicilizacia objectov }
     mx_Init_InpTextBox(Textbox1);

     mx_Init_ListBox(Listbox1);
      listbox1.text[1] := '1. Dlina ';
      listbox1.text[2] := '2. Ob:em ';
      listbox1.text[3] := '3. Plochad'' ';
      listbox1.text[4] := '4. >Vihod<';
     listbox1.UsedList := 4; { Kolichestvo zadeystvovanniy variantov, strok }

     mx_Init_ListBox(Listbox2);
      listbox2.text[1] := '1. mm (millimetr) ';
      listbox2.text[2] := '2. cm (santiment)';
      listbox2.text[3] := '3. m (metr)';
      listbox2.text[4] := '4. l (litri)';
      listbox2.text[5] := '5. >Vihod<';
     listbox2.UsedList := 5; { Kolichestvo zadeystvovanniy variantov, strok }


   init_shell := errcode;
  end;
{=== Inicilizacia obolochki + graphiki ===}


{--- Zapusk shell : ZDES posledovatelnost deystviy ---}
procedure Start_shell;
var
 Operation : integer;
begin
 mx_Execute_InpTextBox(textbox1, 'Vvedite Meru');

while listbox1.selected <> 4 do
BEGIN

 mx_Execute_ListBox(listbox1, ':: Chto nujno? ::');
 case listbox1.selected of
  { Kakay iz punktov vibran? }
   1 : mx_Execute_InpTextBox(textbox1, 'Vvedite 1');
   2 : mx_Execute_InpTextBox(textbox1, 'Vvedite 2');
   3 : begin
       mx_Execute_ListBox(listbox2, ':: Metrika ::');
        if listbox2.selected = 1 then
        begin
         mx_Execute_InpTextBox(textbox1, ':: GO! ::');

          textbox1.text:=textbox1.text+1;
           cleardevice; {ochistka ekrana}
            outtextxy(100,getmaxy div 2,'RESULT!: '+inttostr(textbox1.text));
             readkey;
        end;

       end;

   4 : ;
 end;

END;
end;
{=== Zapusk shell ===}


{--- MAIN ---}
begin

   if Init_Shell = 0 then
    begin
     Start_Shell;
      closegraph;
    end;

end.