Silverfrost Forums

Welcome to our forums

What's wrong here?

29 Jan 2026 4:31 (Edited: 29 Jan 2026 4:44) #32761

Congrats with the new updated and upgraded more spacious home for the forum.

Creating the program which checks some changes in the files ones per few seconds. The method I used as a first attempt kind of failing so I decided to use another one which employs timer control %dl . But it is also failing. Here is demo. Try to run it. Initially it works. It calls some function every second as it was preset and updates and displays the number of calls. But try to change the default interval time - no effect.

(Comment: I use recursive function just for additional safety: it has no effect in this specific demo but could be useful when the computer becomes very slow and due to that the timer will issue the call for the next such function while it is still not finished with the previous call - this will lead to crash)

module PICrunControl
  integer LastPICfileOutputNumber
  integer (7) hwFileCheckingInterval
  real*8 :: FileCheckingInterval = 1

contains 

integer recursive function FileCheckingCB ()
  LastPICfileOutputNumber = LastPICfileOutputNumber + 1
  call window_update@(LastPICfileOutputNumber)
  FileCheckingCB = 2
end function FileCheckingCB
!...................................
integer function changeTimerDelay ()
  call CHANGE_TIMER_INTERVAL@(hwFileCheckingInterval, FileCheckingInterval)
  changeTimerDelay = 2
end function 
  
end module

!=============================================
Program Prog
  use PICrunControl

k = WINIO@('Interval    %ta%df%rf%ff&', 1d0, FileCheckingInterval )
k = WINIO@('Caii number %ta%4rd%ff&', LastPICfileOutputNumber )
k = WINIO@('%dl&', FileCheckingInterval, FileCheckingCB)
k = WINIO@('%hw%es', hwFileCheckingInterval)
end

29 Jan 2026 6:42 #32762

Dan, You need to change %rf to %^rf with changeTimerDelay as the callback.

module PICrunControl
use clrwin
  integer :: LastPICfileOutputNumber=0  !####
  integer (7) hwFileCheckingInterval
  real*8 :: FileCheckingInterval = 1

contains 

integer recursive function FileCheckingCB ()
  LastPICfileOutputNumber = LastPICfileOutputNumber + 1
  call window_update@(LastPICfileOutputNumber)
  FileCheckingCB = 2
end function FileCheckingCB
!...................................
integer function changeTimerDelay ()
  print*, FileCheckingInterval            !####
  call CHANGE_TIMER_INTERVAL@(hwFileCheckingInterval, FileCheckingInterval) 
  changeTimerDelay = 2
end function 
  
end module

!=============================================
Program Prog
  use PICrunControl
  
k = WINIO@('Interval    %ta%df%^rf%ff&', 1d0, FileCheckingInterval,changeTimerDelay )  !####
k = WINIO@('Caii number %ta%4rd%ff&', LastPICfileOutputNumber )
k = WINIO@('%dl&', FileCheckingInterval, FileCheckingCB)
k = WINIO@('%hw%es', hwFileCheckingInterval)
end
29 Jan 2026 9:11 (Edited: 29 Jan 2026 9:17) #32763

Thanks Ken. Fun is I tried this ^rf too but devilry clearly tricked me to make some typo that the code even did not compile so I gave up.

Please login to reply.