Coding helpMarch 6 2017 at 10:16 AM
|MJ (Login Mongojerry_2)|
So I am trying to create a simple program to time some random events. Essentially I want the system to send printed responses to the screen display.
Step 1: Downtime--pause for 10-120 seconds. Display "Downtime [time]." Proceed to Step 2.
Step 2: 2% chance of displaying "On [120 seconds]." Return to step 1. Else proceed to Step 3.
Step 3: Determine a random time from 3-20 seconds and display "On [time]." After pause, return to Step 1.
I've created a program to do this but it's not working--I believe I am using several commands incorrectly. I would really appreciate any help correcting the syntax of this!
LET X = INT(RND * 100 + 10)
PRINT "Downtime "; X
ON TIMER(X) GOSUB STEP 2
IF RND * 100 <2 THEN
ON TIMER(120) GOSUB DOWNTIME
ELSE GOSUB STEP3
LET X = INT(RND * 17 + 3)
PRINT "Active "; X
ON TIMER(X) GOSUB DOWNTIME
|March 6 2017, 11:07 AM |
Fixed most of this to work as planned except the time delays. Any help on how to structure the TIMER command would be appreciated!
have you been to the wiki?
|March 6 2017, 11:14 AM |
|March 6 2017, 12:01 PM |
Thanks--that was super helpful!
Added a Sleep command to the code so now the delay is working. Only remaining problem is that the delay is too short. When the value of X is, say, 90, ON TIMER(X) flips over in closer to 20 seconds. Any experience with that?
that one you might want to ask on the qb64 forum...
|March 6 2017, 1:15 PM |
i never used on timer, or any events that i could avoid. i always checked the value of the timer function instead.
|March 6 2017, 1:50 PM |
Thanks for your help--sending me to the Wiki was fantastic. I have the program working exactly as I want it now. So happy with it. I dropped the "ON TIMER" commands entirely and just used the SLEEP command with a timed parameter.
* cool! youre welcome
|March 6 2017, 2:34 PM |
BEEN TRYING TO REACH YOU
|March 16 2017, 1:39 PM |