BOXING(DEGREE)
 ;This takes in a degree heading, nominally from 0 to 360, and returns the compass point name.
 QUIT:((DEGREE<0)||(DEGREE>360)) "land lubber can't read a compass"
 NEW DIRS,UNP,UNPACK,SEP,DIR,DOS,D,DS,I,F
 SET DIRS="N^NbE^N-NE^NEbN^NE^NEbE^E-NE^EbN^E^EbS^E-SE^SEbE^SE^SEbS^S-SE^SbE^"
 SET DIRS=DIRS_"S^SbW^S-SW^SWbS^SW^SWbW^W-SW^WbS^W^WbN^W-NW^NWbW^NW^NWbN^N-NW^NbW"
 SET UNP="NESWb"
 SET UNPACK="north^east^south^west^ by "
 SET SEP=360/$LENGTH(DIRS,"^")
 SET DIR=(DEGREE/SEP)+1.5
 SET DIR=$SELECT((DIR>33):DIR-32,1:DIR)
 SET DOS=$NUMBER(DIR-.5,0)
 SET D=$PIECE(DIRS,"^",DIR)
 SET DS=""
 FOR I=1:1:$LENGTH(D) DO
 . SET F=$FIND(UNP,$EXTRACT(D,I)) SET DS=DS_$SELECT((F>0):$PIECE(UNPACK,"^",F-1),1:$E(D,I))
 KILL DIRS,UNP,UNPACK,SEP,DIR,D,I,F
 QUIT DOS_"^"_DS

BOXWRITE
 NEW POINTS,UP,LO,DIR,P,X
 SET POINTS="0.0,16.87,16.88,33.75,50.62,50.63,67.5,84.37,84.38,101.25,118.12,118.13,135.0,151.87,"
 SET POINTS=POINTS_"151.88,168.75,185.62,185.63,202.5,219.37,219.38,236.25,253.12,253.13,270.0,286.87,"
 SET POINTS=POINTS_"286.88,303.75,320.62,320.63,337.5,354.37,354.38"
 SET UP="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 SET LO="abcdefghijklmnopqrstuvwxyz"
 FOR P=1:1:$LENGTH(POINTS,",") DO
 . SET X=$$BOXING($PIECE(POINTS,",",P))
 . ;Capitalize the initial letter of the direction
 . SET DIR=$PIECE(X,"^",2)
 . SET DIR=$TRANSLATE($EXTRACT(DIR,1),LO,UP)_$EXTRACT(DIR,2,$LENGTH(DIR))
 . WRITE $PIECE(X,"^"),?5,DIR,?40,$JUSTIFY($PIECE(POINTS,",",P),10,2),!
 KILL POINTS,UP,LO,DIR,P,X
 QUIT
