09-28-2022, 03:11 AM
That looks like nice code, but,
when patched into the following snippet it produces an error:
Statement cannot be placed between SUBS/FUNCTIONS
even if I move the include statement below main (above sub CPUtrap), then
when I start it the program window pauses for 2 seconds and vanishes.
when patched into the following snippet it produces an error:
Statement cannot be placed between SUBS/FUNCTIONS
even if I move the include statement below main (above sub CPUtrap), then
when I start it the program window pauses for 2 seconds and vanishes.
Code: (Select All)
' declare all default variables
DefDbl A-Z
Rem $DYNAMIC
Rem $Include:'mem.bi'
Dim Shared t6 As Integer
Dim Shared t7 As Single
' start cpu timer trap
t6 = _FreeTimer
t7! = 1!
On Timer(t6, t7!) CPUtrap
Timer(t6) On
Do
_Limit 50
x$ = InKey$
If Len(x$) Then Exit Do
Loop
Timer(t6) Off
End
Sub CPUtrap
S$ = Str$(Int(GetCPULoad * 10000) / 100) ' 100.00
If InStr(S$, ".") Then
Q$ = Mid$(S$, InStr(S$, ".") + 1)
S$ = Left$(S$, InStr(S$, ".") - 1)
Q$ = Left$(Q$, 3)
S$ = S$ + "." + Q$
Else
S$ = S$ + ".0"
End If
D$ = "CPU " + S$ + "%" ' 100.00
Cls
Print D$
End Sub