I’m trying to make a terminal user interface in Dyalog APL and need a way to read a single byte of user input from stdin. How can I do this? In Python for example, you can use sys.stdin.read(1).
I’ve tried using ⍞, but that reads a whole line.
I’m trying to make a terminal user interface in Dyalog APL and need a way to read a single byte of user input from stdin. How can I do this? In Python for example, you can use sys.stdin.read(1).
I’ve tried using ⍞, but that reads a whole line.
Copyright © 2021 Jogjafile Inc.
You can do this with
⎕ARBIN, which can be used like this:The number of bytes to read is
1, and there are no bytes to output (⍬). You can assign a tie number to stdin with⎕NTIE.⎕ARBINreturns a numeric vector, so First (⊃) is used to get the byte as a scalar.