
-----------------------------------
jessie_f
Sun May 14, 2006 6:40 pm

time + type at the same time
-----------------------------------
HELLOo people :wink:

how do you get user input and do the timer thing at the same time.

so i searched high and low for an answer but the only thing i could find was to get a single character each time. so i decided to register =P thing is, i want to save individual words the user types in into an array so that i may *spellcheck* it later. yeh i'm doing a typing game. 

yupp.. my turing knowledge is soo limited i am going to fail my ISP or whatever. it's due tomorrow, but there's no way im handing it in on time! :shock:

THANK YOU!

-----------------------------------
Dan
Sun May 14, 2006 6:54 pm


-----------------------------------
Well how is your timmer working? It helps to post the code you have when asking for help.

The two methods i whould sugested are:

1. Using the non blocking character functions you talked about and add each letter to a string. Then when they are done go threw the string and break it up in to smaller ones with substrings.

2. Use processes (procs). Thess are functions that will simualte runing two things at the same time. Tho the key here is simualte since if you only have one cpu it is imposable to do two things at once. This route whould probly be more effshent but makes bad things happen if done worng.

You can find more infomtation on proceses and substrings in our tutoral section.

-----------------------------------
TheOneTrueGod
Sun May 14, 2006 7:00 pm


-----------------------------------
Hey, welcome to compsci.  

#1 This place moves kinda slowly, so posting the day before the ISU generally isn't a good idea :wink: 

#2 Specific examples, such as code you have tried will help others help you much better.

Allright, onto the advice.  Judging by what you said, I believe this is an actual use for processes *gasp*.  You could use a process and Time.Elapsed to constantly output the time to the screen, or you could use Input.KeyDown in a clever and well thought out way.  Since your short on time, you might want to go for the process way  :wink:.

I'll try and give some easy examples to follow for each one.

for the process method, you basically just want to:

loop
    locate(locationx,locationy)
    put maxTimeGiven - (Time.Elapsed - timeStarted)
    if maxTimeGiven - (Time.Elapsed - timeStarted) =] ) i just want to know how you can type + time + save the input like dan's first suggestion. 

um i guess here's the code i found on compsci before i registered haha. 

View.Set ("offscreenonly")
var input := ""
var _char : string (1)
var lastTime := -1000
var counter := 11
var fontID := Font.New ("Arial:16")

loop

    if hasch then
        getch (_char)
        exit when ord (_char) = 10  %enter
        if ord (_char) = 8 then %backspace
            if input ~= "" then
                input := input (1 .. * -1)  %chomp off the last char
            end if
        else
            input += _char
        end if
    end if
    if Time.Elapsed > lastTime + 1000 then              %updates every second (1000 milliseconds)
        lastTime := Time.Elapsed
        counter -= 1
    end if

    cls
    Font.Draw (input, 100, 200, fontID, black)
    Font.Draw (intstr (counter), 100, 100, fontID, black)
    View.Update
    delay (10)

    exit when counter 