$PBExportHeader$n_dw2xls_progress.sru forward global type n_dw2xls_progress from nonvisualobject end type end forward global type n_dw2xls_progress from nonvisualobject end type global n_dw2xls_progress n_dw2xls_progress type variables Boolean ib_Cancel Boolean ib_OpenExcelFile Boolean ib_WritePictures Boolean ib_WriteBKColor=TRUE Boolean ib_FreezeTitles=TRUE Boolean ib_ProcessSparse=TRUE Int ii_Result Long il_Progress_Max Long il_Progress_Total Long il_Progress, li_Step_Count Long il_PriorStep Int ii_BeginPosition DateTime idt_start DateTime idt_last Boolean ib_CalcRemainTimes =False PowerObject inv_Requestor n_dw2xls_Resource inv_Res w_dw2xls_Progress iw_progress HProgressBar iu_hpb end variables forward prototypes public subroutine of_stepit () public subroutine of_close_progress () public subroutine of_intial_progress (readonly long ai_progresstal, integer ai_remain) public subroutine of_progress (readonly long al_value) public function LONG of_secondsafter (datetime adtm_start, datetime adtm_end) public subroutine of_calcremaintimes () public subroutine of_open_progress () public subroutine of_disablecancel () public subroutine of_setrequestor (powerobject anv_requestor, n_dw2xls_resource anv_resource) end prototypes public subroutine of_stepit (); IF Not IsValid(inv_Requestor) Then Return END IF IF Not IsValid(iu_hpb) Then Return END IF IF ib_CalcRemainTimes AND iu_hpb.Position =il_Progress_Total Then iu_hpb.Position = iu_hpb.Position + il_Progress_Max - il_PriorStep ELSE li_Step =il_Progress /li_Step_Count IF li_Step>il_PriorStep Then OF_CalcRemainTimes() iu_hpb.Position = iu_hpb.Position + li_Step - il_PriorStep il_PriorStep =li_Step END IF END IF END IF Yield() end subroutine public function LONG of_secondsafter (datetime adtm_start, datetime adtm_end);long ll_total_seconds long ll_day_adjust date ld_sdate date ld_edate time lt_stime time lt_etime long ll_null ld_sdate = date(adtm_start) ld_edate = date(adtm_end) lt_stime = time(adtm_start) lt_etime = time(adtm_end) if ld_sdate = ld_edate then ll_total_seconds = secondsafter(lt_stime,lt_etime) else if ld_sdate < ld_edate then ll_total_seconds = secondsafter(lt_stime,time("23:59:59")) ll_day_adjust = daysafter(ld_sdate,ld_edate) - 1 if ll_day_adjust > 0 then ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjust end if ll_total_seconds = ll_total_seconds + secondsafter(time("00:00:00"),lt_etime) + 1 else ll_total_seconds = secondsafter(lt_stime,time("00:00:00")) ll_day_adjust = daysafter(ld_sdate,ld_edate) + 1 if ll_day_adjust < 0 then ll_total_seconds = ll_total_seconds + 86400 * ll_day_adjust end if ll_total_seconds = ll_total_seconds + secondsafter(time("23:59:59"),lt_etime) - 1 end if end if return ll_total_seconds end function public subroutine of_calcremaintimes ();long ll_cur_s, li_progress long ll_total_rem_s long ll_rem_s long ll_rem_m long ll_rem_h string ls_str datetime ldt_now ldt_now = datetime(today(),now()) li_progress=iu_hpb.Position - ii_BeginPosition IF OF_SecondsAfter(idt_last,ldt_now) >5 Then IF Not iw_progress.cb_Cancel.Visible Then iw_progress.cb_Cancel.Visible=TRUE END IF idt_last = ldt_now ll_cur_s =OF_SecondsAfter(idt_start,ldt_now) IF ll_cur_s > 5 AND li_progress > 0 Then ll_total_rem_s = truncate(round((ll_cur_s * 100) / li_progress - ll_cur_s,0),0) ll_total_rem_s = round(ll_total_rem_s / 5,0) * 5 ll_rem_s = mod(ll_total_rem_s,60) ll_total_rem_s = truncate(ll_total_rem_s / 60,0) ll_rem_m = mod(ll_total_rem_s,60) ll_rem_h = truncate(ll_total_rem_s / 60,0) ls_str = "" IF ll_rem_s=0 AND ll_rem_m =0 AND ll_rem_h=0 Then Return END IF IF ll_rem_h = 1 Then ls_str = ls_str + string(ll_rem_h) + " "+inv_Res.Hour+" " ELSEIF ll_rem_h>1 Then ls_str = ls_str + string(ll_rem_h) + " "+inv_Res.Hours+" " END IF IF ll_rem_m=1 Then ls_str = ls_str + string(ll_rem_m) + " "+inv_Res.Minute+" " ELSEIF ((ll_rem_m > 1) or (ll_rem_h > 0)) Then ls_str = ls_str + string(ll_rem_m) + " "+inv_Res.Minutes+" " END IF IF ll_rem_s=1 Then ls_str = ls_str + string(ll_rem_s) + " "+inv_Res.Second ELSE ls_str = ls_str + string(ll_rem_s) + " "+inv_Res.Seconds END IF IF ls_str <> "" Then ls_str =inv_Res.RemainTimes+" "+ ls_str iw_progress.st_remain.text = ls_str END IF END IF END IF end subroutine public subroutine of_open_progress ();IF Not IsValid(inv_Requestor) Then Return END IF IF Not IsValid(iw_progress) Then OpenWithParm(iw_progress, This, "w_dw2xls_progress" ) END IF end subroutine public subroutine of_disablecancel ();IF IsValid(iw_progress) Then iw_progress.cb_Cancel.Enabled=False END IF end subroutine public subroutine of_setrequestor (powerobject anv_requestor, n_dw2xls_resource anv_resource);inv_Requestor = anv_Requestor inv_Res = anv_Resource end subroutine on n_dw2xls_progress.create call super::create TriggerEvent( this, "constructor" ) end on on n_dw2xls_progress.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event destructor;IF IsValid(iw_progress) Then Close(iw_progress) END IF end event