QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: thelowerrhythm on June 13, 2019, 02:28:33 am
-
Greetings! Hoping someone can give me a hand with this. Haven't touched code more than a couple of times in a few decades and can't figure out how to add a timer to this that counts 1 for every second the program is active and set a variable to that value. The idea is to print said amount of seconds to the file as the program completes. Right now I'm doing it a really stupid way, essentially capturing the time as the program starts as X$ and then printing that in addition to the current TIME$ at the end. Not really ideal. :P
Thanks for taking pity on me. For some reason I've got the bug to try and learn some things I never quite got to way back when,
PRINT "Follow the instructions below..."
INPUT "Enter your name: ", n$
PRINT #1, "FILE CONTENTS" PRINT #1, "Time Started : "; X$
PRINT #1, n$;
" has completed the exercise." PRINT #1, "Congratulations, you did the thing."
PRINT "File has been written."
-
Change x$ = TIME$ to:
DIM x AS _FLOAT
X = TIMER
Then, before the END statement, place the following:
PRINT USING “###.##### seconds to run.”; TIMER - X
-
Thanks! After playing around with it a bit I got it to work and think I've got a solid grasp on why it works, too. :)