Computer Science Canada

Input + when statement?

Author:  xevious [ Sun Nov 13, 2005 11:30 am ]
Post subject:  Input + when statement?

First off, I can't get keydown to work at all.
I took this straight from the examples, and it won't work
code:

var chars : array char of boolean
Input.KeyDown (chars)
if chars ('t') then
    put "The T key is pressed"
end if

Is there something wrong with that?

I was also wondering if it is possible to combine some form of input with a when statement.

something like
if chars ('t') when x=300 then *do something*



[/code]

Author:  MysticVegeta [ Sun Nov 13, 2005 11:37 am ]
Post subject: 

you need it in a loop

Author:  xevious [ Sun Nov 13, 2005 11:46 am ]
Post subject: 

MysticVegeta wrote:
you need it in a loop


ok thanks, I have that working now

but is there any way to put a when statement in that loop so it only does something when you press the button at a specific time?

Author:  Cervantes [ Sun Nov 13, 2005 12:19 pm ]
Post subject: 

code:
if chars ('t') and x = 300 then

Or perhaps,
code:
if chars ('t') and x >= 300 then

Author:  MysticVegeta [ Sun Nov 13, 2005 12:49 pm ]
Post subject: 

xevious wrote:
at a specific time?


you mean at a specific location right?

Author:  Tony [ Sun Nov 13, 2005 1:33 pm ]
Post subject: 

xevious wrote:
but is there any way to put a when statement in that loop

when statement doesn't actually have anything to do with time. It's a condition much like if, just different syntax.

Turing:

function() when condition = true

is equavalent and will behave identical to
Turing:

if condition = true then
    function()
end if

Author:  xevious [ Sun Nov 13, 2005 2:38 pm ]
Post subject: 

MysticVegeta wrote:
you mean at a specific location right?


yeah, that's what I meant, and I'll mess around with

code:
if chars ('t') and x >= 300 then


I think I can get it to work...


: