Shop OBEX P1 Docs P2 Docs Learn Events
KEYCODE instruction operation in FemtoBasic? — Parallax Forums

KEYCODE instruction operation in FemtoBasic?

Duane C. JohnsonDuane C. Johnson Posts: 955
edited 2011-07-22 21:36 in Propeller 1
I am trying to us the KEYCODE instruction in FemtoBasic.

Well, I'm actually running DongleBasic. I want to read a single ascii code
representing the keystroke from the serial port or "0" for an empty buffer

KEYCODE
The value of the next keyboard key value or zero if the keyboard buffer is empty.

I guess I don't understand how this works.
Do you have any examples of how to use this.
It seems like I have tried everything but all I get is an error like this:

10 A = KEYCODE
IN LINE 10 Syntax Error
or
10 PRINT KEYCODE
IN LINE 10 Syntax Error
or
10 IF KEYCODE <> 0 THEN PRINT "x"
IN LINE 10 Syntax Error
but
10 KEYCODE
works but where do I find the code?

What am I doing wrong?

Duane

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-07-22 19:39
    My mistake (in the documentation). Sorry. FemtoBasic uses just KEYCODE, but DongleBasic uses KEYCODE[ <mstime> ] where <mstime> is a timeout in milliseconds. I probably ought to modify DongleBasic to make the timeout optional in addition to documenting it properly. The other FemtoBasic derivatives that use the downloading interface for a console probably have the same issue. I'll try to get to it over the weekend.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-07-22 21:36
    Thanks Mike, that works just fine.

    Duane
Sign In or Register to comment.