In every project there are a myriad ways to accomplish the goal. If what you conceive meets your goal and is within your skill level - I count that as success! I'd say, yes... you were on track.
The purpose of the "PauseTime" subroutine is to demonstrate how a long pause may be achieved without paralyzing the processor for undue lengths of time. It is FUNCTIONALLY equivalent to Pause 10000. It is not "better" in your case, only offers advantage when other processes require service.
First priority is to complete your assignment on time - do that using the method you understand best; I have no wish to derail your train of thought, only to explain why long pauses are not well illustrated by random example. I really enjoy the opportunity to payback some of the help I have received here, but I don't wish to influence your design decisions. Ask whatever you like, I'll (and many others likely) will try and help, but please don't let me be a distraction to your instructor's curriculum.
That said, my approach would be to write a subroutine that provides a simple pause of a minimum acceptable length then, call the routine multiple times to provide a random factor, except in the case of "9" where you branch to the error handling routine.
Main:
Generate random number
If number is 9 goto Errorhandler 'If our random number is 9 GOTO where we deal with it
This part only happens when our random is NOT 9
Display the random number
For Delay = 1 to Random number ' Use the variable Delay as a counter from 1 to our random number.
gosub delay 'Go find our pause
Next Delay 'If Delay < our random number, +1 to Delay then go back and pause again
Goto Main 'do it all over
Delay:
pause 1000 'this is the shortest pause, we'll do this once if our random number was 1, three times if it was 3....
Return 'go back to the line after the gosub
ErrorHandler:
Here's where we do whatever we want to happen when 9 is the random number
Dispay an "E"....
Goto Main: 'Go back to "Main", generate a new random number and start over
Do you follow the logic here? The Main loop picks a number, if that number is nine, it leaves the loop for Errorhandler to handle the special case. Otherwise, it displays the number before the "For Delay" loop pauses 1 second "RandomNumber" times. Goto Main starts the process again. What the user will see: A random number, then a pause of equal number of seconds, another random number will appear and another pause of equal seconds... If a nine is our random number, an "E" appears and whatever else you code in errorhandler. Once the errorhandle coder is completed another number is generated, appears on the display, and the pause begins.
Bookmarks