Silverfrost Forums

Welcome to our forums

WaitAction

21 Jan 2014 10:52 #13587

In a loop, the mouse info to be queried only when an action is performed.

do while (endless)
    call get_mouse_position@(x,y,flag)
    call temporary_yield@()
end do

The CPU is being used even though nothing is done. The same result I get when I permit_another_callback views before the loop. [img]http://tu-dresden.de/die_tu_dresden/fakultaeten/fakultaet_maschinenwesen/iet/ew/trnsys/temp_yield[/img]

21 Jan 2014 12:29 #13589

If you have a %gr window, then specify a callback function and 'full_mouse_input'. For each mouse movement within the graphics window a call to your specified callback function is performed and you can check the mouse info within that function. If this is not for a graphics window, then forget I mentioned this! Ian

21 Jan 2014 1:32 #13590

Ian made good point for %gr. As to other uses of mouse it would be wise to curb excessive CPU use by adding to the DO loop above the CALL SLEEP1@(smalldelay) which is specifically designed for not sucking processor time ( versus SLEEP@ as I last time used it a decade ago) with smalldelay from 0.01 to a quarter a second depending on usage

21 Jan 2014 2:15 #13591

Calling temporary_yield@ causes ClearWin+ to process the Windows message queue at the point that you specify. If you omit the call then normally ClearWin+ will make the call automatically at an appropriate point.

If you need the call in the current context and do not make it, then Windows may not respond (e.g. to mouse movements).

In a simple program ClearWin+ will automatically call (something like) temporary_yield@ just before the Fortran STOP (or END) statement.

Please login to reply.