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.




 
REM Multiplication tables
N = 12
PREDN = N - 1
WDTH = 3
CLS
FOR J = 1 TO PREDN
  INTVAL = J
  GOSUB PRINTINT:
  PRINT " ";
NEXT J
INTVAL = N
GOSUB PRINTINT:
PRINT
FOR J = 0 TO PREDN
  PRINT "----";
NEXT J
PRINT "+"
FOR I = 1 TO N
  WDTH = 3
  FOR J = 1 TO N    
    IF J < I THEN
      PRINT "    ";
    ELSE
      INTVAL = I * J      
      GOSUB PRINTINT:
      PRINT " ";
    ENDIF
  NEXT J
  PRINT "| ";
  INTVAL = I
  WDTH = 2
  GOSUB PRINTINT:
  PRINT
NEXT I
END
 
PRINTINT:
REM Writes the value of INTVAL in a field of the given WDTH
S2$ = STR$(INTVAL)
S2$ = LTRIM$(S2$)
SPNUM = LEN(S2$)
SPNUM = WDTH - SPNUM
S1$ = SPACE$(SPNUM)
PRINT S1$;
PRINT S2$;
RETURN
 