How to use a Indicator control
lloydf
Member Posts: 73
Hi there could anyone please give a simple example of how to use the indicator control.
I have a blank form with some buttons which will trigger some processing.
e.g. I will be looping through the customer table and modifying some data and I would like to place an indicator on the form and have it display the progress of the processing.
any help would be appreciated
thanks
I have a blank form with some buttons which will trigger some processing.
e.g. I will be looping through the customer table and modifying some data and I would like to place an indicator on the form and have it display the progress of the processing.
any help would be appreciated
thanks
0
Comments
-
What I use (which is not the progress bar but I ifnd it a bit simpler), is code like below. I don't know the progress bar offhand, maybe someone else can post it. The example is looping through customers but you should be able to get the picture.
//Window is a variable of type dialog, icount is an integer
Window.open('Processing customer #1######, #2###### of #3######');
window.update(3,customer.count); //control 3 is the total count of the records you are scrolling through
icount := 0;
//filters
if customer.findfirst then repeat
icount := icount + 1;
window.update(1,customer."no."); //update this control with the customer no
window.update(2,count); //update this control with the current count
//all of your other processing
until customer.next = 0;
window.close;
-a0 -
Thanks for your reply it is appreciated however I need to use the indicator control as I need to embed it on a form.0
-
Here's another example of the Progress Bar
do the following
declare 3 variables:
window of type dialog
TotalRec of type integer
CurRec of type integer
in OnPreDataItemwindow.OPEN('Processing @1@@@@@@@@'); TotalRec := COUNT;in AfterGetRecordCurRec := CurRec + 1; window.Update(1,ROUND(CurRec / TotalRec * 10000,1));
in OnPostDataItemwindow.CLOSE;
Whatever processing you are doing it's going to have to:
Get a record
Do something with the record0 -
OK I have roughly worked out how to use this however I do not understand how I can dynamically apply the minValue and the maxValue properties which are key to the control functioning. The SourceExpr is set to a counter variable which is incremented as I loop through each record being processed however if I attempt to assign a variable to maxValue or minValue I get an error.0
-
The progress bar works with integer numbers 0-10000, that's why it goes (currentnumber/totalnumber * 10000). Your dynamic control variable will be the total number, the current number is the one you increment as you loop, and by multiplying the result by 10000 you control the progress indicator. You need to round to the nearest whole number because it only takes integer. Don't forget to catch division by zero.0
-
Denster, Thanks for your reply. please forgive my ignorance. Firstly I am trying to use the indicator control. The application designer guide mentions three key properties: minValue, maxValue and SourceExpr. The only property that I can assign a variable to is SourceExpr.
If I give you the scenario that I want to loop through all the customer records and using a record variable called recCustomers and a counter variable called intCount. Using the code below how can I get the indicator control to work?
intCount:=0;
recCustomers.init;
IF recCustomers.FIND('-') THEN BEGIN
REPEAT
intCount:=intCount + 1;
UNTIL recCustomers.Next=0;
END;
Do I set the SourceExpr to intCount? And how do I set minValue, maxValue?0 -
Here's a little example. Paste this into a new text file, and import it into your database. I used form number 60000, so if that is already taken, you need to renumber it first.
OBJECT Form 60000 Progressbar Test { OBJECT-PROPERTIES { Date=12/02/07; Time=11:32:40 AM; Modified=Yes; Version List=; } PROPERTIES { Width=3190; Height=2420; } CONTROLS { { 1000000000;Indicator;220;220 ;2750 ;440 ;Name=MyProgressBar; SourceExpr=ProgressCount; MinValue=0; MaxValue=10000 } { 1000000001;CommandButton;550;880;2200;550 ;Name=btnShowProgress; CaptionML=ENU=Show Progress; OnPush=BEGIN // first reset the counters ResetProgressBar(); // Set the total count, in real life this is where you'd set it to the total // number of customers for instance TotalCount := 1000; // then start your loop REPEAT CurrentCount += 1; ProgressCount := ROUND(CurrentCount/TotalCount * 10000,1); CurrForm.MyProgressBar.UPDATE; UNTIL CurrentCount = TotalCount; END; } { 1000000002;CommandButton;550;1650;2200;550;Name=btnReset; CaptionML=ENU=Reset; OnPush=BEGIN ResetProgressBar(); END; } } CODE { VAR TotalCount@1000000002 : Integer; CurrentCount@1000000003 : Integer; ProgressCount@1000000000 : Integer; PROCEDURE ResetProgressBar@1000000000(); BEGIN ProgressCount := 0; CurrentCount := 0; TotalCount := 0; CurrForm.MyProgressBar.UPDATE; END; BEGIN { The MinValue and MaxValue properties are hardcoded properties, so you need to set those from the properties window. I use 0 and 10000 because they are the same as the progress indicator on the dialog window. The SourceExpr property is your control variable, which is also an integer that displays the progress between 0 and 10000. Because in real life you can never tell the counters upfront, you have to use a dynamic calculation, expressed as a percentage of the maxvalue. With a large number of entities, you might want to update the progressbar only every so many times, for instance just 10 times, because repainting the form takes a lot of processing Variables: TotalCount is the count of the total entities. If you need to loop through all customers, then you set this to Customer.COUNT for instance. CurrentCount is where you are in the loop ProgressCount is an integer number between 0 and 10000, which are the min and max values Process: All that is available really is an UPDATE method of the control, so that's all you can do. Loop through your entity, keep track of the ProgressCount and UPDATE your progress bar. } END. } }0 -
Denster, What can I say!! That is an absolutely fantastic example. Thanks for taking the time to create this incredibly useful example. I am sure that many people will benefit from this.0
-
You're welcome. I was writing an elaborate reply and realized it would take about the same time to put together a little sample. Glad I could help
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
