! This software CALLCON.f90 is part of the Visual Fortran kit.
! 
! This software is provided as an example that demonstrates a particular
! feature/function of the licensed product. The software is not intended to
! provide a complete solution to any application problem but rather is provided
! as a teaching mechanism.
! 
! Users may incorporate any part of this sample into their own source after 
! making appropriate changes to make it suitable for the intended application.
!
! This sample program demonstrates using the Visual Fortran Dialog Procedures
! in a DLL.  The public routines in the DLL can be called to:
!  o  DisplayProgressBox - Display a dialog box containing a progress bar 
!  o  SetProgress - Set the current progress bar value
!  o  DestroyProgressBox - Destroy the dialog box
! CallCon is a console application that calls the public routines in the
! DLLPRGRS DLL.
!
!  FUNCTIONS:
!	CALLCON      - Entry point of console application.
!

!****************************************************************************
!
!  PROGRAM: CALLCON
!
!  PURPOSE:  Entry point for the console application.
!
!****************************************************************************

program CALLCON

    use ProgressBox
	implicit none

	! Variables
    type (PBContext) context
    integer iret
    integer progress
    logical bCancelled

	! Body of CALLCON

    ! Create the progress dialog box
    ! We specify no parent window (since the console application does not
    ! have a window).
    iret = DisplayProgressBox( context, 0, "Console Progress Bar Test", .TRUE.) 
    if ( iret == PBStatus_OK ) then
        bCancelled = .FALSE.
        progress = 0

        ! Perform the work, updating the progress bar as we go along...
        do while ( ( bCancelled == .FALSE. ) .and. ( progress < 101 ) )
            iret = SetProgress ( context, progress )

            if ( iret == PBStatus_Aborted ) then
                bCancelled = .TRUE.
            else
                ! You would do real work here....
                ! Ideally, you should keep each increment of work to
                ! to under .25 seconds.  This keeps the user interface
                ! responsive.
			    call sleepqq(250)		! Wait .25 seconds, 100 times
            end if

            progress = progress + 1
        end do

        ! Destroy the progress box
        iret = DestroyProgressBox( context )

    end if
	
end program CALLCON

