function gui1_al(event)

persistent SOLVED

f1=event.parent;

if isequal(event.source,f1.get('solvebutton'))
  try
    geommodel(f1);
  catch 
    errordisp
    return
  end
  try
    meshmodel(f1);
  catch 
    errordisp
    return
  end
  try
    solvemodel(f1);
    SOLVED=1;
    drawnow;
  catch 
    errordisp
    return
  end
elseif isequal(event.source,f1.get('defbutton'))
  setdefaults(f1);
  SOLVED=[];
elseif isequal(event.source,f1.get('meshbutton'))
  try
    geommodel(f1);
  catch 
    errordisp
    return
  end
  try
    meshmodel(f1);
  catch 
    errordisp
    return
  end
  SOLVED=[];
  drawnow;
elseif isequal(event.source,f1.get('plotbutton'))
  if isempty(SOLVED)
    try
        geommodel(f1);
    catch 
        errordisp
        return
    end
    try
      meshmodel(f1);
    catch 
      errordisp
      return
    end
    try
      solvemodel(f1);
      SOLVED=1;
      drawnow;
    catch 
      errordisp
      return
    end
  end
  plotmodel(f1);
else
    geommodel(f1);
    SOLVED=[];
end

function setdefaults(f1)
f1.get('length').setValue('1');
f1.get('left').setValue('273');
f1.get('right').setValue('293');
f1.get('source').setValue('2e3*x');
f1.get('cond').setValue('40');
f1.get('meshsize').setValue('0.1');
f1.get('meshorder').setSelectedIndex(2);

function errordisp
errorstr = 'Wrong input.' ;
messagedlg('Error',errorstr);
