Progress Bar

sabzamsabzam Member Posts: 1,149
Hi, I have created a progress bar but for some reason or another it starts immediately from 100% instead of progressing from 1% to 100%. The following is the code.
TempFileName := ConvertPath(ImportFileName);

Window.OPEN(
  Text003 +'   .  .   '+TempFileName +'\' +
  Text004 +'@1@@@@@@@@@@@@@@@@@@@@@\');
Window.UPDATE(1);
TotalRecNo := "Transactions".COUNTAPPROX;
RecNo :=0;


Can anyone help please?

Regards

Comments

  • rdebathrdebath Member Posts: 383
    sabzam wrote:
    Window.UPDATE(1);
    
    

    You probably ment
    Window.UPDATE(1, 0)
    

    The second argument must be an integer in the range 0 to 10000 so:
    Window.UPDATE(1, ROUND("Progress %" * 100, 1, '<'));
    
    I usually round down to reduce the 'still running at 100%' effect.
  • sabzamsabzam Member Posts: 1,149
    Unfortunately still not working I don't know why..... What I am doing is uploading records through a dataport and I want to show the upload progress but it is starting from 100% immediately.

    Can you help please?

    Regards
  • garakgarak Member Posts: 3,263
    TempFileName := ConvertPath(ImportFileName);
    
    Window.OPEN(
      Text003 +'   .  .   '+TempFileName +'\' +
      Text004 +'@1@@@@@@@@@@@@@@@@@@@@@\');
    Window.UPDATE(1);
    TotalRecNo := "Transactions".COUNTAPPROX;
    RecNo :=0;
    

    What should "1" update? Which variable should there set?
    Is the Window.upadate in a loop or in a dataport or where?
    Normally the souirce for a progressbar in a dialog looks like this:
    Counts := FromSomewhere.counts; //or countapprox <- need updated statistics
    i := 0;
    
    Window.open('My little progress bar: @1@@@@@@@@');
    if CONDITION then begin
      repeat
        i += 1;
        Window.update(1,round(i*100/counts*100,1));
      until LOOPSTOPCOMMAND;
    end;
    Window.close;
    

    Regards
    Do you make it right, it works too!
  • sabzamsabzam Member Posts: 1,149
    Hi,
    What should "1" update? Which variable should there set?
    Is the Window.upadate in a loop or in a dataport or where?

    1 is Updating TEXT004 which is a constant i.e. the one that populates the progress bar
    Window.update is in a dataport OnAfterImportRecord() trigger and there is no need loops for loops i think

    So... OnAfterImportRecord() trigger I have the following code:
    RecNo := RecNo + 1;
    Window.UPDATE(1,ROUND(RecNo/TotalRecNo * 10000,1));
    

    And in PreDataport() trigger I have the following:
    TempFileName := ConvertPath(ImportFileName);
    
    Window.OPEN(
      Text003 +'   .  .   '+TempFileName +'\' +
      Text004 +'@1@@@@@@@@@@@@@@@@@@@@@\');
    
    Window.UPDATE(1, 0);
    TotalRecNo := "EBet Transactions".COUNTAPPROX;
    RecNo :=0;
    

    Where:

    Name ConstValue
    Text003 Filename:
    Text004 Progress:

    Is it better this way?? Can you help please??

    Regards
  • rdebathrdebath Member Posts: 383
    Unfortunately still not working I don't know why..... What I am doing is uploading records through a dataport and I want to show the upload progress but it is starting from 100% immediately.

    Can you help please?

    Regards

    Errm, (feels like there might be a do'h moment coming ...)

    Where are you getting your total count from?
    Are you getting it from the empty table before the import ... are there zero records in the table?

    For a Import dataport you use
    Window.UPDATE(1, ROUND(CurrFile.POS / CurrFile.LEN * 10000, 1));
Sign In or Register to comment.