Posted to tcl by stu at Mon Jan 03 10:21:53 GMT 2022view pretty

$ cat 4x4.gob      

# Gub example
# Turn a row of 16 buttons into a 4x4 grid

# 16 buttons in a row
b b b b b b b b b b b b b b b b

# Push b4, b8 and b12 each down by 1 row
!:-b4-12*4 +1

# Put b4, b8 and b12 in column 0
!:|b4-12*4 0



$ gubtool 4x4.gob  

grid [tk::button .b0] -row 0 -column 0
grid [tk::button .b1] -row 0 -column 1
grid [tk::button .b2] -row 0 -column 2
grid [tk::button .b3] -row 0 -column 3
grid [tk::button .b4] -row 1 -column 0
grid [tk::button .b5] -row 1 -column 1
grid [tk::button .b6] -row 1 -column 2
grid [tk::button .b7] -row 1 -column 3
grid [tk::button .b8] -row 2 -column 0
grid [tk::button .b9] -row 2 -column 1
grid [tk::button .b10] -row 2 -column 2
grid [tk::button .b11] -row 2 -column 3
grid [tk::button .b12] -row 3 -column 0
grid [tk::button .b13] -row 3 -column 1
grid [tk::button .b14] -row 3 -column 2
grid [tk::button .b15] -row 3 -column 3