Computer Science Canada

Get that doesn't pause

Author:  Taur [ Wed Dec 14, 2005 6:10 pm ]
Post subject:  Get that doesn't pause

is there a way to use get without pausing everything else? I tried making a procedure and then calling get in it, but it still pauses it. the only other way I can think of is making a new get procedure by using keys and stuff, I could do it but I was wondering if there was an easier way?

Author:  pkchris [ Wed Dec 14, 2005 6:26 pm ]
Post subject: 

Maybe if you put it in a process then used fork.

code:

process getpro
get whatever
end getpro
fork getpro

Author:  Taur [ Wed Dec 14, 2005 6:31 pm ]
Post subject: 

I don't understand that fork does Confused

Author:  pkchris [ Wed Dec 14, 2005 6:36 pm ]
Post subject: 

"Fork" just makes a process run seperate so that you can have other stuff going on at the same time. Check out Turing Help for more info. Wink

Author:  Paul [ Wed Dec 14, 2005 6:55 pm ]
Post subject: 

The general concensus is to avoid using processes and forks in your programs.
read up on the advanced input tutorial
and also in general Input.KeyDown then F9 (turing's reference).

Author:  Taur [ Wed Dec 14, 2005 7:16 pm ]
Post subject: 

what has that got to do with using a get that doesn't pause?

Author:  Paul [ Wed Dec 14, 2005 7:28 pm ]
Post subject: 

Perhaps if you'd read the tutorial, its about input. What is get? its input.
Check out this old typing game I made with Input.KeyDown.

This requires getting the user's input without pausing the game. Get it?

Author:  Taur [ Wed Dec 14, 2005 7:35 pm ]
Post subject: 

I aldready considered that and I posted in my title, it would take a bit of coding and 1 line would be much easier if not much more efficient, but I guess it's the only way

Author:  md [ Wed Dec 14, 2005 8:12 pm ]
Post subject: 

easy and how you do something aren't always the same. So what if it's more then one line, write a procedure! You probably should be doing so anyways. If you ask for help don't complain because the answers given are "too hard" or are "more then a line".

Author:  Taur [ Wed Dec 14, 2005 8:47 pm ]
Post subject: 

sorry but I was looking for a build in turing procedure because mine might be less efficient..

Author:  Paul [ Wed Dec 14, 2005 8:54 pm ]
Post subject: 

Its ok.
But you have to realize that turing is not meant for that sort of thing. Turing is a learning language, where you should build everything from scratch, and you're only given a few things for you to work with.

Things like C++ have huge amounts pre-made things that comes in its libraries.

Have fun being creative! Very Happy

Author:  Taur [ Thu Dec 15, 2005 8:02 pm ]
Post subject: 

okay thx

I finished it, it works pretty good with the exception of the little black boxy thingy Razz but yah thx for everything

Author:  Albrecd [ Tue Dec 20, 2005 9:19 am ]
Post subject: 

Or, A much simpler way would be to use:

code:
var input : char

put "Please Type A Letter"
input := getchar
put "Your Letter Was: ",input

Author:  Cervantes [ Tue Dec 20, 2005 1:50 pm ]
Post subject: 

Hmm? That still pauses.
If you want to use getch/getchar, you need to wrap it in an if hasch statement:
code:

var input := ""
for i : 0 .. maxx
    if hasch then
        input += getchar
    end if
    locate (1, 1)
    put input
    Draw.Dot (i, 50, black)
    delay (10)
end for

Although, this would be better if instead of having a delay, you had a loop that accepted input. (Think: what happens if you press a key while the delay is on, then lift the key before the key is lifted?)
code:

var input := ""
var time_enter : int

for i : 0 .. maxx
    time_enter := Time.Elapsed
    loop
        if hasch then
            input += getchar
        end if
        exit when Time.Elapsed - time_enter >= 10
    end loop
    locate (1, 1)
    put input
    Draw.Dot (i, 50, black)
end for


: