kent logo

CO538 Anonymous Questions and Answers Keyword Index

This page provides a keyword index to questions and answers. Clicking on a keyword will take you to a page containing all questions and answers for that keyword, grouped by year.

To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.

Keyword reference for keyboard


Question 11 (2012):

Submission reference: IN2163

How exactly is keyboard input performed in occam-pi?

It is my understanding that keyboards input a BYTE character, but how does the key press register in the monitor process?

Answer 11:

A physical keyboard outputs ASCII codes corresponding to keys that are pressed on it. On a PC/laptop, the operating system grabs these codes and buffers them for delivery to the application in the window on which the PC/laptop user has current focus.

If this application is the Transterpreter runtime system (because you have focus on the "occplug") or the KRoC runtime system (because you have focus on the terminal window in which you started the occam-pi system), that runtime system takes the ASCII code (which is an occam-pi BYTE) from the operating system and sends it down the CHAN BYTE input channel in the parameter list of the last PROC declaration in your main compilation unit.

We have not told you about building separately compiled units (libraries), so you only have main ones – e.g. q4.occ. All your starter files have as their last PROC declaration something like:

    PROC q4 (CHAN BYTE keyboard?, CHAN BYTE screen!, CHAN BYTE error!)

So, to get keyboard input from a user interacting with an occam-pi system running on a PC/laptop, your code simply inputs from this keyboard? parameter channel. Your monitor process needs keyboard input. To enable this, your q4 process (see above) must invoke monitor, passing its keyboard? channel as one of the arguments. Of course, q4 will be invoking several other processes in parallel with monitor.

Keywords: keyboard

Valid CSS!

Valid XHTML 1.0!

This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.
Last modified Mon May 20 13:50:27 2013
This document is maintained by Fred Barnes, to whom any comments and corrections should be addressed.