Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 6 of 6

Thread: Code Request

  1. #1
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114

    Code Request

    If I have a table containing several files, I am copying them to another location. How can I code a Time Left for the user?

    such as xx:xx Time Remaining.

    Thanks

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    You'd have to use a callback function and use a global variable and calculate time left based on copy rate...


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114
    You'd have to use a callback function and use a global variable and calculate time left based on copy rate...

    I have the callback function and a Global variable would be easy but how do you figure out Copy rate.

    Global Variable1 is the (Total Files)
    Global Variable2 is the(Current File)

    Dividing Variable 2 into 1 gives the 50%
    Dividing Variable 1 into 2 gives 2

    Now How can I make this work?

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    You need to use know the time elapsed; then calculate the time elapsed vs bytes copied -- use that as a percentage of total bytes, then calculate out bytes remaining.. at 1st the estimated time will be off and change rapidly; but it should soon settle down to a only slightly varying estimation...


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  5. #5
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114
    Quote Originally Posted by jassing View Post
    You need to use know the time elapsed; then calculate the time elapsed vs bytes copied -- use that as a percentage of total bytes, then calculate out bytes remaining.. at 1st the estimated time will be off and change rapidly; but it should soon settle down to a only slightly varying estimation...
    Global Variable1 is the (Total Bytes)
    Global Variable2 is the(Bytes Copied so far)
    Variable (Start Time)
    Variable (End Time)
    Elapsed (Start Time - End Time)
    Variable2 is Percent of Varible1

    Subtract (Variable2 from 1)

    Im thinking that will be expressed as a percent but not as SS:MM?

  6. #6
    Join Date
    Jul 2001
    Location
    Harrisburg, PA , USA
    Posts
    114
    My functions are;

    Code:
    function COPYCB(Source,Destination,Copied,Total)
    	DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_02, (nfl / nflcnt) * 100);
    	BytesCSF = BytesCSF + Copied
    	E_Time = System.GetTime(TIME_FMT_MIN)..":"..System.GetTime(TIME_FMT_SEC)
    	End_Time = Time2Num(E_Time)
    	Elapsed = End_Time - Start_Time
    	TEvsBC =  Elapsed / BytesCSF 
    	Current_Percent =  TEvsBC / TBytes   
    	Display_TL = Math.Round(Current_Percent,0) 
    	Display_TL = Time2Str(Display_TL)
        --Dialog.TimedMessage("Please Wait...", End_Time.." "..Start_Time.." "..Elapsed.." "..BytesCSF.." "..TBytes.."\r\n", 500, MB_ICONINFORMATION);
    
    	return true; --continue copying
    end    
    
    function Time2Num(Tme)
    
    Raw_Min = String.ToNumber(String.Left(Tme, 2));
    Raw_Sec = String.ToNumber(String.Mid(Tme, 4, 2));
    
    Num_Time = (Raw_Min * 59) + Raw_Sec
    Tme = Num_Time
    return Tme
    end
    
    function Time2Str(Tme)
    
    Str_Min = Math.Round((Tme /59), 0);
    Str_Sec = Math.Mod(Tme, 59)
    Num_Time = Str_Min..":"..Str_Sec
    Tme = Num_Time
    return Tme
    end
    
    function gtbs(Path)
        local nSize = File.GetSize(Path);
        TBytes = g_FolderSize + nSize;
        
        return true;
    end
    My Calls are:

    Code:
    TBytes = 0
    BytesCSF = 0
    Start_T = System.GetTime(TIME_FMT_MIN)..":"..System.GetTime(TIME_FMT_SEC)
    Start_Time = Time2Num(Start_T)
    Code:
    File.Copy(tfiles[n], Sdest..dest, true, true, true, true, COPYCB);
    My "Time Left" seems to get larger and larger. I think I may be missing a step somewhere

Similar Threads

  1. Article: Using Authenticode Code Signing Certificates
    By Ted Sullivan in forum Setup Factory 8.0 Examples
    Replies: 4
    Last Post: 10-31-2007, 09:03 AM
  2. Progress Bars screen, On Start code is skipped
    By AxemanMK in forum Setup Factory 7.0
    Replies: 7
    Last Post: 09-21-2006, 02:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts