@read_char From DM4 - Not Working?

I see the following code in the DM4:

[ PressAnyKey k; @read_char 1 -> k; return k; ];

However, if I use that exact example I get a compilation error:

Inform 6.43 for MacOS (in development)
line 45: Error:  Expected an opcode name but found read_char
> [ PressAnyKey k; @read_char
Compiled with 1 error (no output)

I feel like I’m missing something obvious here but I have no idea what.

1 Like

That’s the error you get if you try to compile that line in Glulx. Glulx does not have a @read_char opcode; input is too complicated to handle with single opcodes.

If you’re writing a game with the I6 library, call KeyCharPrimitive(). If you’re writing I6 code from the bare metal, you’ll need to learn enough about the library to reimplement KeyCharPrimitive(). :)

2 Likes

And that, indeed, was the obvious thing I was missing. Thank you!