program main
use progress
implicit none

    type(progresswindow), volatile::p
    integer::counter
    real::last_time, now_time
    
    p = initprogress("Timed Progress", canceltest)
    
    call cpu_time(last_time)
    now_time = last_time
    
    counter = 0
    
    do while(counter < 100) 
        
        do while(now_time - last_time < 0.2)
            call cpu_time(now_time)
        end do
        
        last_time = now_time
        counter = counter + 1
        
        call p%draw(counter)
        
        if(counter == 50) then
            call p%draw(counter, "Halfway Complete")
        end if
    
    end do

    call p%close()
    
    contains
    
    subroutine canceltest
    implicit none
    
        counter = 101
        now_time = now_time + 1.0
        
    end subroutine canceltest

end program main
