05-11-2022, 03:20 PM
One thing you might want to watch out for is super-high CPU usage loops. For example:
Written as the above, that code is going to use as much CPU power as it possibly can, and it's going to make the fans on your PC scream like an airplane engine...
Be user friendly and always remember to add a _LIMIT or a _DELAY to such loops so that your program will play nice with the OS and not try to hog resources which it doesn't need. Example:
It'll keep CPU usage down, and you'll never notice a change in your program's usage at all.
Code: (Select All)
Function waitup
Do
x = _KeyHit
Loop Until x < 0
waitup = x
End Function
Written as the above, that code is going to use as much CPU power as it possibly can, and it's going to make the fans on your PC scream like an airplane engine...
Be user friendly and always remember to add a _LIMIT or a _DELAY to such loops so that your program will play nice with the OS and not try to hog resources which it doesn't need. Example:
Code: (Select All)
Function waitup
Do
x = _KeyHit
_DELAY .05 '1/20th of a second pause between loops
Loop Until x < 0
waitup = x
End Function
It'll keep CPU usage down, and you'll never notice a change in your program's usage at all.