$MLC F 100 10 3000
300 INPUT "How many rectangles : ":N
310 CALL LINK("TEST",N)
320 END
$TEST
    GETPARAM 1 N                ; how many rectangles said the user
    XREGENABLE                  ; access enabled to extended registers
    STARTDATA
        byte &hE3               ; BML def bloc, first byte is flags with palette 3
        byte &h40               ; then address (here 64*64 = 4096)
        bytes 64,32,128,128     ; then x,y,w,h
    ENDDATA E
    BMLSET 0 E                  ; set my BML without display
    BMLPLOT 0 0 0
    BMLFILLRECT 128 128         ; clear everything
    BMLSET 1 E                  ; and display the BML
    CLEAR C
    NDO I N
        RND
        AND Z 63
        LET X Z                 ; X upper corner from 0 to 63
        RND
        AND Z 63                ; same for Y
        BMLPLOT X Z C           ; plot upper corner
        RND
        AND Z 31
        ADD Z 32
        LET X Z                 ; width = 32 to 63
        RND
        AND Z 31
        ADD Z 32                ; height from 32 to 63
        BMLFILLRECT X Z         ; fill W,H from last plot
        INC C                   ; next color
        AND 3 C                 ; always from 0 to 3
    NLOOP
    KEYWAIT 0
    PUTTABLE E(0) &h60          ; else, change flags to "BML disabled"
    BMLSET 1 E                  ; and set new parameters
$$
$END