StopWatch

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
Post Reply
neil
Posts: 594
Joined: Mar 17, 2022 23:26

StopWatch

Post by neil »

Here's A StopWatch. There is probably a better way to do this.

Code: Select all

Declare Sub Space1
Dim As UByte h,s1,s2,m1,m2
Dim AS String k 
Color 14
Cls
Locate 2, 27:Print "StopWatch"
Locate 6, 22:Print "Press Space to Start"
Locate 10, 25:Print ":"
Locate 10, 35:Print ":"
Locate 10, 21:Print "0"
Locate 10, 29:Print "0"
Locate 10, 31:Print "0"
Locate 10, 39:Print "0"
Locate 10, 41:Print "0"

Do
k = Inkey
IF k = " " THEN
space1
End If
Loop UNTIL k = " "

For h = 0 TO 24 'looping For 24 hours(times)
Locate 10, 21:Print h
For m2 = 0 TO 5
Locate 10, 31:Print m2
For m1 = 0 TO 9 'looping For 10 times(minutes)
Locate 10, 31:Print m1
For s2 = 0 TO 5 'looping For 6 times(seconds)
Locate 10, 39:Print s2
For s1 = 0 TO 9 'looping For 10 times(seconds)
k = Inkey
Locate 6, 22:Print "Press Space to Stop "
If k = " " THEN
Locate 14,1:Print
End
End If

Locate 10, 41
Print s1
Sleep 1000,1 'delay 1 second
Next
Next
Next
Next
Next
End

Sub Space1
Locate 10, 25:Print ":"
Locate 10, 35:Print ":"
Locate 10, 21:Print "0"
Locate 10, 29:Print "0"
Locate 10, 31:Print "0"
Locate 10, 39:Print "0"
Locate 10, 41:Print "0"   
End Sub
Post Reply