Hi Guys
I've been reading the excellent timer() tutorial on here and have been experimenting with it.
T=Timer()
Do
Elapsed=(Timer()-T)/1000
If Elapsed=2
hello()
Elapsed=0
T=Timer()
endif
Loop
endscreen()
end
function hello()
print "hello"
endfunction
function endscreen()
cls
print "The end"
wait key
endfunction
The above code works as expected. Every 2 seconds the program will print hello.
However if I want to add this into a function (see below), the code no longer functions as expected, can anyone tell me why and if there is a solution please?
T=Timer()
Do
timed(T)
Loop
endscreen()
end
function timed(T)
Elapsed=(Timer()-T)/1000
If Elapsed=2
hello()
Elapsed=0
T=Timer()
endif
endfunction
function hello()
print "hello"
endfunction
function endscreen()
cls
print "The end"
wait key
endfunction
Also, is it possible in this case to make T a global, I've tried and it seems to break the program.
Any help would be greatly appreciated.