%%HP: T(3)F(.);
@ MZIK, by Jonathan T. Higa
\<< \-> S
  \<<
    IF S TYPE 2 \=/
    THEN # 202h DOERR
    END
    IFERR RCL\GS
    THEN
    ELSE DROP S "\GSDAT exists." DOERR
    END MZKPAR TYPE 5 ==
    IF DUP
    THEN MZKPAR SIZE 4 == AND
    END
    IF NOT
    THEN { 55 4 3 128 } 'MZKPAR' STO
    END MZKPAR OBJ\-> DROP \-> A L O T
    \<<
      WHILE S "" \=/
      REPEAT S 1 1 SUB 2 \-> I
        \<< 0
          WHILE "-+b#" S I I SUB POS
          REPEAT "+#" S I I SUB POS 1 -1 IFTE + 'I' 1 STO+
          END I \-> J
          \<<
            WHILE S J J SUB NUM DUP 48 \>= SWAP 58 < AND
            REPEAT 'J' 1 STO+
            END
            IF J I >
            THEN S I J 1 - SUB OBJ\->
            ELSE -1
            END 0
            WHILE S J J SUB "." ==
            REPEAT 1 + 'J' 1 STO+
            END S J S SIZE SUB 'S' STO
          \>>
        \>> \-> C X N P
        \<<
          CASE "ABCDEFG" C POS
            THEN 2 [ -9 -7 -5 -4 -2 0 2 ] "CDEFGAB" C POS GET
                X + 12 / O + ^ A * 240 T N 0 > N L
                IFTE * / 2 .5 P ^ - * 2 \->ARRY \GS+
            END "H" C ==
            THEN \GS- 0 240 T N 0 > N L IFTE * / 2 .5 P ^ -
                * 2 \->ARRY + \GS+
            END "P" C ==
            THEN 0 240 T N 0 > N L IFTE * / 2 .5 P ^ -
                * 2 \->ARRY \GS+
            END "<>" C POS
            THEN 'O' N 1 MAX
              IF "<" C ==
              THEN NEG
              END STO+
            END "LOT" C POS N -1 \=/ AND
            THEN N
              IF X
              THEN X *
              END { L O T } "LOT" C POS GET STO
            END "K" C ==
            THEN
              IF X
              THEN 'A' 2 X N -1 \=/ N 1 IFTE * 12 / ^ STO*
              ELSE
                    IF N 0 >
                    THEN N 'A' STO
                    END
              END
            END
          END
        \>>
      END { } A + L + O + T + 'MZKPAR' STO
    \>>
  \>> "\<< " "\>>"
  WHILE
    IFERR \GS-
    THEN 0
    ELSE 1
    END
  REPEAT OBJ\-> DROP \-> F D
    \<<
      IF F
      THEN F \->STR " " + D \->STR + " BEEP "
      ELSE D \->STR " WAIT "
      END + SWAP +
    \>>
  END + OBJ\->
\>>
