Task

Produce a formatted   12×12   multiplication table of the kind memorized by rote when in primary (or elementary) school.



Only print the top half triangle of products.




PROC PrintRight(BYTE num,size)
  BYTE i
 
  IF num<10 THEN
    size==-1
  ELSEIF num<100 THEN
    size==-2
  ELSE
    size==-3
  FI
  FOR i=1 TO size
  DO
    Put(' )
  OD
  PrintB(num)
RETURN
 
PROC Main()
  BYTE ARRAY colw=[1 1 1 2 2 2 2 2 2 3 3 3]
  BYTE i,j,x,w
 
  ;clear screen
  Put(125)
 
  ;draw frame
  Position(1,3)
  FOR i=1 TO 38
  DO Put($12) OD
 
  FOR j=2 TO 15
  DO
    Position(36,j)
    Put($7C)
  OD
 
  Position(36,3)
  Put($13)
 
  ;draw numbers
  FOR j=1 TO 12
  DO
    x=1
    FOR i=1 TO 12
    DO
      w=colw(i-1)
      IF i>=j THEN
        IF j=1 THEN
          Position(x,j+1)
          PrintRight(i*j,w)
        FI
        IF i=12 THEN
          Position(37,j+3)
          PrintRight(j,2)
        FI
        Position(x,j+3)
        PrintRight(i*j,w)
      FI
      x==+w+1
    OD
  OD
RETURN