PRO exercise_chart_event,event widget_control,event.top,get_uvalue=infptr info=*infptr CASE event.id OF info.drop_list: BEGIN ;print,'DROP LIST' ;print,'Index=',event.index ;print,'Date=',info.date[event.index] info.start_index=event.index *infptr=info END info.plot_button: BEGIN ;print,'PLOT BUTTON' wset,info.draw_window time=info.time[info.start_index:*] calories=info.calories[info.start_index:*] dummy = LABEL_DATE(DATE_FORMAT=['%N/%D']) PLOT, time, calories, $ XTICKFORMAT='LABEL_DATE', XSTYLE=1, XTICKS=4, YMARGIN=[6,4],$ psym=4,xticklen=1,yticklen=1,xgridstyle=1,ygridstyle=1,$ TITLE='Exercise History',ytitle='Calories',yrange=[250,420],$ XMARGIN=[6.4] v=time-time[0] r=poly_fit(v,calories,2) ;print,r,format='(3(f10.3,1x))' w=r[0]+(v*r[2]+r[1])*v oplot, time, w *infptr=info END info.quit_button: BEGIN ;print,'QUIT BUTTON' ptr_free,infptr widget_control,event.top,/destroy END ELSE: RETURN ENDCASE END PRO exercise_chart openr,lun,'d:\harvey\personal\exercise.txt',/get_lun s='' yr=2001 oldmon=12 for k=0,3 do begin ;Skip the header readf,lun,s print,s end s='' count=0 dd=intarr(1000) mon=intarr(1000) calories=intarr(1000) miles=fltarr(1000) year=intarr(1000) date=strarr(1000) While not eof(lun) do begin readf,lun,s ks=where(byte(s) eq 32 or byte(s) eq 44 or byte(s) eq 9 or byte(s) eq 47) if ks[0] le 0 then break mon[count]=fix(strmid(s,0,ks[0])) dd[count]=fix(strmid(s,ks[0]+1,ks[1]-ks[0]-1)) date[count]=strmid(s,0,ks[1]) calories[count]=fix(strmid(s,ks[1]+1,ks[2]-ks[1]-1)) miles[count]=float(strmid(s,ks[2]+1)) if mon[count]-oldmon LT 0 then yr=yr+1 year[count]=yr oldmon=mon[count] count=count+1 endwhile dd=dd[0:count-1] mon=mon[0:count-1] miles=miles[0:count-1] calories=calories[0:count-1] date=date[0:count-1] year=year[0:count-1] time=lonarr(count) for k=0,count-1 DO BEGIN time[k]=julday(mon[k],dd[k],year[k]) end free_lun,lun ;Build the widget device,get_screen_size=scr buttsize=60 tlb=widget_base(TITLE='Exercise Record',col=1,FRAME=1,$ xoffset=scr[0]/3,yoffset=scr[1]/3,tlb_frame_attr=1) base0=widget_base(tlb,row=1,frame=1) wlbl=widget_label(base0,value='Beginning Date for Plot: ') wdlist=widget_droplist(base0,VALUE=date,uname='DROP_LIST') wdraw=widget_draw(tlb,xsize=500,ysize=300,uname='DRAW_WINDOW') base1=widget_base(tlb,row=1) pbtn=widget_button(base1,value='PLOT',xsize=buttsize,uname='PLOT_BUTTON') qbtn=widget_button(base1,value='QUIT',xsize=buttsize,uname='QUIT_BUTTON') widget_control,tlb,/realize wid=!d.window info={drop_list:wdlist,draw_window:wid,plot_button:pbtn,quit_button:qbtn,$ calories:calories,time:time,miles:miles,date:date,start_index:0} infptr=ptr_new(info) widget_control,tlb,set_uvalue=infptr xmanager,'exercise_chart',tlb,/no_block end