function saveWeights(~,~, WeightButton, RegSlider)
if ispc
    basicfsz = 4.5;
    basichi = 0.025;
else
    basicfsz = 5.5;
    basichi = 0.025;
end
Styles = {'bitstream charter';'clean';'Courier';'courier 10 pitch';'frank ruehl';'Helvetica';'Helvetica-Narrow';'itc bookman';'urw bookman l'};
sty = Styles{6};
fig = figure;
pause(.1);

scrsz = get(0,'ScreenSize');

set(fig,'Position',[scrsz(3)/2 scrsz(4)/2 300 120]);
pause(.1);

set(fig,'Name','Chose the number to save the current weights in.','NumberTitle','off','MenuBar','none','Toolbar','none','color','white');

Textfield(1) = uicontrol('Style','text','String','Save weights in:','HorizontalAlignment','left','Fontsize',2*basicfsz,'BackgroundColor','white',...
    'Units','normalized','FontName',sty,'Position',[0.01, 0.6, 0.7, 0.2]);


DataPopup(1) = uicontrol('Style','popupmenu','String',4:6,'HorizontalAlignment','left','Fontsize',2*basicfsz,'BackgroundColor','white',...
    'Units','normalized','FontName',sty,'Position',[0.75, 0.6, 0.2, 0.2]);

Button(1) = uicontrol('Style','pushbutton','UserData',0,'String','Accept','HorizontalAlignment','center','Fontsize',2*basicfsz,'FontWeight','bold',...
    'Units','normalized','FontName',sty,'Position',[0.55, 0.2, 0.4, 0.2],...
    'Callback',{@innerbuttonsave, WeightButton, RegSlider DataPopup, fig});

Button(2) = uicontrol('Style','pushbutton','UserData',0,'String','Cancel','HorizontalAlignment','center','Fontsize',2*basicfsz,'FontWeight','bold',...
    'Units','normalized','FontName',sty,'Position',[0.05, 0.2, 0.4, 0.2],...
    'Callback',{@innerbuttoncancel, fig});

function innerbuttonsave(hobject, eventdata, WeightButton, RegSlider, DataPopup, parentfig)
number = 3+get(DataPopup(1), 'Value');
% saveWeights([],[],WeightButton, RegSlider, number)

for i =1:6
   dfault(i) = get(RegSlider(3+i),'Value');
end

fname = mfilename;
calcf = mfilename('fullpath');
calcf = calcf(1:end-length(fname));
filename =calcf + "weights/weights" + string(number) +".mat";
save(filename,"dfault");

close(parentfig)

function innerbuttoncancel(hobject, eventdata, parentfig)
close(parentfig);