clear all
close all

graphics_toolkit qt
h.ax = axes ("position", [0.05 0.42 0.5 0.5]);
GoForIt=false;
Age=0;
  function update_plot (obj, init = false) 
    ## gcbo holds the handle of the control
    h = guidata (obj);
    read=false;
    replot = false;
    recalc = false;
    switch (gcbo)
      case {h.b1}
        read=true;
      case {h.b2}
        close all
    endswitch
    
    if read
      [y,Test]=plot_function();
        h.print_result = uicontrol ("style", "text","units", "normalized",
                                        "string", Test, "horizontalalignment",
                                        "left", "position", [0.05 0.25 0.35 0.08]);
      a= get (h.e1, "string");
      assignin ('base','a',a); 
      b = get (h.e2, "string");
      assignin ('base','b',b); 
      c = get (h.e3, "string");
      assignin ('base','c',c); 
      d = get (h.e4, "string");
      assignin ('base','d',d); 
      e = get (h.e5, "string");
      assignin ('base','e',e); 
      f = get (h.e6, "string");
      assignin ('base','f',f); 
      g = get (h.e7, "string");
      assignin ('base','g',g); 
      m = get (h.e8, "string");
      assignin ('base','m',m); 
      n = get (h.e9, "string");
      assignin ('base','n',n); 
    endif
  endfunction
% create an edit control
%global Age Captial Period Saving_Rate Dynamic Dividend Price TER Fee
lenght=200;
hight=30;
horizontal=350;
% create a button (default style)
h.b1 = uicontrol ("style", "pushbutton","string", "Go for it","callback", @update_plot, "position",[horizontal 20 95 hight]);
h.b2 = uicontrol ("style", "pushbutton","string", "Exit","callback", @update_plot, "position",[horizontal+105 20 95 hight]);
h.e1 = uicontrol ("style", "edit", "string", "a ","callback", @update_plot, "position",[horizontal 380 lenght hight]);
h.e2 = uicontrol ("style", "edit", "string", "b ", "position",[horizontal 340 lenght hight]);
h.e3 = uicontrol ("style", "edit", "string", "c", "position",[horizontal 300 lenght hight]);
h.e4 = uicontrol ("style", "edit", "string", "d", "position",[horizontal 260 lenght hight]);
h.e5 = uicontrol ("style", "edit", "string", "e", "position",[horizontal 220 lenght hight]);
h.e6 = uicontrol ("style", "edit", "string", "f", "position",[horizontal 180 lenght hight]);
h.e7 = uicontrol ("style", "edit", "string", "g", "position",[horizontal 140 lenght hight]);
h.e8 = uicontrol ("style", "edit", "string", "m", "position",[horizontal 100 lenght hight]);
h.e9 = uicontrol ("style", "edit", "string", "n", "position",[horizontal 60 lenght hight]);
guidata (gcf, h)

%update_plot (gcf,true);
