Alright I have everything how I want it, except for one thing.... I added buttons that show the hour of the other time zones. When you press them, the number appears on the screen. Anyway I want to be able to have a reset button, which starts the program over and clears those numbers. Anyone have some advice for it. Heres the code that I have
Code:
% This program is of a clock that shows the current time in other zones of
% the US. The large main numbers is the current time in the Easter timezone. When you press
% the other buttons for the zones(pacific,western,central), it shows the
% hour of that time(not the minutes). This program also has a date feature.
clear1 = 0;
done = 0;
about = 0;
thedate = 0;
pacific = 0;
mountain = 0;
central = 0;
HFIG = figure('Name', 'Digital Clock', 'Numbertitle', 'off', 'Position', [450 300 400 100], ...
'Menubar', 'none', 'Resize', 'on');
filemenu = uimenu('Label', 'File');
aboutmenu = uimenu('Label', 'About');
uimenu(filemenu, 'Label', 'Exit', 'Callback', 'done = 1;');
uimenu(filemenu, 'Label', 'Clear', 'Callback', 'clear1 =1;');
uimenu(aboutmenu, 'Label', 'About', 'Callback', 'about = 1;');
uicontrol(HFIG, 'Style', 'PushButton', 'Position', [10 10 75 25], ...
'String', 'Date', 'Callback', 'thedate = 1');
uicontrol(HFIG, 'Style', 'Pushbutton', 'Position', [85 10 75 25], ...
'String', 'Done', 'Callback', 'done = 1;');
uicontrol(HFIG, 'Style', 'Pushbutton', 'Position', [160 10 75 25],...
'string', 'Central Time','Callback', 'central = 1;');
uicontrol(HFIG, 'Style', 'Pushbutton', 'Position', [235 10 75 25],...
'string', 'Mountain Time','Callback','mountain = 1;');
uicontrol(HFIG, 'Style', 'Pushbutton', 'Position', [310 10 75 25],...
'string', 'pacific','Callback','pacific = 1;');
th = text(0.5,0.5,'xxx','FontSize', 35) ; % retrieve handle
set(gca,'visible','off') ;
set(th,'visible','on','horizontalalignment','center')
while(~done),
c1 = datestr(clock,14) ;
set(th,'string',c1);% set the string
pause(.1) ; % break with ctrl-
if(thedate),
msgbox( DATE , 'Date');
thedate=0;
else if(central),
a = str2num(datestr(now,'HH'))
b = a-2+1
if b>12
b = b-12
end
tg= text(.5,.9,'xxx','Fontsize',10')
set(tg,'string',b);
central = 0;
else if(mountain),
c = str2num(datestr(now,'HH'))
d = c-3+1
if d>12
d = d-12
end
tg= text(.7,.9,'xxx','Fontsize',10')
set(tg,'string',d);
mountain = 0;
else if(pacific),
e = str2num(datestr(now,'HH'))
f = e-4+1
if f>12
f = f-12
end
tg= text(.9,.9,'xxx','Fontsize',10')
set(tg,'string',f);
pacific = 0;
else if(about),
load gong
wavplay(y)
msgbox( 'This program displays the current time in the eastern zone. It also shows the hour of the the 3 other time zones when you press the according buttons. This was writting by Trevor Holloway and Charles Silcott for EE 103', 'About message box');
about = 0;
if (clear1);
clear1 = 0;
end
end
end
end
end
end
end
close(HFIG);