Progress bar

anakinanakin Member Posts: 27
Hi,
I have created a form to import a text file in a navision table: this form contain a textbox for the file name, and a button to start import procedure.
I want add a progress bar to indicate the percentage of import progress; can anybody add a little sample code to show me the usage of progress bar ?

Thanks, Anakin \:D/

Comments

  • kinekine Member Posts: 12,562
    See Application Designer Guide (w1w1adg.pdf), section "Using an Indicator to Display Values" for more info.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • havhav Member Posts: 299
    Hi,
    Here is a sample code that displays progress bar denoting %completion of synchronizing customer records.
    Customer.RESET;
    TotalRecs := Customer.COUNT;
    
    IF Customer.FIND('-') THEN
    BEGIN
       //Open the progress bar dialog 
       ProgressBar.OPEN(TEXT008 + TEXT009, Customer.AccountNo);
           { 
            Where,
    	TEXT008	= Synchronising Customers
                    TEXT009	= #1######\@2@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
           }
       //Perform synchronisation of each customer
       REPEAT
       BEGIN
          // do required processing
    
          .................
      	
          //Update no. of customers processed and calculate percentage progress
          CurrTotal := CurrTotal + 1;
          Progress := ROUND(CurrTotal/TotalRecs*10000, 1); //max limit = 10000
    
          //Update progress bar to display current Customer No. & %completion of customer synchronisation
          ProgressBar.UPDATE(1, Customer."No.");
          ProgressBar.UPDATE(2, Progress);
          SLEEP(500);
       END;
       UNTIL Customer.NEXT = 0;
    
       //Close the progress bar dialog
       ProgressBar.CLOSE;
    END;
    

    Hope this will help you.

    :)
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi


    1. The function COUNTAPPROX more recommend for this situation.
    2. Nice joke with use a SLEEP function =D>
  • havhav Member Posts: 299
    Hi
    Yes COUNTAPPROX should be used.

    I didn't follow the 2nd comment.
    2. Nice joke with use a SLEEP function
    Anything wrong with using SLEEP function.
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    Hi

    Just i think progress need as addition for some work and not the reverse.

    By the way may be asked about Indicator control on the form?
  • havhav Member Posts: 299
    Hi
    Note that ProgressBar in the above sample code is a variable of type Dialog.

    Regards,
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    hav wrote:
    Hi
    Note that ProgressBar in the above sample code is a variable of type Dialog.

    Regards,

    I know but exists a Progress control which can be add on form - may be asked about it?
  • kinekine Member Posts: 12,562
    Look at the documentation I refered. There is example and description how to use the Indicator control. Base is, that you set the minimum and maximum on the control, SourceExpr to some variable, and the progress bar will show you the percentage of the variable when Min value is 0% and max value is 100%. (it mean that if you set the min =0 and max = 100 than you need to set the variable used in SourceExpr to percentage you want to show - e.g. Percentage of read bytes from file size (FileVar.POS/FileVar.*100).)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Yaroslav_GaponovYaroslav_Gaponov Member Posts: 158
    kine wrote:
    Look at the documentation I refered. There is example and description how to use the Indicator control. Base is, that you set the minimum and maximum on the control, SourceExpr to some variable, and the progress bar will show you the percentage of the variable when Min value is 0% and max value is 100%. (it mean that if you set the min =0 and max = 100 than you need to set the variable used in SourceExpr to percentage you want to show - e.g. Percentage of read bytes from file size (FileVar.POS/FileVar.*100).)

    Hi

    I think nice so
    Min := 0;
    Max := Table.COUNTAPPROX;

    variable in SourceExpr just will be increase like i += 1;

    BUT Min and Max properties is hidden :oops:
  • kinekine Member Posts: 12,562
    Yes, they are not available in runtime. You set them in Design time to know the limits and than you need to recalculate the variable to the percentage as I wrote. Just set the limits to 0 and 100 in design time. Than set the value to percentage you want to show and it is done...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.