⎕ — Output and input

Keys: Alt-q

⎕←Y explicitly prints Y and retains its value.

≥⎕←2              ⍝ 3

The example prints 2 before returning 3. Explicit output is separate from implicit result display and is captured by the evaluation API.

Input

Reading ⎕ gives the next line of standard input as a string, without its line ending. At the end of the input it gives ⍬, not the "" of an empty line. ⍎⎕ evaluates the line, as Dyalog’s ⎕ does. •nget "-" gives the rest of standard input as one string.

printf '3\n4\n' | bpl -e '+/⍎¨[⎕ ⎕]'       # 7

"-" •nput text writes text to standard output with no line ending added. When ⎕ is read, the text written since the last line ending is its prompt. A terminal shows the prompt and reads the answer on the same line, and a notebook shows the prompt beside its text box.

printf 'bob\n' | bpl -e '"-" •nput "Name? " ⋄ "Hi ",⎕'   # Name? Hi bob

bpl -e, script files and the interactive REPL read standard input. In a notebook, ⎕ asks for a line in a text box, but •nget "-" is an IO error. The Python API reads each line with Python’s input(), and •nget "-" reads sys.stdin. bpl - and piped REPL input read the program itself from standard input. In those two modes and in bpl --worker, reading ⎕ or •nget "-" is an IO error.

Dyalog’s ⎕A and ⎕D are BPL’s $a and $d. ⎕C and ⎕UCS are •c and •ucs.