1. putitng info from keyboard

I am new to this but what I want to do like I did in basic to start with is to be able to input info useing the keyboard.I have look and havn't seen an example of it.I think it could be something like getkey.but what would you put the answer in

new topic     » topic index » view message » categorize

2. Re: putitng info from keyboard

sequence input 
 
input = prompt_string( "Please enter your input: " ) 
printf( 1, "Your input was: \"%s\"\n", {input} ) 

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: putitng info from keyboard

Another easy example would be.

include get.e 
 
constant ESC = 27 
 
integer key 
key = get_key() 
 
while 1 do 
 if key = ESC then 
      exit 
 end if 
end while 

This will end the program when you press ESC. Check the key.bat for list of keycodes.

new topic     » goto parent     » topic index » view message » categorize

4. Re: putitng info from keyboard

Andy said...

Another easy example would be.

code

This will end the program when you press ESC. Check the key.bat for list of keycodes.

That won't do anything since it only calls get_key() once.

include get.e 
 
constant ESC = 27 
 
integer key 
 
while 1 do 
    key = get_key()   -- moved inside the loop 
    if key = ESC then 
        exit 
    end if 
end while 

That's better. grin

-Greg

new topic     » goto parent     » topic index » view message » categorize

5. Re: putitng info from keyboard

You could also use wait_key() instead of get_key() in that example, which would wait gracefully rather than polling continuously. blink

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: putitng info from keyboard

ghaberek said...

You could also use wait_key() instead of get_key() in that example, which would wait gracefully rather than polling continuously. blink

-Greg

Ah that's right, Thanks for catching my error.

new topic     » goto parent     » topic index » view message » categorize

7. Re: putitng info from keyboard

is there a way to set a time limit or have it randomised

new topic     » goto parent     » topic index » view message » categorize

8. Re: putitng info from keyboard

so is the sentence saved in key

new topic     » goto parent     » topic index » view message » categorize

9. Re: putitng info from keyboard

fred said...

is there a way to set a time limit

You'd have to write your own input function that uses get_key() to watch for keyboard and collect it in a sequence, while also monitoring the time passed since it started monitoring. Then when the time passed a certain point, it would exit its loop and continue on.

fred said...

or have it randomised

Or have what randomized? The input from the user? The time limit?

fred said...

so is the sentence saved in key

get_key() and wait_key() only return the key pressed:

integer key 
 
key = wait_key() 
printf( 1, "%s\n", key ) 


So if I press the 'K' key, that would simply output:

K 


-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu