apldyalog

How can I use rich boxing when printing something in a function in Dyalog APL?


If I use quad-gets (⎕←...) to print some debugging information inside a function in Dyalog APL, it doesn't seem to respect my ]box settings. How can I print stuff with boxing on?

      tmp ← {⎕←⍵}

      ]box on -s=max
┌→────────────────┐
│Was ON -style=max│
└─────────────────┘

      3 3 3⍴⍳27
┌┌→───────┐
↓↓ 1  2  3│
││ 4  5  6│
││ 7  8  9│
││        │
││10 11 12│
││13 14 15│
││16 17 18│
││        │
││19 20 21│
││22 23 24│
││25 26 27│
└└~───────┘

      tmp 3 3 3⍴⍳27 ⍝ No box!
 1  2  3
 4  5  6
 7  8  9

10 11 12
13 14 15
16 17 18

19 20 21
22 23 24
25 26 27

Solution

  • Quoting from the ]box documentation, viewable with ]box -??:

    -fns={off|on}  diagram output from running functions
        Display of {⌽⎕←⍵}'hello' 'world' with -fns=...  
             off               on                       
         hello  world    ┌─────┬─────┐                  
        ┌─────┬─────┐    │hello│world│                  
        │world│hello│    └─────┴─────┘                  
        └─────┴─────┘    ┌─────┬─────┐                  
                         │world│hello│                  
                         └─────┴─────┘                   
    

    So you can enable boxed output from functions with ]box -f=on (note that user command modifiers can be abbreviated). You can also enable boxing globally and for functions as a single command: ]box on -f=on