From early days of Clearwin I was surprised that this simple Run-Pause-Stop prototype code does not work. Ones it started, it does not react on anything besides %ac keys.
Is there any way to make it respond on Run-Pause-Continue-Stop button clicks with minimum changes ? No .NET multithreading, or additional windows opened where controls will reside please.
module button_controls
double precision progress_bar
integer start_button_enabled
integer stop_button_enabled
integer pause_button_enabled
integer continue_button_enabled
integer k_pause_butt_on
integer k_stop_run
end module button_controls
winapp
use button_controls
use clrwin
integer start_run, stop_run, continue_run, pause_run, close_window
external start_run, stop_run, continue_run, pause_run, close_window
start_button_enabled = 1
continue_button_enabled = 0
pause_button_enabled = 0
stop_button_enabled = 0
k_pause_butt_on = 0
k_stop_run = 0
progress_bar = 0
k = winio@ ('%ca[Run-pause-stop]%sy[3d_thin]&')
k = winio@ ('%50.10cw%ff%nl&', 0)
k = winio@ ('%50br %nl%ff&', progress_bar, RGB@(255,0,0) )
k = winio@ ('%cn%^~bt[Start] %^~bt[Pause] %^~bt[Continue]%^~bt[Stop]%nl&', &
& start_button_enabled, start_run, pause_button_enabled, pause_run, &
& continue_button_enabled, continue_run, stop_button_enabled, stop_run)
k = winio@ ('%ac[Ctrl+A]&', start_run)
k = winio@ ('%ac[Ctrl+S]&', pause_run)
k = winio@ ('%ac[Ctrl+Q]&', continue_run)
k = winio@ ('%ac[Ctrl+E]&', stop_run)
k = winio@ ('%ac[Esc]&', '+',close_window,'exit')
k = winio@ ('%cn%^bt[OK]','+',close_window,'exit')
end
!-------------------------------
integer function start_run ()
use clrwin
use button_controls
start_button_enabled = 0
stop_button_enabled = 1
pause_button_enabled = 1
continue_button_enabled = 1
k_pause_butt_on = 0
k_stop_run = 0
call window_update@(start_button_enabled)
call window_update@(stop_button_enabled)
call window_update@(pause_button_enabled)
call window_update@(continue_button_enabled)
num_runs = 100
do m = 1, num_runs
progress_bar = m / real(num_runs)
a=2.0
do i=1,400000
do while ( k_pause_butt_on.eq.1 )
CALL TEMPORARY_YIELD@
call sleep1@(0.5)
call sound@(3333,1)
enddo
a=alog(exp(a))
if(k_stop_run.eq.1) goto 1000
enddo
print *, m, ' / ', num_runs
call window_update@(progress_bar)
enddo
1000 return
start_run = 2
end function start_run
!------------------------------------
integer function pause_run ()
use clrwin
use button_controls
k_pause_butt_on = 1
call window_update@(k_pause_butt_on)
pause_run=1
end function pause_run
!-----------------------------------
integer function continue_run ()
use clrwin
use button_controls
k_pause_butt_on = 0
call window_update@(k_pause_butt_on)
continue_run=1
end function continue_run
!------------------------------
integer function stop_run ()
use clrwin
use button_controls
k_pause_butt_on = 0
k_stop_run = 1
stop_run=1
end function stop_run
!------------------------------------
integer function close_window()
use clrwin
use button_controls
k_pause_butt_on = 0
close_window = 1
end function close_window