#title: Sheet All-Needle Cast-On (plain python)
# Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

#Write header:
print(';!knitout-2')
print(';;Machine: Kniterate')
print(';;Carriers: 1 2 3 4 5 6')

#Parameters:
min = 1 #needle number of left edge
max = 20 #needle number of right edge
carrier = "3" #carrier name

#Bring in carrier:
print(f"in {carrier}")

#On Kniterate machines, carriers start on the left,
#so will start by tucking all needles left-to-right,
#and will be sure to tuck the rightmost back-bed needle last.

#Need to use quarter-pitch racking to tuck all needles in one pass:
print(f"rack 0.5")

for n in range(min, max+1, 1):
	print(f"tuck + f{n} {carrier}")
	print(f"tuck + b{n} {carrier}")

#Return to aligned racking:
print(f"rack 0")

#Do a row of plain knitting on the front and back:
for n in range(max, min-1, -1):
	print(f"knit - f{n} {carrier}")
for n in range(min, max+1, 1):
	print(f"knit + b{n} {carrier}")
#One can knit more on the front or back beds here to make a larger "welt" at the edge.

#Stack back-bed stitches with front-bed stitches:
for n in range(min, max+1, 1):
	print(f"xfer b{n} f{n}")

#knit two plain rows through the stacked stitches to return carrier to the right edge:
for n in range(max, min-1, -1):
	print(f"knit - f{n} {carrier}")
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")


#...now can knit on [min,max].
