Computer Science Canada

How can I use getch to input multiple characters?

Author:  asdfasdf123 [ Tue Jan 13, 2015 11:59 am ]
Post subject:  How can I use getch to input multiple characters?

What is it you are trying to achieve?
Explained in the title.


What is the problem you are having?
When I try to input multiple characters with getch, it says "Argument is the wrong type".


Describe what you have tried to solve this problem
Looking up the problem.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:


import GUI
setscreen ("graphics:max;max")
var c : string (2)
var b : int := GUI.CreateButton (maxx - 100, 0, 0, "Quit", GUI.Quit)
loop
    exit when GUI.ProcessEvent
    getch (c)
    put (c)
end loop



Please specify what version of Turing you are using
4.1 1.0.1

Author:  Tony [ Tue Jan 13, 2015 2:30 pm ]
Post subject:  RE:How can I use getch to input multiple characters?

Read the documentation for details -- getch

The argument is defined to be of type string(1) (so it is expected for type string(2) to be of "wrong type"). You can use getch twice, and probably should -- there is a long time (from a fast computer's perspective) in between two key presses.


: