Jump to content

Progress Dialog


Recommended Posts

I looked at the above.  After a bunch of trial and error, I was able to build an example below the "====" line, but I really don't understand what I'm doing.  Here is what I am tripping over.

 

These procedures/function have obvious functionality and are understood.

PROCEDURE   ProgressDlgClose;
PROCEDURE   ProgressDlgEnd;
FUNCTION   ProgressDlgHasCancel:BOOLEAN ;
PROCEDURE   ProgressDlgOpen( title :STRING; canCancel :BOOLEAN) ;

PROCEDURE   ProgressDlgOpenDelay( title:STRING;canCancel:BOOLEAN; delaySec:INTEGER) ;

PROCEDURE   ProgressDlgSetBotMsg( message:STRING ) ;

PROCEDURE   ProgressDlgSetTopMsg( message:STRING ) ;  only sort of obvious.  I expected it to be in the position of the SetMeter String

 

 

Then there are these:

PROCEDURE   ProgressDlgSetMeter( message:STRING ) ;
    "Set progress meter message of a progress dialog."
With minimal testing this became clear.  It would have been nice if it had beem named "SetProgressDlgLabel" or "ProgressDlgSetLabel".  "...SetMeter" is opaque until after one figures it out.
    
PROCEDURE   ProgressDlgStart( Percentage    :REAL; LoopCount    :LONGINT) ;
   "Start a progress context. This defines progress percentage and loop count for ProgressDlgYield calls. LoopCount is fit in the Percentage of the progress."
"Percentage".  Percentage of what going in what direction?
"LoopCount".  "LoopCount" ???? What Loop? What Count?

    
PROCEDURE   ProgressDlgYield( count:LONGINT ) ;
   " Increases the progress. This must be called between ProgressDlgStart and ProgressDlgEnd and defines the LoopCount index."
"count"??? Counting what?  All the examples have this set to "1"  What does this do?  Where in the loop or in the survey by criteria is this needed.  What happens if the value is not "1", maybe "2" or maybe "0"?  It is defined as a LONGINT, so it would seeem a bunch of values can be expected.  I really don't understand this call, but I put it in each iteration of the repeating task.
    
==============================================================

PROCEDURE ProgressDialogExample;

VAR
    index                :INTEGER;
    x1, y1, x2, y2    :REAL;
    progress            :LONGINT;
    
BEGIN
    x1 := 10;
    y1 := 10;
    x2 := x1 + x1;
    y2 := y1 - y1;
    ProgressDlgOpen('Draw Squares', TRUE);
    ProgressDlgSetMeter ('Drawing Squares First Half');

    ProgressDlgSetTopMsg ('Top');
    ProgressDlgSetBotMsg ('Bottom');
 
    ProgressDlgYield (0);        { start at 0% }
    ProgressDlgStart(100, 30);
    FOR index := 1 TO 30 DO
        BEGIN
            message('index = ', index);
            IF index = 15 THEN
                ProgressDlgSetMeter ('Drawing Squares Second Half');
            RECT(x1, y1, x2, y2);
            x1 := x1 + 5;
            y1 := y1 + 5;
            x2 := x1 + x1;
            y2 := y2 - 5;
            ProgressDlgYield (1);        { Increment the progress bar }
            IF ProgressDlgHasCancel THEN
                index := 60;
            wait(1);
        END; {FOR index := 1 TO 60}
        
    ProgressDlgStart(0, 0);        
    ProgressDlgYield (0);
    ProgressDlgEnd;
    ProgressDlgClose;
    
    Redrawall;
    clrmessage;
END;
RUN(ProgressDialogExample);
 

Link to comment
  • Vectorworks, Inc Employee

I'll try to clarify some of the calls, to the best of my abilities. I can't really comment on the naming, since that ship has sailed long ago. Keep in mind that many function calls are exposing inner functionality for public use, and the function and variable names will be created to reflect that.

Lets examine ProgressDlgStart. This tells the dialog that how much of the work you want to be show. If for example you have ten steps that you are going to be doing and you want to update the meter text after each step, you would give the percentage as 10 for each step. Maybe you have three steps, but one of them reflects 50% of the work, one 30% and the final 20%. You would be calling ProgressDlgStart three times, each with a different percentage. 

 

Now each of these steps can be broken down into how many increments will be in the progress bar for that step.  Let's take our example of 50, 30 and 20 as a division of labour, and you have 10 objects you will be working on during each of the operations. You would call ProgressDlgStart( 50, 10 ). You are saying "fill the progress bar until 50 percent of it is filled, and do it in 10 incremental parts." Each time the progress bar fills a little big, it will be 1/10th of 50% of the bar. That is you LoopCount

 

When is the progress bar incremented? When you call ProgressDlgYield. You are saying how many of the previously defined LoopCounts you want to increment the bar. It also gives you an opportunity to check if the cancel has button has been clicked. 

 

I know this may not be as clear as possible, but with a little playing around I think it would clarify itself.

 

Does this help at all?

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...