how do i incorporate a timer
Author |
Message |
upandatom
|
Posted: Mon Jan 17, 2005 5:17 pm Post subject: how do i incorporate a timer |
|
|
would i use a case statment or just a counter? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
cycro1234
|
Posted: Mon Jan 17, 2005 5:33 pm Post subject: (No subject) |
|
|
code: | var startTime:int:=Time.Sec
var endTime:int:= 120 %put time in secondes to run
var curent:int
loop
curent := Time.Sec - startTime
put curent
exit when curent >= endTime
end loop
|
Theres a code for a small timer. |
|
|
|
|
|
upandatom
|
Posted: Mon Jan 17, 2005 5:34 pm Post subject: (No subject) |
|
|
so if i wanted a program to close after 30 seconds do i for count or ? |
|
|
|
|
|
cycro1234
|
Posted: Mon Jan 17, 2005 5:37 pm Post subject: (No subject) |
|
|
Change the part where it says 120 seconds to 30 seconds. |
|
|
|
|
|
upandatom
|
Posted: Mon Jan 17, 2005 5:40 pm Post subject: (No subject) |
|
|
here's my code
var random3:int
randint(random3,1,3)
var answer : int
var random : int
var random2 : int
var reply:string
loop
randint (random, 1, 12)
randint (random2, 1, 12)
put random ,"*",random2
get answer
if answer = random * random2 then
put "Caught it"
else
put "Wrong, deducting money"
end if
end loop
i want the thing to end after 30 seconds and the seconds have to be displayed |
|
|
|
|
|
cycro1234
|
Posted: Mon Jan 17, 2005 5:56 pm Post subject: (No subject) |
|
|
So try adding the counter, with the 30 seconds limit, inside the loop. |
|
|
|
|
|
upandatom
|
Posted: Mon Jan 17, 2005 5:58 pm Post subject: (No subject) |
|
|
lol i triiied bu tthen i have to wait for the 30 seconds before it starts asking questions or the timer doesnt show at all |
|
|
|
|
|
cycro1234
|
Posted: Mon Jan 17, 2005 6:01 pm Post subject: (No subject) |
|
|
Better?
code: | var random3 : int
var startTime : int := Time.Sec
var endTime : int := 30
var current : int
randint (random3, 1, 3)
var answer : int
var random : int
var random2 : int
var reply : string
var random3 : int
var startTime : int := Time.Sec
var endTime : int := 30
var current : int
randint (random3, 1, 3)
var answer : int
var random : int
var random2 : int
var reply : string
loop
current := Time.Sec - startTime
locate (1, 1)
put current
randint (random, 1, 12)
randint (random2, 1, 12)
put random, "*", random2
loop
locate (3, 1)
get answer
if answer not= random * random2 then
put "Wrong, deducting money"
locate (3, 1)
put " "
locate (5, 1)
put " "
else
locate (3, 1)
put " "
locate (4, 1)
put " "
put "Caught it"
exit
end if
end loop
exit when current >= endTime
end loop
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
cycro1234
|
Posted: Mon Jan 17, 2005 6:02 pm Post subject: (No subject) |
|
|
Disregard the double code. |
|
|
|
|
|
upandatom
|
Posted: Mon Jan 17, 2005 8:09 pm Post subject: (No subject) |
|
|
ty |
|
|
|
|
|
cycro1234
|
Posted: Mon Jan 17, 2005 8:13 pm Post subject: (No subject) |
|
|
np |
|
|
|
|
|
|
|