Cast-on

Casting on is the process of starting a swatch. This involves tucking onto needles so that it will be possible to knit through those loops.

Sheet Cast-on

Casting on a sheet involves forming the initial loops to knit through when beginning the sheet, creating a closed edge. When knitting on a single bed, the tucks are typically done on every other needle, since tucking on consecutive needles essentially drapes the yarn over those needles without creating any secured loops, resulting in a lack of tension that will cause the final swatch to fall apart. Note that, for this reason, one must be careful not to knit a stitch that was just tucked after casting on a sheet. Instead, one can use an alternating tuck cast-on, which alternates between tucking and missing in on direction, and then in the other direction, tucking on the needles that were missed and missing on those that were tucked in the previous pass. Once the overlapping strands of yarn in either pass have created secure loops, the knitting can begin.

When knitting a double-bed sheet, one typically uses a different method called a 'zig-zag' cast-on, which involves racking to half pitch (which shifts the back bed such that it's needles are no longer adjacent to the corresponding needles on the front bed), and then tuck on all needles on both beds in a single pass. Because of the zig-zag pattern that this method creates, the unsecured strand of yarn is no longer an issue.

Tube Cast-on

When casting on a tube, it is important that the fabric remains open, so the cast-on methods involves an alternating tuck cast-on moving in a circle from the end of one bed to the opposite end on the other bed. Then, one does the same thing once again, filling in the needles that were missed the first time around. This results in a total of four passes, completing two full rotations around the needle beds.

for written in
//title: Sheet Cast-On (javascript with knitout module)
// Casts on a sheet by tucking even/odd front bed needles.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6'] });
K.addHeader('Machine', 'Kniterate');

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

//Bring in carrier:
K.in(carrier);

//On Kniterate machines, carriers start on the left,
//so will start tucking onto needles left-to-right,
//and will be sure to tuck the leftmost needle in the first pass:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	if ((n - min) % 2 === 0) {
		K.tuck("+", 'f' + n, carrier);
	}
}
//now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for (let n = max; n >= min; n -= 1) {
	if ((n - min) % 2 !== 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}

//knit three plain rows to allow cast-on stitches to relax:
// three isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

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

K.write('sheet-cast-on.kniterate.k');
;!knitout-2
;;Machine: Kniterate
;;Carriers: 1 2 3 4 5 6

;title: Sheet Cast-On (raw knitout)
; Casts on a sheet by tucking even/odd front bed needles.

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

;Bring in carrier:
in 3

;On Kniterate machines, carriers start on the left,
;so will start tucking onto needles left-to-right,
;and will be sure to tuck the leftmost needle in the first pass:
tuck + f1 3
tuck + f3 3
tuck + f5 3
tuck + f7 3
tuck + f9 3
tuck + f11 3
tuck + f13 3
tuck + f15 3
tuck + f17 3
tuck + f19 3
;now, moving right-to-left, tuck the needles that were not tucked on the first pass:
tuck - f20 3
tuck - f18 3
tuck - f16 3
tuck - f14 3
tuck - f12 3
tuck - f10 3
tuck - f8 3
tuck - f6 3
tuck - f4 3
tuck - f2 3

;knit three plain rows to allow cast-on stitches to relax:
; three isn't set in stone here -- it's just convenient
; for this example code to have the carrier end up on the right.
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

;...now can knit on [min,max].
//title: Sheet Cast-On (plain javascript)
// Casts on a sheet by tucking even/odd front bed needles.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: Kniterate');
console.log(';;Carriers: 1 2 3 4 5 6');

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

//Bring in carrier:
console.log(`in ${carrier}`);

//On Kniterate machines, carriers start on the left,
//so will start tucking onto needles left-to-right,
//and will be sure to tuck the leftmost needle in the first pass:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	if ((n - min) % 2 === 0) {
		console.log(`tuck + f${n} ${carrier}`);
	}
}
//now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for (let n = max; n >= min; n -= 1) {
	if ((n - min) % 2 !== 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}

//knit three plain rows to allow cast-on stitches to relax:
// three isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

//...now can knit on [min,max].
#title: Sheet Cast-On (plain python)
# Casts on a sheet by tucking even/odd front bed needles.

#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 tucking onto needles left-to-right,
#and will be sure to tuck the leftmost needle in the first pass:
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	if (n - min) % 2 == 0:
		print(f"tuck + f{n} {carrier}")
#now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for n in range(max, min-1, -1):
	if (n - min) % 2 != 0:
		print(f"tuck - f{n} {carrier}")

#knit three plain rows to allow cast-on stitches to relax:
# three isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
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].
#title: Sheet Cast-On (python with knitout module)
# Casts on a sheet by tucking even/odd front bed needles.

import knitout
K = knitout.Writer('1 2 3 4 5 6');
K.addHeader('Machine', 'Kniterate');

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

#Bring in carrier:
K.ingripper(carrier)

#On Kniterate machines, carriers start on the left,
#so will start tucking onto needles left-to-right,
#and will be sure to tuck the leftmost needle in the first pass:
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	if (n - min) % 2 == 0:
		K.tuck("+", 'f' + str(n), carrier)
#now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for n in range(max, min-1, -1):
	if (n - min) % 2 != 0:
		K.tuck("-", 'f' + str(n), carrier)

#knit three plain rows to allow cast-on stitches to relax:
# three isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

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

K.write('sheet-cast-on.kniterate.k')
//title: Sheet Cast-On (javascript with knitout module)
// Casts on a sheet by tucking even/odd front bed needles.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] });
K.addHeader('Machine', 'SWGN2');

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

//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

//On SWGN2 machines, carriers start on the right,
//so will start tucking onto needles right-to-left,
//and will be sure to tuck the rightmost needle in the first pass:
for (let n = max; n >= min; n -= 1) {
	//tuck alternating needles, making sure to do the right edge:
	if ((max - n) % 2 === 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}
//now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for (let n = min; n <= max; n += 1) {
	if ((max - n) % 2 !== 0) {
		K.tuck("+", 'f' + n, carrier);
	}
}
//Set stitch table entry for knitting:
K.stitchNumber(105);
//knit two plain rows to allow cast-on stitches to relax:
// two isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

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

K.write('sheet-cast-on.swgn2.k');
;!knitout-2
;;Machine: SWGN2
;;Carriers: 1 2 3 4 5 6 7 8 9 10

;title: Sheet Cast-On (raw knitout)
; Casts on a sheet by tucking even/odd front bed needles.

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

;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

;On SWGN2 machines, carriers start on the right,
;so will start tucking onto needles right-to-left,
;and will be sure to tuck the rightmost needle in the first pass:
tuck - f20 3
tuck - f18 3
tuck - f16 3
tuck - f14 3
tuck - f12 3
tuck - f10 3
tuck - f8 3
tuck - f6 3
tuck - f4 3
tuck - f2 3
;now, moving left-to-right, tuck the needles that were not tucked on the first pass:
tuck + f1 3
tuck + f3 3
tuck + f5 3
tuck + f7 3
tuck + f9 3
tuck + f11 3
tuck + f13 3
tuck + f15 3
tuck + f17 3
tuck + f19 3
;Set stitch table entry for knitting:
x-stitch-number 105
;knit two plain rows to allow cast-on stitches to relax:
; two isn't set in stone here -- it's just convenient
; for this example code to have the carrier end up on the right.
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

;...now can knit on [min,max].
//title: Sheet Cast-On (plain javascript)
// Casts on a sheet by tucking even/odd front bed needles.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: SWGN2');
console.log(';;Carriers: 1 2 3 4 5 6 7 8 9 10');

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

//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

//On SWGN2 machines, carriers start on the right,
//so will start tucking onto needles right-to-left,
//and will be sure to tuck the rightmost needle in the first pass:
for (let n = max; n >= min; n -= 1) {
	//tuck alternating needles, making sure to do the right edge:
	if ((max - n) % 2 === 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}
//now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for (let n = min; n <= max; n += 1) {
	if ((max - n) % 2 !== 0) {
		console.log(`tuck + f${n} ${carrier}`);
	}
}
//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);
//knit two plain rows to allow cast-on stitches to relax:
// two isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

//...now can knit on [min,max].
#title: Sheet Cast-On (plain python)
# Casts on a sheet by tucking even/odd front bed needles.

#Write header:
print(';!knitout-2')
print(';;Machine: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

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

#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

#On SWGN2 machines, carriers start on the right,
#so will start tucking onto needles right-to-left,
#and will be sure to tuck the rightmost needle in the first pass:
for n in range(max, min-1, -1):
	#tuck alternating needles, making sure to do the right edge:
	if (max - n) % 2 == 0:
		print(f"tuck - f{n} {carrier}")
#now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for n in range(min, max+1, 1):
	if (max - n) % 2 != 0:
		print(f"tuck + f{n} {carrier}")
#Set stitch table entry for knitting:
print(f"x-stitch-number 105")
#knit two plain rows to allow cast-on stitches to relax:
# two isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(max, min-1, -1):
	print(f"knit - f{n} {carrier}")
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")

#...now can knit on [min,max].
#title: Sheet Cast-On (python with knitout module)
# Casts on a sheet by tucking even/odd front bed needles.

import knitout
K = knitout.Writer('1 2 3 4 5 6 7 8 9 10');
K.addHeader('Machine', 'SWGN2');

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

#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

#On SWGN2 machines, carriers start on the right,
#so will start tucking onto needles right-to-left,
#and will be sure to tuck the rightmost needle in the first pass:
for n in range(max, min-1, -1):
	#tuck alternating needles, making sure to do the right edge:
	if (max - n) % 2 == 0:
		K.tuck("-", 'f' + str(n), carrier)
#now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for n in range(min, max+1, 1):
	if (max - n) % 2 != 0:
		K.tuck("+", 'f' + str(n), carrier)
#Set stitch table entry for knitting:
K.stitchNumber(105)
#knit two plain rows to allow cast-on stitches to relax:
# two isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

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

K.write('sheet-cast-on.swgn2.k')
//title: Tube Cast-On (javascript with knitout module)

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6'] });
K.addHeader('Machine', 'Kniterate');

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

//Bring in carrier:
K.in(carrier);

//On Kniterate machines, carriers start on the left,
//so will start tucking onto needles left-to-right:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles starting at the left edge:
	if ((n-min) % 2 === 0) {
		K.tuck("+", 'b' + n, carrier);
	}
}

//...continue clockwise around the tube to the front bed:
for (let n = max; n >= min; n -= 1) {
	//note that adding 1+max-min preserves the alternating-needles pattern:
	if ((1+max-min + max-n) % 2 === 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}

//...continue clockwise around the tube to the back bed and fill in needles missed the first time:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles starting at the left edge:
	if ((n-min) % 2 !== 0) {
		K.tuck("+", 'b' + n, carrier);
	}
}

//...finally, fill in the rest of the front bed:
for (let n = max; n >= min; n -= 1) {
	//note that adding 1+max-min preserves the alternating-needles pattern:
	if ((1+max-min + max-n) % 2 !== 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}

//now knit one and a half rows of plain knitting to let the cast-on stitches relax (and because having the carrier on the right will be convenient for example code):
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'b' + n, carrier);
}
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'b' + n, carrier);
}

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

K.write('tube-cast-on.kniterate.k');
;!knitout-2
;;Machine: Kniterate
;;Carriers: 1 2 3 4 5 6

;title: Tube Cast-On (raw knitout)

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

;Bring in carrier:
in 3

;On Kniterate machines, carriers start on the left,
;so will start tucking onto needles left-to-right:
tuck + b1 3
tuck + b3 3
tuck + b5 3
tuck + b7 3
tuck + b9 3
tuck + b11 3
tuck + b13 3
tuck + b15 3
tuck + b17 3
tuck + b19 3

;...continue clockwise around the tube to the front bed:
tuck - f20 3
tuck - f18 3
tuck - f16 3
tuck - f14 3
tuck - f12 3
tuck - f10 3
tuck - f8 3
tuck - f6 3
tuck - f4 3
tuck - f2 3

;...continue clockwise around the tube to the back bed and fill in needles missed the first time:
tuck + b2 3
tuck + b4 3
tuck + b6 3
tuck + b8 3
tuck + b10 3
tuck + b12 3
tuck + b14 3
tuck + b16 3
tuck + b18 3
tuck + b20 3

;...finally, fill in the rest of the front bed:
tuck - f19 3
tuck - f17 3
tuck - f15 3
tuck - f13 3
tuck - f11 3
tuck - f9 3
tuck - f7 3
tuck - f5 3
tuck - f3 3
tuck - f1 3

;now knit one and a half rows of plain knitting to let the cast-on stitches relax (and because having the carrier on the right will be convenient for example code):
knit + b1 3
knit + b2 3
knit + b3 3
knit + b4 3
knit + b5 3
knit + b6 3
knit + b7 3
knit + b8 3
knit + b9 3
knit + b10 3
knit + b11 3
knit + b12 3
knit + b13 3
knit + b14 3
knit + b15 3
knit + b16 3
knit + b17 3
knit + b18 3
knit + b19 3
knit + b20 3
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + b1 3
knit + b2 3
knit + b3 3
knit + b4 3
knit + b5 3
knit + b6 3
knit + b7 3
knit + b8 3
knit + b9 3
knit + b10 3
knit + b11 3
knit + b12 3
knit + b13 3
knit + b14 3
knit + b15 3
knit + b16 3
knit + b17 3
knit + b18 3
knit + b19 3
knit + b20 3

;...now can knit on [min,max].
//title: Tube Cast-On (plain javascript)

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: Kniterate');
console.log(';;Carriers: 1 2 3 4 5 6');

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

//Bring in carrier:
console.log(`in ${carrier}`);

//On Kniterate machines, carriers start on the left,
//so will start tucking onto needles left-to-right:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles starting at the left edge:
	if ((n-min) % 2 === 0) {
		console.log(`tuck + b${n} ${carrier}`);
	}
}

//...continue clockwise around the tube to the front bed:
for (let n = max; n >= min; n -= 1) {
	//note that adding 1+max-min preserves the alternating-needles pattern:
	if ((1+max-min + max-n) % 2 === 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}

//...continue clockwise around the tube to the back bed and fill in needles missed the first time:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles starting at the left edge:
	if ((n-min) % 2 !== 0) {
		console.log(`tuck + b${n} ${carrier}`);
	}
}

//...finally, fill in the rest of the front bed:
for (let n = max; n >= min; n -= 1) {
	//note that adding 1+max-min preserves the alternating-needles pattern:
	if ((1+max-min + max-n) % 2 !== 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}

//now knit one and a half rows of plain knitting to let the cast-on stitches relax (and because having the carrier on the right will be convenient for example code):
for (let n = min; n <= max; n += 1) {
	console.log(`knit + b${n} ${carrier}`);
}
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + b${n} ${carrier}`);
}

//...now can knit on [min,max].
#title: Tube Cast-On (plain python)

#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 tucking onto needles left-to-right:
for n in range(min, max+1, 1):
	#tuck alternating needles starting at the left edge:
	if (n-min) % 2 == 0:
		print(f"tuck + b{n} {carrier}")

#...continue clockwise around the tube to the front bed:
for n in range(max, min-1, -1):
	#note that adding 1+max-min preserves the alternating-needles pattern:
	if (1+max-min + max-n) % 2 == 0:
		print(f"tuck - f{n} {carrier}")

#...continue clockwise around the tube to the back bed and fill in needles missed the first time:
for n in range(min, max+1, 1):
	#tuck alternating needles starting at the left edge:
	if (n-min) % 2 != 0:
		print(f"tuck + b{n} {carrier}")

#...finally, fill in the rest of the front bed:
for n in range(max, min-1, -1):
	#note that adding 1+max-min preserves the alternating-needles pattern:
	if (1+max-min + max-n) % 2 != 0:
		print(f"tuck - f{n} {carrier}")

#now knit one and a half rows of plain knitting to let the cast-on stitches relax (and because having the carrier on the right will be convenient for example code):
for n in range(min, max+1, 1):
	print(f"knit + b{n} {carrier}")
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}")

#...now can knit on [min,max].
#title: Tube Cast-On (python with knitout module)

import knitout
K = knitout.Writer('1 2 3 4 5 6');
K.addHeader('Machine', 'Kniterate');

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

#Bring in carrier:
K.ingripper(carrier)

#On Kniterate machines, carriers start on the left,
#so will start tucking onto needles left-to-right:
for n in range(min, max+1, 1):
	#tuck alternating needles starting at the left edge:
	if (n-min) % 2 == 0:
		K.tuck("+", 'b' + str(n), carrier)

#...continue clockwise around the tube to the front bed:
for n in range(max, min-1, -1):
	#note that adding 1+max-min preserves the alternating-needles pattern:
	if (1+max-min + max-n) % 2 == 0:
		K.tuck("-", 'f' + str(n), carrier)

#...continue clockwise around the tube to the back bed and fill in needles missed the first time:
for n in range(min, max+1, 1):
	#tuck alternating needles starting at the left edge:
	if (n-min) % 2 != 0:
		K.tuck("+", 'b' + str(n), carrier)

#...finally, fill in the rest of the front bed:
for n in range(max, min-1, -1):
	#note that adding 1+max-min preserves the alternating-needles pattern:
	if (1+max-min + max-n) % 2 != 0:
		K.tuck("-", 'f' + str(n), carrier)

#now knit one and a half rows of plain knitting to let the cast-on stitches relax (and because having the carrier on the right will be convenient for example code):
for n in range(min, max+1, 1):
	K.knit("+", 'b' + str(n), carrier)
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'b' + str(n), carrier)

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

K.write('tube-cast-on.kniterate.k')
//title: Tube Cast-On (javascript with knitout module)

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] });
K.addHeader('Machine', 'SWGN2');

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

//Bring in carrier:
K.inhook(carrier);

//On SWGN2 machines, carriers start on the right,
//so will start tucking onto needles right-to-left:
for (let n = max; n >= min; n -= 1) {
	//tuck alternating needles starting at the right edge:
	if ((max - n) % 2 === 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}

//...continue clockwise around the tube to the back bed:
for (let n = min; n <= max; n += 1) {
	//note that adding 1+max-min preserves the alternating-needles pattern:
	if ((1+max-min + n - min) % 2 === 0) {
		K.tuck("+", 'b' + n, carrier);
	}
}

//...continue clockwise around the tube to the front bed and fill in needles missed the first time:
for (let n = max; n >= min; n -= 1) {
	if ((max - n) % 2 !== 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}

//...finally, fill in the rest of the back bed:
for (let n = min; n <= max; n += 1) {
	if ((1+max-min + n - min) % 2 !== 0) {
		K.tuck("+", 'b' + n, carrier);
	}
}

//now knit a row of plain knitting to let the cast-on stitches relax:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
//send the yarn inserting hook out -- yarn should be well-enough held by the needles at this point.
K.releasehook(carrier);
//finish the back of the row of plain knitting:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'b' + n, carrier);
}

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

K.write('tube-cast-on.swgn2.k');
;!knitout-2
;;Machine: SWGN2
;;Carriers: 1 2 3 4 5 6 7 8 9 10

;title: Tube Cast-On (raw knitout)

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

;Bring in carrier:
inhook 3

;On SWGN2 machines, carriers start on the right,
;so will start tucking onto needles right-to-left:
tuck - f20 3
tuck - f18 3
tuck - f16 3
tuck - f14 3
tuck - f12 3
tuck - f10 3
tuck - f8 3
tuck - f6 3
tuck - f4 3
tuck - f2 3

;...continue clockwise around the tube to the back bed:
tuck + b1 3
tuck + b3 3
tuck + b5 3
tuck + b7 3
tuck + b9 3
tuck + b11 3
tuck + b13 3
tuck + b15 3
tuck + b17 3
tuck + b19 3

;...continue clockwise around the tube to the front bed and fill in needles missed the first time:
tuck - f19 3
tuck - f17 3
tuck - f15 3
tuck - f13 3
tuck - f11 3
tuck - f9 3
tuck - f7 3
tuck - f5 3
tuck - f3 3
tuck - f1 3

;...finally, fill in the rest of the back bed:
tuck + b2 3
tuck + b4 3
tuck + b6 3
tuck + b8 3
tuck + b10 3
tuck + b12 3
tuck + b14 3
tuck + b16 3
tuck + b18 3
tuck + b20 3

;now knit a row of plain knitting to let the cast-on stitches relax:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;send the yarn inserting hook out -- yarn should be well-enough held by the needles at this point.
releasehook 3
;finish the back of the row of plain knitting:
knit + b1 3
knit + b2 3
knit + b3 3
knit + b4 3
knit + b5 3
knit + b6 3
knit + b7 3
knit + b8 3
knit + b9 3
knit + b10 3
knit + b11 3
knit + b12 3
knit + b13 3
knit + b14 3
knit + b15 3
knit + b16 3
knit + b17 3
knit + b18 3
knit + b19 3
knit + b20 3

;...now can knit on [min,max].
//title: Tube Cast-On (plain javascript)

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: SWGN2');
console.log(';;Carriers: 1 2 3 4 5 6 7 8 9 10');

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

//Bring in carrier:
console.log(`inhook ${carrier}`);

//On SWGN2 machines, carriers start on the right,
//so will start tucking onto needles right-to-left:
for (let n = max; n >= min; n -= 1) {
	//tuck alternating needles starting at the right edge:
	if ((max - n) % 2 === 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}

//...continue clockwise around the tube to the back bed:
for (let n = min; n <= max; n += 1) {
	//note that adding 1+max-min preserves the alternating-needles pattern:
	if ((1+max-min + n - min) % 2 === 0) {
		console.log(`tuck + b${n} ${carrier}`);
	}
}

//...continue clockwise around the tube to the front bed and fill in needles missed the first time:
for (let n = max; n >= min; n -= 1) {
	if ((max - n) % 2 !== 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}

//...finally, fill in the rest of the back bed:
for (let n = min; n <= max; n += 1) {
	if ((1+max-min + n - min) % 2 !== 0) {
		console.log(`tuck + b${n} ${carrier}`);
	}
}

//now knit a row of plain knitting to let the cast-on stitches relax:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
//send the yarn inserting hook out -- yarn should be well-enough held by the needles at this point.
console.log(`releasehook ${carrier}`);
//finish the back of the row of plain knitting:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + b${n} ${carrier}`);
}

//...now can knit on [min,max].
#title: Tube Cast-On (plain python)

#Write header:
print(';!knitout-2')
print(';;Machine: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

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

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

#On SWGN2 machines, carriers start on the right,
#so will start tucking onto needles right-to-left:
for n in range(max, min-1, -1):
	#tuck alternating needles starting at the right edge:
	if (max - n) % 2 == 0:
		print(f"tuck - f{n} {carrier}")

#...continue clockwise around the tube to the back bed:
for n in range(min, max+1, 1):
	#note that adding 1+max-min preserves the alternating-needles pattern:
	if (1+max-min + n - min) % 2 == 0:
		print(f"tuck + b{n} {carrier}")

#...continue clockwise around the tube to the front bed and fill in needles missed the first time:
for n in range(max, min-1, -1):
	if (max - n) % 2 != 0:
		print(f"tuck - f{n} {carrier}")

#...finally, fill in the rest of the back bed:
for n in range(min, max+1, 1):
	if (1+max-min + n - min) % 2 != 0:
		print(f"tuck + b{n} {carrier}")

#now knit a row of plain knitting to let the cast-on stitches relax:
for n in range(max, min-1, -1):
	print(f"knit - f{n} {carrier}")
#send the yarn inserting hook out -- yarn should be well-enough held by the needles at this point.
print(f"releasehook {carrier}")
#finish the back of the row of plain knitting:
for n in range(min, max+1, 1):
	print(f"knit + b{n} {carrier}")

#...now can knit on [min,max].
#title: Tube Cast-On (python with knitout module)

import knitout
K = knitout.Writer('1 2 3 4 5 6 7 8 9 10');
K.addHeader('Machine', 'SWGN2');

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

#Bring in carrier:
K.inhook(carrier)

#On SWGN2 machines, carriers start on the right,
#so will start tucking onto needles right-to-left:
for n in range(max, min-1, -1):
	#tuck alternating needles starting at the right edge:
	if (max - n) % 2 == 0:
		K.tuck("-", 'f' + str(n), carrier)

#...continue clockwise around the tube to the back bed:
for n in range(min, max+1, 1):
	#note that adding 1+max-min preserves the alternating-needles pattern:
	if (1+max-min + n - min) % 2 == 0:
		K.tuck("+", 'b' + str(n), carrier)

#...continue clockwise around the tube to the front bed and fill in needles missed the first time:
for n in range(max, min-1, -1):
	if (max - n) % 2 != 0:
		K.tuck("-", 'f' + str(n), carrier)

#...finally, fill in the rest of the back bed:
for n in range(min, max+1, 1):
	if (1+max-min + n - min) % 2 != 0:
		K.tuck("+", 'b' + str(n), carrier)

#now knit a row of plain knitting to let the cast-on stitches relax:
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
#send the yarn inserting hook out -- yarn should be well-enough held by the needles at this point.
K.releasehook(carrier)
#finish the back of the row of plain knitting:
for n in range(min, max+1, 1):
	K.knit("+", 'b' + str(n), carrier)

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

K.write('tube-cast-on.swgn2.k')
//title: Sheet All-Needle Cast-On (javascript with knitout module)
// Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6'] });
K.addHeader('Machine', 'Kniterate');

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

//Bring in carrier:
K.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:
K.rack(0.5);

for (let n = min; n <= max; n += 1) {
	K.tuck("+", 'f' + n, carrier);
	K.tuck("+", 'b' + n, carrier);
}

//Return to aligned racking:
K.rack(0);

//Do a row of plain knitting on the front and back:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.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 (let n = min; n <= max; n += 1) {
	K.xfer('b' + n, 'f' + n);
}

//knit two plain rows through the stacked stitches to return carrier to the right edge:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}


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

K.write('sheet-all-needle-cast-on.kniterate.k');
;!knitout-2
;;Machine: Kniterate
;;Carriers: 1 2 3 4 5 6

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

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

;Bring in carrier:
in 3

;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:
rack 0.5

tuck + f1 3
tuck + b1 3
tuck + f2 3
tuck + b2 3
tuck + f3 3
tuck + b3 3
tuck + f4 3
tuck + b4 3
tuck + f5 3
tuck + b5 3
tuck + f6 3
tuck + b6 3
tuck + f7 3
tuck + b7 3
tuck + f8 3
tuck + b8 3
tuck + f9 3
tuck + b9 3
tuck + f10 3
tuck + b10 3
tuck + f11 3
tuck + b11 3
tuck + f12 3
tuck + b12 3
tuck + f13 3
tuck + b13 3
tuck + f14 3
tuck + b14 3
tuck + f15 3
tuck + b15 3
tuck + f16 3
tuck + b16 3
tuck + f17 3
tuck + b17 3
tuck + f18 3
tuck + b18 3
tuck + f19 3
tuck + b19 3
tuck + f20 3
tuck + b20 3

;Return to aligned racking:
rack 0

;Do a row of plain knitting on the front and back:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + b1 3
knit + b2 3
knit + b3 3
knit + b4 3
knit + b5 3
knit + b6 3
knit + b7 3
knit + b8 3
knit + b9 3
knit + b10 3
knit + b11 3
knit + b12 3
knit + b13 3
knit + b14 3
knit + b15 3
knit + b16 3
knit + b17 3
knit + b18 3
knit + b19 3
knit + b20 3
;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:
xfer b1 f1
xfer b2 f2
xfer b3 f3
xfer b4 f4
xfer b5 f5
xfer b6 f6
xfer b7 f7
xfer b8 f8
xfer b9 f9
xfer b10 f10
xfer b11 f11
xfer b12 f12
xfer b13 f13
xfer b14 f14
xfer b15 f15
xfer b16 f16
xfer b17 f17
xfer b18 f18
xfer b19 f19
xfer b20 f20

;knit two plain rows through the stacked stitches to return carrier to the right edge:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3


;...now can knit on [min,max].
//title: Sheet All-Needle Cast-On (plain javascript)
// Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: Kniterate');
console.log(';;Carriers: 1 2 3 4 5 6');

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

//Bring in carrier:
console.log(`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:
console.log(`rack 0.5`);

for (let n = min; n <= max; n += 1) {
	console.log(`tuck + f${n} ${carrier}`);
	console.log(`tuck + b${n} ${carrier}`);
}

//Return to aligned racking:
console.log(`rack 0`);

//Do a row of plain knitting on the front and back:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`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 (let n = min; n <= max; n += 1) {
	console.log(`xfer b${n} f${n}`);
}

//knit two plain rows through the stacked stitches to return carrier to the right edge:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}


//...now can knit on [min,max].
#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].
#title: Sheet All-Needle Cast-On (python with knitout module)
# Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

import knitout
K = knitout.Writer('1 2 3 4 5 6');
K.addHeader('Machine', 'Kniterate');

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

#Bring in carrier:
K.ingripper(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:
K.rack(0.5)

for n in range(min, max+1, 1):
	K.tuck("+", 'f' + str(n), carrier)
	K.tuck("+", 'b' + str(n), carrier)

#Return to aligned racking:
K.rack(0)

#Do a row of plain knitting on the front and back:
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'b' + str(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):
	K.xfer('b' + str(n), 'f' + str(n))

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


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

K.write('sheet-all-needle-cast-on.kniterate.k')
//title: Sheet All-Needle Cast-On (javascript with knitout module)
// Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] });
K.addHeader('Machine', 'SWGN2');

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

//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

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

//Need to use quarter-pitch racking to tuck all needles in one pass:
K.rack(-0.75);

for (let n = max; n >= min; n -= 1) {
	K.tuck("-", 'f' + n, carrier);
	K.tuck("-", 'b' + n, carrier);
}

//Return to aligned racking:
K.rack(0);

//Set stitch table entry for knitting:
K.stitchNumber(105);

//Do a rows of plain knitting on the front and back:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
for (let n = max; n >= min; n -= 1) {
	K.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 (let n = max; n >= min; n -= 1) {
	K.xfer('b' + n, 'f' + n);
}

//knit a plain row through the stacked stitches and return carrier to the right edge:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);

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

K.write('sheet-all-needle-cast-on.swgn2.k');
;!knitout-2
;;Machine: SWGN2
;;Carriers: 1 2 3 4 5 6 7 8 9 10

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

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

;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

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

;Need to use quarter-pitch racking to tuck all needles in one pass:
rack -0.75

tuck - f20 3
tuck - b20 3
tuck - f19 3
tuck - b19 3
tuck - f18 3
tuck - b18 3
tuck - f17 3
tuck - b17 3
tuck - f16 3
tuck - b16 3
tuck - f15 3
tuck - b15 3
tuck - f14 3
tuck - b14 3
tuck - f13 3
tuck - b13 3
tuck - f12 3
tuck - b12 3
tuck - f11 3
tuck - b11 3
tuck - f10 3
tuck - b10 3
tuck - f9 3
tuck - b9 3
tuck - f8 3
tuck - b8 3
tuck - f7 3
tuck - b7 3
tuck - f6 3
tuck - b6 3
tuck - f5 3
tuck - b5 3
tuck - f4 3
tuck - b4 3
tuck - f3 3
tuck - b3 3
tuck - f2 3
tuck - b2 3
tuck - f1 3
tuck - b1 3

;Return to aligned racking:
rack 0

;Set stitch table entry for knitting:
x-stitch-number 105

;Do a rows of plain knitting on the front and back:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
knit - b20 3
knit - b19 3
knit - b18 3
knit - b17 3
knit - b16 3
knit - b15 3
knit - b14 3
knit - b13 3
knit - b12 3
knit - b11 3
knit - b10 3
knit - b9 3
knit - b8 3
knit - b7 3
knit - b6 3
knit - b5 3
knit - b4 3
knit - b3 3
knit - b2 3
knit - b1 3
;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:
xfer b20 f20
xfer b19 f19
xfer b18 f18
xfer b17 f17
xfer b16 f16
xfer b15 f15
xfer b14 f14
xfer b13 f13
xfer b12 f12
xfer b11 f11
xfer b10 f10
xfer b9 f9
xfer b8 f8
xfer b7 f7
xfer b6 f6
xfer b5 f5
xfer b4 f4
xfer b3 f3
xfer b2 f2
xfer b1 f1

;knit a plain row through the stacked stitches and return carrier to the right edge:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3

;...now can knit on [min,max].
//title: Sheet All-Needle Cast-On (plain javascript)
// Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: SWGN2');
console.log(';;Carriers: 1 2 3 4 5 6 7 8 9 10');

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

//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

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

//Need to use quarter-pitch racking to tuck all needles in one pass:
console.log(`rack -0.75`);

for (let n = max; n >= min; n -= 1) {
	console.log(`tuck - f${n} ${carrier}`);
	console.log(`tuck - b${n} ${carrier}`);
}

//Return to aligned racking:
console.log(`rack 0`);

//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);

//Do a rows of plain knitting on the front and back:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
for (let n = max; n >= min; n -= 1) {
	console.log(`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 (let n = max; n >= min; n -= 1) {
	console.log(`xfer b${n} f${n}`);
}

//knit a plain row through the stacked stitches and return carrier to the right edge:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);

//...now can knit on [min,max].
#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: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

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

#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

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

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

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

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

#Set stitch table entry for knitting:
print(f"x-stitch-number 105")

#Do a rows of plain knitting on the front and back:
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
for n in range(max, min-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(max, min-1, -1):
	print(f"xfer b{n} f{n}")

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

#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")

#...now can knit on [min,max].
#title: Sheet All-Needle Cast-On (python with knitout module)
# Casts on a sheet by knitting all needles and then stacking front and back stitches to produce a decorative welt.

import knitout
K = knitout.Writer('1 2 3 4 5 6 7 8 9 10');
K.addHeader('Machine', 'SWGN2');

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

#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

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

#Need to use quarter-pitch racking to tuck all needles in one pass:
K.rack(-0.75)

for n in range(max, min-1, -1):
	K.tuck("-", 'f' + str(n), carrier)
	K.tuck("-", 'b' + str(n), carrier)

#Return to aligned racking:
K.rack(0)

#Set stitch table entry for knitting:
K.stitchNumber(105)

#Do a rows of plain knitting on the front and back:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
for n in range(max, min-1, -1):
	K.knit("-", 'b' + str(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(max, min-1, -1):
	K.xfer('b' + str(n), 'f' + str(n))

#knit a plain row through the stacked stitches and return carrier to the right edge:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)

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

K.write('sheet-all-needle-cast-on.swgn2.k')
//title: Sheet I-Cord Cast-On (javascript with knitout module)
// Casts on a sheet by knitting a small tube, leaving one stitch on the bed each time; slow but fancy.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] });
K.addHeader('Machine', 'SWGN2');

//Parameters:
let min = 1; //needle number of left edge
let max = 20; //needle number of right edge
let carrier = "3"; //carrier name
let cordWidth = 4; //cord width

//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

//On SWGN2 machines, carriers start on the right,
//so will start by making a closed tube bind-off for the cord on the right.

//All-needle closed-tube cast-on, with carrier ending on the left:
K.rack(-0.75);
for (let n = max; n >= max - cordWidth; n -= 1) {
	K.tuck("-", 'f' + n, carrier);
	K.tuck("-", 'b' + n, carrier);
}
K.rack(0);

//Set stitch table entry for knitting:
K.stitchNumber(105);

//Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
//Start first course of the tube:
for (let n = max - cordWidth; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);
//Middle of tube:
for (let tubeMax = max; tubeMax >= min; tubeMax -= 1) {
	for (let n = tubeMax; n >= tubeMax - cordWidth; n -= 1) {
		K.knit("-", 'b' + n, carrier);
	}
	K.miss("-", 'b' + (tubeMax-cordWidth-1), carrier);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('f' + n, 'bs' + n);
	}
	K.rack(-1);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('bs' + n, 'f' + (n-1));
	}
	K.rack(0);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.knit("+", 'f' + (n-1), carrier);
	}
	K.tuck("+", 'f' + tubeMax, carrier);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('b' + n, 'fs' + n);
	}
	K.rack(1);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('fs' + n, 'b' + (n-1));
	}
	K.rack(0);
}
//Finish last course of tube (and get carrier to the left):
for (let n = min - 1; n >= min - cordWidth - 1; n -= 1) {
	K.knit("-", 'b' + n, carrier);
}

//Closed bind-off on the tube:
for (let n = min - cordWidth - 1; n <= min - 1; n += 1) {
	K.xfer('b' + n, 'f' + n);
	K.knit("+", 'f' + n, carrier);
	K.rack(-1);
	K.xfer('f' + n, 'b' + (n+1));
	K.knit("+", 'b' + (n+1), carrier);
	K.rack(0);
}
K.xfer('b' + min, 'f' + min);

//Knit regular course to get carrier to the right:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

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

K.write('sheet-i-cord-cast-on.swgn2.k');
;!knitout-2
;;Machine: SWGN2
;;Carriers: 1 2 3 4 5 6 7 8 9 10

;title: Sheet I-Cord Cast-On (raw knitout)
; Casts on a sheet by knitting a small tube, leaving one stitch on the bed each time; slow but fancy.

;Parameters:
; min = 1 -- needle number of left edge
; max = 20 -- needle number of right edge
; carrier = "3" -- carrier name
; cordWidth = 4 -- cord width

;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

;On SWGN2 machines, carriers start on the right,
;so will start by making a closed tube bind-off for the cord on the right.

;All-needle closed-tube cast-on, with carrier ending on the left:
rack -0.75
tuck - f20 3
tuck - b20 3
tuck - f19 3
tuck - b19 3
tuck - f18 3
tuck - b18 3
tuck - f17 3
tuck - b17 3
tuck - f16 3
tuck - b16 3
rack 0

;Set stitch table entry for knitting:
x-stitch-number 105

;Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
;Start first course of the tube:
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3
;Middle of tube:
knit - b20 3
knit - b19 3
knit - b18 3
knit - b17 3
knit - b16 3
miss - b15 3
xfer f16 bs16
xfer f17 bs17
xfer f18 bs18
xfer f19 bs19
xfer f20 bs20
rack -1
xfer bs16 f15
xfer bs17 f16
xfer bs18 f17
xfer bs19 f18
xfer bs20 f19
rack 0
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
tuck + f20 3
xfer b16 fs16
xfer b17 fs17
xfer b18 fs18
xfer b19 fs19
xfer b20 fs20
rack 1
xfer fs16 b15
xfer fs17 b16
xfer fs18 b17
xfer fs19 b18
xfer fs20 b19
rack 0
knit - b19 3
knit - b18 3
knit - b17 3
knit - b16 3
knit - b15 3
miss - b14 3
xfer f15 bs15
xfer f16 bs16
xfer f17 bs17
xfer f18 bs18
xfer f19 bs19
rack -1
xfer bs15 f14
xfer bs16 f15
xfer bs17 f16
xfer bs18 f17
xfer bs19 f18
rack 0
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
tuck + f19 3
xfer b15 fs15
xfer b16 fs16
xfer b17 fs17
xfer b18 fs18
xfer b19 fs19
rack 1
xfer fs15 b14
xfer fs16 b15
xfer fs17 b16
xfer fs18 b17
xfer fs19 b18
rack 0
knit - b18 3
knit - b17 3
knit - b16 3
knit - b15 3
knit - b14 3
miss - b13 3
xfer f14 bs14
xfer f15 bs15
xfer f16 bs16
xfer f17 bs17
xfer f18 bs18
rack -1
xfer bs14 f13
xfer bs15 f14
xfer bs16 f15
xfer bs17 f16
xfer bs18 f17
rack 0
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
tuck + f18 3
xfer b14 fs14
xfer b15 fs15
xfer b16 fs16
xfer b17 fs17
xfer b18 fs18
rack 1
xfer fs14 b13
xfer fs15 b14
xfer fs16 b15
xfer fs17 b16
xfer fs18 b17
rack 0
knit - b17 3
knit - b16 3
knit - b15 3
knit - b14 3
knit - b13 3
miss - b12 3
xfer f13 bs13
xfer f14 bs14
xfer f15 bs15
xfer f16 bs16
xfer f17 bs17
rack -1
xfer bs13 f12
xfer bs14 f13
xfer bs15 f14
xfer bs16 f15
xfer bs17 f16
rack 0
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
tuck + f17 3
xfer b13 fs13
xfer b14 fs14
xfer b15 fs15
xfer b16 fs16
xfer b17 fs17
rack 1
xfer fs13 b12
xfer fs14 b13
xfer fs15 b14
xfer fs16 b15
xfer fs17 b16
rack 0
knit - b16 3
knit - b15 3
knit - b14 3
knit - b13 3
knit - b12 3
miss - b11 3
xfer f12 bs12
xfer f13 bs13
xfer f14 bs14
xfer f15 bs15
xfer f16 bs16
rack -1
xfer bs12 f11
xfer bs13 f12
xfer bs14 f13
xfer bs15 f14
xfer bs16 f15
rack 0
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
tuck + f16 3
xfer b12 fs12
xfer b13 fs13
xfer b14 fs14
xfer b15 fs15
xfer b16 fs16
rack 1
xfer fs12 b11
xfer fs13 b12
xfer fs14 b13
xfer fs15 b14
xfer fs16 b15
rack 0
knit - b15 3
knit - b14 3
knit - b13 3
knit - b12 3
knit - b11 3
miss - b10 3
xfer f11 bs11
xfer f12 bs12
xfer f13 bs13
xfer f14 bs14
xfer f15 bs15
rack -1
xfer bs11 f10
xfer bs12 f11
xfer bs13 f12
xfer bs14 f13
xfer bs15 f14
rack 0
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
tuck + f15 3
xfer b11 fs11
xfer b12 fs12
xfer b13 fs13
xfer b14 fs14
xfer b15 fs15
rack 1
xfer fs11 b10
xfer fs12 b11
xfer fs13 b12
xfer fs14 b13
xfer fs15 b14
rack 0
knit - b14 3
knit - b13 3
knit - b12 3
knit - b11 3
knit - b10 3
miss - b9 3
xfer f10 bs10
xfer f11 bs11
xfer f12 bs12
xfer f13 bs13
xfer f14 bs14
rack -1
xfer bs10 f9
xfer bs11 f10
xfer bs12 f11
xfer bs13 f12
xfer bs14 f13
rack 0
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
tuck + f14 3
xfer b10 fs10
xfer b11 fs11
xfer b12 fs12
xfer b13 fs13
xfer b14 fs14
rack 1
xfer fs10 b9
xfer fs11 b10
xfer fs12 b11
xfer fs13 b12
xfer fs14 b13
rack 0
knit - b13 3
knit - b12 3
knit - b11 3
knit - b10 3
knit - b9 3
miss - b8 3
xfer f9 bs9
xfer f10 bs10
xfer f11 bs11
xfer f12 bs12
xfer f13 bs13
rack -1
xfer bs9 f8
xfer bs10 f9
xfer bs11 f10
xfer bs12 f11
xfer bs13 f12
rack 0
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
tuck + f13 3
xfer b9 fs9
xfer b10 fs10
xfer b11 fs11
xfer b12 fs12
xfer b13 fs13
rack 1
xfer fs9 b8
xfer fs10 b9
xfer fs11 b10
xfer fs12 b11
xfer fs13 b12
rack 0
knit - b12 3
knit - b11 3
knit - b10 3
knit - b9 3
knit - b8 3
miss - b7 3
xfer f8 bs8
xfer f9 bs9
xfer f10 bs10
xfer f11 bs11
xfer f12 bs12
rack -1
xfer bs8 f7
xfer bs9 f8
xfer bs10 f9
xfer bs11 f10
xfer bs12 f11
rack 0
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
tuck + f12 3
xfer b8 fs8
xfer b9 fs9
xfer b10 fs10
xfer b11 fs11
xfer b12 fs12
rack 1
xfer fs8 b7
xfer fs9 b8
xfer fs10 b9
xfer fs11 b10
xfer fs12 b11
rack 0
knit - b11 3
knit - b10 3
knit - b9 3
knit - b8 3
knit - b7 3
miss - b6 3
xfer f7 bs7
xfer f8 bs8
xfer f9 bs9
xfer f10 bs10
xfer f11 bs11
rack -1
xfer bs7 f6
xfer bs8 f7
xfer bs9 f8
xfer bs10 f9
xfer bs11 f10
rack 0
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
tuck + f11 3
xfer b7 fs7
xfer b8 fs8
xfer b9 fs9
xfer b10 fs10
xfer b11 fs11
rack 1
xfer fs7 b6
xfer fs8 b7
xfer fs9 b8
xfer fs10 b9
xfer fs11 b10
rack 0
knit - b10 3
knit - b9 3
knit - b8 3
knit - b7 3
knit - b6 3
miss - b5 3
xfer f6 bs6
xfer f7 bs7
xfer f8 bs8
xfer f9 bs9
xfer f10 bs10
rack -1
xfer bs6 f5
xfer bs7 f6
xfer bs8 f7
xfer bs9 f8
xfer bs10 f9
rack 0
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
tuck + f10 3
xfer b6 fs6
xfer b7 fs7
xfer b8 fs8
xfer b9 fs9
xfer b10 fs10
rack 1
xfer fs6 b5
xfer fs7 b6
xfer fs8 b7
xfer fs9 b8
xfer fs10 b9
rack 0
knit - b9 3
knit - b8 3
knit - b7 3
knit - b6 3
knit - b5 3
miss - b4 3
xfer f5 bs5
xfer f6 bs6
xfer f7 bs7
xfer f8 bs8
xfer f9 bs9
rack -1
xfer bs5 f4
xfer bs6 f5
xfer bs7 f6
xfer bs8 f7
xfer bs9 f8
rack 0
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
tuck + f9 3
xfer b5 fs5
xfer b6 fs6
xfer b7 fs7
xfer b8 fs8
xfer b9 fs9
rack 1
xfer fs5 b4
xfer fs6 b5
xfer fs7 b6
xfer fs8 b7
xfer fs9 b8
rack 0
knit - b8 3
knit - b7 3
knit - b6 3
knit - b5 3
knit - b4 3
miss - b3 3
xfer f4 bs4
xfer f5 bs5
xfer f6 bs6
xfer f7 bs7
xfer f8 bs8
rack -1
xfer bs4 f3
xfer bs5 f4
xfer bs6 f5
xfer bs7 f6
xfer bs8 f7
rack 0
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
tuck + f8 3
xfer b4 fs4
xfer b5 fs5
xfer b6 fs6
xfer b7 fs7
xfer b8 fs8
rack 1
xfer fs4 b3
xfer fs5 b4
xfer fs6 b5
xfer fs7 b6
xfer fs8 b7
rack 0
knit - b7 3
knit - b6 3
knit - b5 3
knit - b4 3
knit - b3 3
miss - b2 3
xfer f3 bs3
xfer f4 bs4
xfer f5 bs5
xfer f6 bs6
xfer f7 bs7
rack -1
xfer bs3 f2
xfer bs4 f3
xfer bs5 f4
xfer bs6 f5
xfer bs7 f6
rack 0
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
tuck + f7 3
xfer b3 fs3
xfer b4 fs4
xfer b5 fs5
xfer b6 fs6
xfer b7 fs7
rack 1
xfer fs3 b2
xfer fs4 b3
xfer fs5 b4
xfer fs6 b5
xfer fs7 b6
rack 0
knit - b6 3
knit - b5 3
knit - b4 3
knit - b3 3
knit - b2 3
miss - b1 3
xfer f2 bs2
xfer f3 bs3
xfer f4 bs4
xfer f5 bs5
xfer f6 bs6
rack -1
xfer bs2 f1
xfer bs3 f2
xfer bs4 f3
xfer bs5 f4
xfer bs6 f5
rack 0
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
tuck + f6 3
xfer b2 fs2
xfer b3 fs3
xfer b4 fs4
xfer b5 fs5
xfer b6 fs6
rack 1
xfer fs2 b1
xfer fs3 b2
xfer fs4 b3
xfer fs5 b4
xfer fs6 b5
rack 0
knit - b5 3
knit - b4 3
knit - b3 3
knit - b2 3
knit - b1 3
miss - b0 3
xfer f1 bs1
xfer f2 bs2
xfer f3 bs3
xfer f4 bs4
xfer f5 bs5
rack -1
xfer bs1 f0
xfer bs2 f1
xfer bs3 f2
xfer bs4 f3
xfer bs5 f4
rack 0
knit + f0 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
tuck + f5 3
xfer b1 fs1
xfer b2 fs2
xfer b3 fs3
xfer b4 fs4
xfer b5 fs5
rack 1
xfer fs1 b0
xfer fs2 b1
xfer fs3 b2
xfer fs4 b3
xfer fs5 b4
rack 0
knit - b4 3
knit - b3 3
knit - b2 3
knit - b1 3
knit - b0 3
miss - b-1 3
xfer f0 bs0
xfer f1 bs1
xfer f2 bs2
xfer f3 bs3
xfer f4 bs4
rack -1
xfer bs0 f-1
xfer bs1 f0
xfer bs2 f1
xfer bs3 f2
xfer bs4 f3
rack 0
knit + f-1 3
knit + f0 3
knit + f1 3
knit + f2 3
knit + f3 3
tuck + f4 3
xfer b0 fs0
xfer b1 fs1
xfer b2 fs2
xfer b3 fs3
xfer b4 fs4
rack 1
xfer fs0 b-1
xfer fs1 b0
xfer fs2 b1
xfer fs3 b2
xfer fs4 b3
rack 0
knit - b3 3
knit - b2 3
knit - b1 3
knit - b0 3
knit - b-1 3
miss - b-2 3
xfer f-1 bs-1
xfer f0 bs0
xfer f1 bs1
xfer f2 bs2
xfer f3 bs3
rack -1
xfer bs-1 f-2
xfer bs0 f-1
xfer bs1 f0
xfer bs2 f1
xfer bs3 f2
rack 0
knit + f-2 3
knit + f-1 3
knit + f0 3
knit + f1 3
knit + f2 3
tuck + f3 3
xfer b-1 fs-1
xfer b0 fs0
xfer b1 fs1
xfer b2 fs2
xfer b3 fs3
rack 1
xfer fs-1 b-2
xfer fs0 b-1
xfer fs1 b0
xfer fs2 b1
xfer fs3 b2
rack 0
knit - b2 3
knit - b1 3
knit - b0 3
knit - b-1 3
knit - b-2 3
miss - b-3 3
xfer f-2 bs-2
xfer f-1 bs-1
xfer f0 bs0
xfer f1 bs1
xfer f2 bs2
rack -1
xfer bs-2 f-3
xfer bs-1 f-2
xfer bs0 f-1
xfer bs1 f0
xfer bs2 f1
rack 0
knit + f-3 3
knit + f-2 3
knit + f-1 3
knit + f0 3
knit + f1 3
tuck + f2 3
xfer b-2 fs-2
xfer b-1 fs-1
xfer b0 fs0
xfer b1 fs1
xfer b2 fs2
rack 1
xfer fs-2 b-3
xfer fs-1 b-2
xfer fs0 b-1
xfer fs1 b0
xfer fs2 b1
rack 0
knit - b1 3
knit - b0 3
knit - b-1 3
knit - b-2 3
knit - b-3 3
miss - b-4 3
xfer f-3 bs-3
xfer f-2 bs-2
xfer f-1 bs-1
xfer f0 bs0
xfer f1 bs1
rack -1
xfer bs-3 f-4
xfer bs-2 f-3
xfer bs-1 f-2
xfer bs0 f-1
xfer bs1 f0
rack 0
knit + f-4 3
knit + f-3 3
knit + f-2 3
knit + f-1 3
knit + f0 3
tuck + f1 3
xfer b-3 fs-3
xfer b-2 fs-2
xfer b-1 fs-1
xfer b0 fs0
xfer b1 fs1
rack 1
xfer fs-3 b-4
xfer fs-2 b-3
xfer fs-1 b-2
xfer fs0 b-1
xfer fs1 b0
rack 0
;Finish last course of tube (and get carrier to the left):
knit - b0 3
knit - b-1 3
knit - b-2 3
knit - b-3 3
knit - b-4 3

;Closed bind-off on the tube:
xfer b-4 f-4
knit + f-4 3
rack -1
xfer f-4 b-3
knit + b-3 3
rack 0
xfer b-3 f-3
knit + f-3 3
rack -1
xfer f-3 b-2
knit + b-2 3
rack 0
xfer b-2 f-2
knit + f-2 3
rack -1
xfer f-2 b-1
knit + b-1 3
rack 0
xfer b-1 f-1
knit + f-1 3
rack -1
xfer f-1 b0
knit + b0 3
rack 0
xfer b0 f0
knit + f0 3
rack -1
xfer f0 b1
knit + b1 3
rack 0
xfer b1 f1

;Knit regular course to get carrier to the right:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

;...now can knit on [min,max].
//title: Sheet I-Cord Cast-On (plain javascript)
// Casts on a sheet by knitting a small tube, leaving one stitch on the bed each time; slow but fancy.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: SWGN2');
console.log(';;Carriers: 1 2 3 4 5 6 7 8 9 10');

//Parameters:
let min = 1; //needle number of left edge
let max = 20; //needle number of right edge
let carrier = "3"; //carrier name
let cordWidth = 4; //cord width

//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

//On SWGN2 machines, carriers start on the right,
//so will start by making a closed tube bind-off for the cord on the right.

//All-needle closed-tube cast-on, with carrier ending on the left:
console.log(`rack -0.75`);
for (let n = max; n >= max - cordWidth; n -= 1) {
	console.log(`tuck - f${n} ${carrier}`);
	console.log(`tuck - b${n} ${carrier}`);
}
console.log(`rack 0`);

//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);

//Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
//Start first course of the tube:
for (let n = max - cordWidth; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);
//Middle of tube:
for (let tubeMax = max; tubeMax >= min; tubeMax -= 1) {
	for (let n = tubeMax; n >= tubeMax - cordWidth; n -= 1) {
		console.log(`knit - b${n} ${carrier}`);
	}
	console.log(`miss - b${(tubeMax-cordWidth-1)} ${carrier}`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer f${n} bs${n}`);
	}
	console.log(`rack -1`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer bs${n} f${(n-1)}`);
	}
	console.log(`rack 0`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`knit + f${(n-1)} ${carrier}`);
	}
	console.log(`tuck + f${tubeMax} ${carrier}`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer b${n} fs${n}`);
	}
	console.log(`rack 1`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer fs${n} b${(n-1)}`);
	}
	console.log(`rack 0`);
}
//Finish last course of tube (and get carrier to the left):
for (let n = min - 1; n >= min - cordWidth - 1; n -= 1) {
	console.log(`knit - b${n} ${carrier}`);
}

//Closed bind-off on the tube:
for (let n = min - cordWidth - 1; n <= min - 1; n += 1) {
	console.log(`xfer b${n} f${n}`);
	console.log(`knit + f${n} ${carrier}`);
	console.log(`rack -1`);
	console.log(`xfer f${n} b${(n+1)}`);
	console.log(`knit + b${(n+1)} ${carrier}`);
	console.log(`rack 0`);
}
console.log(`xfer b${min} f${min}`);

//Knit regular course to get carrier to the right:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

//...now can knit on [min,max].
#title: Sheet I-Cord Cast-On (plain python)
# Casts on a sheet by knitting a small tube, leaving one stitch on the bed each time; slow but fancy.

#Write header:
print(';!knitout-2')
print(';;Machine: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

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

#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

#On SWGN2 machines, carriers start on the right,
#so will start by making a closed tube bind-off for the cord on the right.

#All-needle closed-tube cast-on, with carrier ending on the left:
print(f"rack -0.75")
for n in range(max, max - cordWidth-1, -1):
	print(f"tuck - f{n} {carrier}")
	print(f"tuck - b{n} {carrier}")
print(f"rack 0")

#Set stitch table entry for knitting:
print(f"x-stitch-number 105")

#Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
#Start first course of the tube:
for n in range(max - cordWidth, max+1, 1):
	print(f"knit + f{n} {carrier}")
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")
#Middle of tube:
for tubeMax in range(max, min-1, -1):
	for n in range(tubeMax, tubeMax - cordWidth-1, -1):
		print(f"knit - b{n} {carrier}")
	print(f"miss - b{tubeMax-cordWidth-1} {carrier}")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer f{n} bs{n}")
	print(f"rack -1")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer bs{n} f{n-1}")
	print(f"rack 0")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"knit + f{n-1} {carrier}")
	print(f"tuck + f{tubeMax} {carrier}")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer b{n} fs{n}")
	print(f"rack 1")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer fs{n} b{n-1}")
	print(f"rack 0")
#Finish last course of tube (and get carrier to the left):
for n in range(min - 1, min - cordWidth - 1-1, -1):
	print(f"knit - b{n} {carrier}")

#Closed bind-off on the tube:
for n in range(min - cordWidth - 1, min - 1+1, 1):
	print(f"xfer b{n} f{n}")
	print(f"knit + f{n} {carrier}")
	print(f"rack -1")
	print(f"xfer f{n} b{n+1}")
	print(f"knit + b{n+1} {carrier}")
	print(f"rack 0")
print(f"xfer b{min} f{min}")

#Knit regular course to get carrier to the right:
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")

#...now can knit on [min,max].
#title: Sheet I-Cord Cast-On (python with knitout module)
# Casts on a sheet by knitting a small tube, leaving one stitch on the bed each time; slow but fancy.

import knitout
K = knitout.Writer('1 2 3 4 5 6 7 8 9 10');
K.addHeader('Machine', 'SWGN2');

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

#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

#On SWGN2 machines, carriers start on the right,
#so will start by making a closed tube bind-off for the cord on the right.

#All-needle closed-tube cast-on, with carrier ending on the left:
K.rack(-0.75)
for n in range(max, max - cordWidth-1, -1):
	K.tuck("-", 'f' + str(n), carrier)
	K.tuck("-", 'b' + str(n), carrier)
K.rack(0)

#Set stitch table entry for knitting:
K.stitchNumber(105)

#Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
#Start first course of the tube:
for n in range(max - cordWidth, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)
#Middle of tube:
for tubeMax in range(max, min-1, -1):
	for n in range(tubeMax, tubeMax - cordWidth-1, -1):
		K.knit("-", 'b' + str(n), carrier)
	K.miss("-", 'b' + str(tubeMax-cordWidth-1), carrier)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('f' + str(n), 'bs' + str(n))
	K.rack(-1)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('bs' + str(n), 'f' + str(n-1))
	K.rack(0)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.knit("+", 'f' + str(n-1), carrier)
	K.tuck("+", 'f' + str(tubeMax), carrier)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('b' + str(n), 'fs' + str(n))
	K.rack(1)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('fs' + str(n), 'b' + str(n-1))
	K.rack(0)
#Finish last course of tube (and get carrier to the left):
for n in range(min - 1, min - cordWidth - 1-1, -1):
	K.knit("-", 'b' + str(n), carrier)

#Closed bind-off on the tube:
for n in range(min - cordWidth - 1, min - 1+1, 1):
	K.xfer('b' + str(n), 'f' + str(n))
	K.knit("+", 'f' + str(n), carrier)
	K.rack(-1)
	K.xfer('f' + str(n), 'b' + str(n+1))
	K.knit("+", 'b' + str(n+1), carrier)
	K.rack(0)
K.xfer('b' + str(min), 'f' + str(min))

#Knit regular course to get carrier to the right:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

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

K.write('sheet-i-cord-cast-on.swgn2.k')
//title: Sheet Twisted-Tuck Cast-On (javascript with knitout module)
// Casts on a sheet by knitting twisted tucks on all needles; slow!

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6'] });
K.addHeader('Machine', 'Kniterate');

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

//Bring in carrier:
K.in(carrier);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	K.tuck("-", 'f' + n, carrier);
}

//knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

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

K.write('sheet-twisted-tuck-cast-on.kniterate.k');
;!knitout-2
;;Machine: Kniterate
;;Carriers: 1 2 3 4 5 6

;title: Sheet Twisted-Tuck Cast-On (raw knitout)
; Casts on a sheet by knitting twisted tucks on all needles; slow!

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

;Bring in carrier:
in 3

;Use a twisted tuck to cast on every stitch.
;Note: this requires a new pass for every stitch, so is pretty slow!
;There are both faster and fancier cast-ons.
;On Kniterate machines, carriers start on the left, so will start with leftmost needle.
tuck - f1 3
tuck - f2 3
tuck - f3 3
tuck - f4 3
tuck - f5 3
tuck - f6 3
tuck - f7 3
tuck - f8 3
tuck - f9 3
tuck - f10 3
tuck - f11 3
tuck - f12 3
tuck - f13 3
tuck - f14 3
tuck - f15 3
tuck - f16 3
tuck - f17 3
tuck - f18 3
tuck - f19 3
tuck - f20 3

;knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

;...now can knit on [min,max].
//title: Sheet Twisted-Tuck Cast-On (plain javascript)
// Casts on a sheet by knitting twisted tucks on all needles; slow!

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: Kniterate');
console.log(';;Carriers: 1 2 3 4 5 6');

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

//Bring in carrier:
console.log(`in ${carrier}`);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	console.log(`tuck - f${n} ${carrier}`);
}

//knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

//...now can knit on [min,max].
#title: Sheet Twisted-Tuck Cast-On (plain python)
# Casts on a sheet by knitting twisted tucks on all needles; slow!

#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}")

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	print(f"tuck - f{n} {carrier}")

#knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
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].
#title: Sheet Twisted-Tuck Cast-On (python with knitout module)
# Casts on a sheet by knitting twisted tucks on all needles; slow!

import knitout
K = knitout.Writer('1 2 3 4 5 6');
K.addHeader('Machine', 'Kniterate');

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

#Bring in carrier:
K.ingripper(carrier)

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	K.tuck("-", 'f' + str(n), carrier)

#knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

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

K.write('sheet-twisted-tuck-cast-on.kniterate.k')
//title: Sheet Twisted-Tuck Cast-On (javascript with knitout module)
// Casts on a sheet by knitting twisted tucks on all needles; slow!

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] });
K.addHeader('Machine', 'SWGN2');

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

//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
//Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
K.miss("-", 'f' + max, carrier);
for (let n = max; n >= min; n -= 1) {
	K.tuck("+", 'f' + n, carrier);
}
//Set stitch table entry for knitting:
K.stitchNumber(105);
//knit a plain row to bring the carrier back to the right:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);

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

K.write('sheet-twisted-tuck-cast-on.swgn2.k');
;!knitout-2
;;Machine: SWGN2
;;Carriers: 1 2 3 4 5 6 7 8 9 10

;title: Sheet Twisted-Tuck Cast-On (raw knitout)
; Casts on a sheet by knitting twisted tucks on all needles; slow!

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

;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

;Use a twisted tuck to cast on every stitch.
;Note: this requires a new pass for every stitch, so is pretty slow!
;There are both faster and fancier cast-ons.
;On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
;Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
miss - f20 3
tuck + f20 3
tuck + f19 3
tuck + f18 3
tuck + f17 3
tuck + f16 3
tuck + f15 3
tuck + f14 3
tuck + f13 3
tuck + f12 3
tuck + f11 3
tuck + f10 3
tuck + f9 3
tuck + f8 3
tuck + f7 3
tuck + f6 3
tuck + f5 3
tuck + f4 3
tuck + f3 3
tuck + f2 3
tuck + f1 3
;Set stitch table entry for knitting:
x-stitch-number 105
;knit a plain row to bring the carrier back to the right:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3

;...now can knit on [min,max].
//title: Sheet Twisted-Tuck Cast-On (plain javascript)
// Casts on a sheet by knitting twisted tucks on all needles; slow!

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: SWGN2');
console.log(';;Carriers: 1 2 3 4 5 6 7 8 9 10');

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

//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
//Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
console.log(`miss - f${max} ${carrier}`);
for (let n = max; n >= min; n -= 1) {
	console.log(`tuck + f${n} ${carrier}`);
}
//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);
//knit a plain row to bring the carrier back to the right:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);

//...now can knit on [min,max].
#title: Sheet Twisted-Tuck Cast-On (plain python)
# Casts on a sheet by knitting twisted tucks on all needles; slow!

#Write header:
print(';!knitout-2')
print(';;Machine: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

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

#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
#Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
print(f"miss - f{max} {carrier}")
for n in range(max, min-1, -1):
	print(f"tuck + f{n} {carrier}")
#Set stitch table entry for knitting:
print(f"x-stitch-number 105")
#knit a plain row to bring the carrier back to the right:
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")

#...now can knit on [min,max].
#title: Sheet Twisted-Tuck Cast-On (python with knitout module)
# Casts on a sheet by knitting twisted tucks on all needles; slow!

import knitout
K = knitout.Writer('1 2 3 4 5 6 7 8 9 10');
K.addHeader('Machine', 'SWGN2');

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

#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
#Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
K.miss("-", 'f' + str(max), carrier)
for n in range(max, min-1, -1):
	K.tuck("+", 'f' + str(n), carrier)
#Set stitch table entry for knitting:
K.stitchNumber(105)
#knit a plain row to bring the carrier back to the right:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)

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

K.write('sheet-twisted-tuck-cast-on.swgn2.k')
//title: Cast-On Sampler (javascript with knitout module)
// Creates several sheets, all with different cast-ons.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6'] });
K.addHeader('Machine', 'Kniterate');

//Parameters:
let carrier = "3"; //carrier name
let min = 1; //needle number of left edge
let max = 20; //needle number of right edge
let rows = 20; //rows of knitting in each sample
let cordWidth = 4; //cord width (for I-cord cast-on)

// === Alternating Tucks === 
//Bring in carrier:
K.in(carrier);

//On Kniterate machines, carriers start on the left,
//so will start tucking onto needles left-to-right,
//and will be sure to tuck the leftmost needle in the first pass:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	if ((n - min) % 2 === 0) {
		K.tuck("+", 'f' + n, carrier);
	}
}
//now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for (let n = max; n >= min; n -= 1) {
	if ((n - min) % 2 !== 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}

//knit three plain rows to allow cast-on stitches to relax:
// three isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Send carrier back to its parking location:
K.out(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}

// === All-Needle Welt === 
//Bring in carrier:
K.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:
K.rack(0.5);

for (let n = min; n <= max; n += 1) {
	K.tuck("+", 'f' + n, carrier);
	K.tuck("+", 'b' + n, carrier);
}

//Return to aligned racking:
K.rack(0);

//Do a row of plain knitting on the front and back:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.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 (let n = min; n <= max; n += 1) {
	K.xfer('b' + n, 'f' + n);
}

//knit two plain rows through the stacked stitches to return carrier to the right edge:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Send carrier back to its parking location:
K.out(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}

// === Twisted Tucks === 
//Bring in carrier:
K.in(carrier);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	K.tuck("-", 'f' + n, carrier);
}

//knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Send carrier back to its parking location:
K.out(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}

// === I-Cord === 
//; not supported at full guage on kniterate


K.write('cast-on-sampler.kniterate.k');
;!knitout-2
;;Machine: Kniterate
;;Carriers: 1 2 3 4 5 6

;title: Cast-On Sampler (raw knitout)
; Creates several sheets, all with different cast-ons.

;Parameters:
; carrier = "3" -- carrier name
; min = 1 -- needle number of left edge
; max = 20 -- needle number of right edge
; rows = 20 -- rows of knitting in each sample
; cordWidth = 4 -- cord width (for I-cord cast-on)

; === Alternating Tucks === 
;Bring in carrier:
in 3

;On Kniterate machines, carriers start on the left,
;so will start tucking onto needles left-to-right,
;and will be sure to tuck the leftmost needle in the first pass:
tuck + f1 3
tuck + f3 3
tuck + f5 3
tuck + f7 3
tuck + f9 3
tuck + f11 3
tuck + f13 3
tuck + f15 3
tuck + f17 3
tuck + f19 3
;now, moving right-to-left, tuck the needles that were not tucked on the first pass:
tuck - f20 3
tuck - f18 3
tuck - f16 3
tuck - f14 3
tuck - f12 3
tuck - f10 3
tuck - f8 3
tuck - f6 3
tuck - f4 3
tuck - f2 3

;knit three plain rows to allow cast-on stitches to relax:
; three isn't set in stone here -- it's just convenient
; for this example code to have the carrier end up on the right.
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Send carrier back to its parking location:
out 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

; === All-Needle Welt === 
;Bring in carrier:
in 3

;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:
rack 0.5

tuck + f1 3
tuck + b1 3
tuck + f2 3
tuck + b2 3
tuck + f3 3
tuck + b3 3
tuck + f4 3
tuck + b4 3
tuck + f5 3
tuck + b5 3
tuck + f6 3
tuck + b6 3
tuck + f7 3
tuck + b7 3
tuck + f8 3
tuck + b8 3
tuck + f9 3
tuck + b9 3
tuck + f10 3
tuck + b10 3
tuck + f11 3
tuck + b11 3
tuck + f12 3
tuck + b12 3
tuck + f13 3
tuck + b13 3
tuck + f14 3
tuck + b14 3
tuck + f15 3
tuck + b15 3
tuck + f16 3
tuck + b16 3
tuck + f17 3
tuck + b17 3
tuck + f18 3
tuck + b18 3
tuck + f19 3
tuck + b19 3
tuck + f20 3
tuck + b20 3

;Return to aligned racking:
rack 0

;Do a row of plain knitting on the front and back:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + b1 3
knit + b2 3
knit + b3 3
knit + b4 3
knit + b5 3
knit + b6 3
knit + b7 3
knit + b8 3
knit + b9 3
knit + b10 3
knit + b11 3
knit + b12 3
knit + b13 3
knit + b14 3
knit + b15 3
knit + b16 3
knit + b17 3
knit + b18 3
knit + b19 3
knit + b20 3
;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:
xfer b1 f1
xfer b2 f2
xfer b3 f3
xfer b4 f4
xfer b5 f5
xfer b6 f6
xfer b7 f7
xfer b8 f8
xfer b9 f9
xfer b10 f10
xfer b11 f11
xfer b12 f12
xfer b13 f13
xfer b14 f14
xfer b15 f15
xfer b16 f16
xfer b17 f17
xfer b18 f18
xfer b19 f19
xfer b20 f20

;knit two plain rows through the stacked stitches to return carrier to the right edge:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Send carrier back to its parking location:
out 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

; === Twisted Tucks === 
;Bring in carrier:
in 3

;Use a twisted tuck to cast on every stitch.
;Note: this requires a new pass for every stitch, so is pretty slow!
;There are both faster and fancier cast-ons.
;On Kniterate machines, carriers start on the left, so will start with leftmost needle.
tuck - f1 3
tuck - f2 3
tuck - f3 3
tuck - f4 3
tuck - f5 3
tuck - f6 3
tuck - f7 3
tuck - f8 3
tuck - f9 3
tuck - f10 3
tuck - f11 3
tuck - f12 3
tuck - f13 3
tuck - f14 3
tuck - f15 3
tuck - f16 3
tuck - f17 3
tuck - f18 3
tuck - f19 3
tuck - f20 3

;knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Send carrier back to its parking location:
out 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

; === I-Cord === 
;; not supported at full guage on kniterate

//title: Cast-On Sampler (plain javascript)
// Creates several sheets, all with different cast-ons.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: Kniterate');
console.log(';;Carriers: 1 2 3 4 5 6');

//Parameters:
let carrier = "3"; //carrier name
let min = 1; //needle number of left edge
let max = 20; //needle number of right edge
let rows = 20; //rows of knitting in each sample
let cordWidth = 4; //cord width (for I-cord cast-on)

// === Alternating Tucks === 
//Bring in carrier:
console.log(`in ${carrier}`);

//On Kniterate machines, carriers start on the left,
//so will start tucking onto needles left-to-right,
//and will be sure to tuck the leftmost needle in the first pass:
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	if ((n - min) % 2 === 0) {
		console.log(`tuck + f${n} ${carrier}`);
	}
}
//now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for (let n = max; n >= min; n -= 1) {
	if ((n - min) % 2 !== 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}

//knit three plain rows to allow cast-on stitches to relax:
// three isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Send carrier back to its parking location:
console.log(`out ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

// === All-Needle Welt === 
//Bring in carrier:
console.log(`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:
console.log(`rack 0.5`);

for (let n = min; n <= max; n += 1) {
	console.log(`tuck + f${n} ${carrier}`);
	console.log(`tuck + b${n} ${carrier}`);
}

//Return to aligned racking:
console.log(`rack 0`);

//Do a row of plain knitting on the front and back:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`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 (let n = min; n <= max; n += 1) {
	console.log(`xfer b${n} f${n}`);
}

//knit two plain rows through the stacked stitches to return carrier to the right edge:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Send carrier back to its parking location:
console.log(`out ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

// === Twisted Tucks === 
//Bring in carrier:
console.log(`in ${carrier}`);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for (let n = min; n <= max; n += 1) {
	//tuck alternating needles, making sure to do the left edge:
	console.log(`tuck - f${n} ${carrier}`);
}

//knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Send carrier back to its parking location:
console.log(`out ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

// === I-Cord === 
//; not supported at full guage on kniterate

#title: Cast-On Sampler (plain python)
# Creates several sheets, all with different cast-ons.

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

#Parameters:
carrier = "3" #carrier name
min = 1 #needle number of left edge
max = 20 #needle number of right edge
rows = 20 #rows of knitting in each sample
cordWidth = 4 #cord width (for I-cord cast-on)

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

#On Kniterate machines, carriers start on the left,
#so will start tucking onto needles left-to-right,
#and will be sure to tuck the leftmost needle in the first pass:
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	if (n - min) % 2 == 0:
		print(f"tuck + f{n} {carrier}")
#now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for n in range(max, min-1, -1):
	if (n - min) % 2 != 0:
		print(f"tuck - f{n} {carrier}")

#knit three plain rows to allow cast-on stitches to relax:
# three isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
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}")
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Send carrier back to its parking location:
print(f"out {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

# === All-Needle Welt === 
#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}")

# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Send carrier back to its parking location:
print(f"out {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

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

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	print(f"tuck - f{n} {carrier}")

#knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
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}")
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Send carrier back to its parking location:
print(f"out {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

# === I-Cord === 
#; not supported at full guage on kniterate

#title: Cast-On Sampler (python with knitout module)
# Creates several sheets, all with different cast-ons.

import knitout
K = knitout.Writer('1 2 3 4 5 6');
K.addHeader('Machine', 'Kniterate');

#Parameters:
carrier = "3" #carrier name
min = 1 #needle number of left edge
max = 20 #needle number of right edge
rows = 20 #rows of knitting in each sample
cordWidth = 4 #cord width (for I-cord cast-on)

# === Alternating Tucks === 
#Bring in carrier:
K.ingripper(carrier)

#On Kniterate machines, carriers start on the left,
#so will start tucking onto needles left-to-right,
#and will be sure to tuck the leftmost needle in the first pass:
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	if (n - min) % 2 == 0:
		K.tuck("+", 'f' + str(n), carrier)
#now, moving right-to-left, tuck the needles that were not tucked on the first pass:
for n in range(max, min-1, -1):
	if (n - min) % 2 != 0:
		K.tuck("-", 'f' + str(n), carrier)

#knit three plain rows to allow cast-on stitches to relax:
# three isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Send carrier back to its parking location:
K.outgripper(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))

# === All-Needle Welt === 
#Bring in carrier:
K.ingripper(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:
K.rack(0.5)

for n in range(min, max+1, 1):
	K.tuck("+", 'f' + str(n), carrier)
	K.tuck("+", 'b' + str(n), carrier)

#Return to aligned racking:
K.rack(0)

#Do a row of plain knitting on the front and back:
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'b' + str(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):
	K.xfer('b' + str(n), 'f' + str(n))

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

# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Send carrier back to its parking location:
K.outgripper(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))

# === Twisted Tucks === 
#Bring in carrier:
K.ingripper(carrier)

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On Kniterate machines, carriers start on the left, so will start with leftmost needle.
for n in range(min, max+1, 1):
	#tuck alternating needles, making sure to do the left edge:
	K.tuck("-", 'f' + str(n), carrier)

#knit two plain rows to allow cast-on stitches to relax and bring carrier to the right:
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Send carrier back to its parking location:
K.outgripper(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))

# === I-Cord === 
#; not supported at full guage on kniterate


K.write('cast-on-sampler.kniterate.k')
//title: Cast-On Sampler (javascript with knitout module)
// Creates several sheets, all with different cast-ons.

//include knitout module:
const knitout = require('knitout'); //include knitout module
const K = new knitout.Writer({ carriers:['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] });
K.addHeader('Machine', 'SWGN2');

//Parameters:
let carrier = "3"; //carrier name
let min = 1; //needle number of left edge
let max = 20; //needle number of right edge
let rows = 20; //rows of knitting in each sample
let cordWidth = 4; //cord width (for I-cord cast-on)

// === Alternating Tucks === 
//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

//On SWGN2 machines, carriers start on the right,
//so will start tucking onto needles right-to-left,
//and will be sure to tuck the rightmost needle in the first pass:
for (let n = max; n >= min; n -= 1) {
	//tuck alternating needles, making sure to do the right edge:
	if ((max - n) % 2 === 0) {
		K.tuck("-", 'f' + n, carrier);
	}
}
//now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for (let n = min; n <= max; n += 1) {
	if ((max - n) % 2 !== 0) {
		K.tuck("+", 'f' + n, carrier);
	}
}
//Set stitch table entry for knitting:
K.stitchNumber(105);
//knit two plain rows to allow cast-on stitches to relax:
// two isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = max; n >= min; n -= 1) {
	K.knit("-", 'f' + n, carrier);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
K.outhook(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}

// === All-Needle Welt === 
//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

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

//Need to use quarter-pitch racking to tuck all needles in one pass:
K.rack(-0.75);

for (let n = max; n >= min; n -= 1) {
	K.tuck("-", 'f' + n, carrier);
	K.tuck("-", 'b' + n, carrier);
}

//Return to aligned racking:
K.rack(0);

//Set stitch table entry for knitting:
K.stitchNumber(105);

//Do a rows of plain knitting on the front and back:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
for (let n = max; n >= min; n -= 1) {
	K.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 (let n = max; n >= min; n -= 1) {
	K.xfer('b' + n, 'f' + n);
}

//knit a plain row through the stacked stitches and return carrier to the right edge:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}

//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
K.outhook(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}

// === Twisted Tucks === 
//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
//Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
K.miss("-", 'f' + max, carrier);
for (let n = max; n >= min; n -= 1) {
	K.tuck("+", 'f' + n, carrier);
}
//Set stitch table entry for knitting:
K.stitchNumber(105);
//knit a plain row to bring the carrier back to the right:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
K.outhook(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}

// === I-Cord === 
//Bring in carrier:
K.inhook(carrier);
//Set stitch table entry for cast-on:
K.stitchNumber(101);

//On SWGN2 machines, carriers start on the right,
//so will start by making a closed tube bind-off for the cord on the right.

//All-needle closed-tube cast-on, with carrier ending on the left:
K.rack(-0.75);
for (let n = max; n >= max - cordWidth; n -= 1) {
	K.tuck("-", 'f' + n, carrier);
	K.tuck("-", 'b' + n, carrier);
}
K.rack(0);

//Set stitch table entry for knitting:
K.stitchNumber(105);

//Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
//Start first course of the tube:
for (let n = max - cordWidth; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier);
//Middle of tube:
for (let tubeMax = max; tubeMax >= min; tubeMax -= 1) {
	for (let n = tubeMax; n >= tubeMax - cordWidth; n -= 1) {
		K.knit("-", 'b' + n, carrier);
	}
	K.miss("-", 'b' + (tubeMax-cordWidth-1), carrier);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('f' + n, 'bs' + n);
	}
	K.rack(-1);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('bs' + n, 'f' + (n-1));
	}
	K.rack(0);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.knit("+", 'f' + (n-1), carrier);
	}
	K.tuck("+", 'f' + tubeMax, carrier);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('b' + n, 'fs' + n);
	}
	K.rack(1);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		K.xfer('fs' + n, 'b' + (n-1));
	}
	K.rack(0);
}
//Finish last course of tube (and get carrier to the left):
for (let n = min - 1; n >= min - cordWidth - 1; n -= 1) {
	K.knit("-", 'b' + n, carrier);
}

//Closed bind-off on the tube:
for (let n = min - cordWidth - 1; n <= min - 1; n += 1) {
	K.xfer('b' + n, 'f' + n);
	K.knit("+", 'f' + n, carrier);
	K.rack(-1);
	K.xfer('f' + n, 'b' + (n+1));
	K.knit("+", 'b' + (n+1), carrier);
	K.rack(0);
}
K.xfer('b' + min, 'f' + min);

//Knit regular course to get carrier to the right:
for (let n = min; n <= max; n += 1) {
	K.knit("+", 'f' + n, carrier);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			K.knit("-", 'f' + n, carrier);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			K.knit("+", 'f' + n, carrier);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
K.outhook(carrier);

//drop loops:
for (let n = min; n <= max; n += 1) {
	K.drop('f' + n);
}


K.write('cast-on-sampler.swgn2.k');
;!knitout-2
;;Machine: SWGN2
;;Carriers: 1 2 3 4 5 6 7 8 9 10

;title: Cast-On Sampler (raw knitout)
; Creates several sheets, all with different cast-ons.

;Parameters:
; carrier = "3" -- carrier name
; min = 1 -- needle number of left edge
; max = 20 -- needle number of right edge
; rows = 20 -- rows of knitting in each sample
; cordWidth = 4 -- cord width (for I-cord cast-on)

; === Alternating Tucks === 
;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

;On SWGN2 machines, carriers start on the right,
;so will start tucking onto needles right-to-left,
;and will be sure to tuck the rightmost needle in the first pass:
tuck - f20 3
tuck - f18 3
tuck - f16 3
tuck - f14 3
tuck - f12 3
tuck - f10 3
tuck - f8 3
tuck - f6 3
tuck - f4 3
tuck - f2 3
;now, moving left-to-right, tuck the needles that were not tucked on the first pass:
tuck + f1 3
tuck + f3 3
tuck + f5 3
tuck + f7 3
tuck + f9 3
tuck + f11 3
tuck + f13 3
tuck + f15 3
tuck + f17 3
tuck + f19 3
;Set stitch table entry for knitting:
x-stitch-number 105
;knit two plain rows to allow cast-on stitches to relax:
; two isn't set in stone here -- it's just convenient
; for this example code to have the carrier end up on the right.
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Take carrier out with yarn inserting hook:
outhook 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

; === All-Needle Welt === 
;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

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

;Need to use quarter-pitch racking to tuck all needles in one pass:
rack -0.75

tuck - f20 3
tuck - b20 3
tuck - f19 3
tuck - b19 3
tuck - f18 3
tuck - b18 3
tuck - f17 3
tuck - b17 3
tuck - f16 3
tuck - b16 3
tuck - f15 3
tuck - b15 3
tuck - f14 3
tuck - b14 3
tuck - f13 3
tuck - b13 3
tuck - f12 3
tuck - b12 3
tuck - f11 3
tuck - b11 3
tuck - f10 3
tuck - b10 3
tuck - f9 3
tuck - b9 3
tuck - f8 3
tuck - b8 3
tuck - f7 3
tuck - b7 3
tuck - f6 3
tuck - b6 3
tuck - f5 3
tuck - b5 3
tuck - f4 3
tuck - b4 3
tuck - f3 3
tuck - b3 3
tuck - f2 3
tuck - b2 3
tuck - f1 3
tuck - b1 3

;Return to aligned racking:
rack 0

;Set stitch table entry for knitting:
x-stitch-number 105

;Do a rows of plain knitting on the front and back:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
knit - b20 3
knit - b19 3
knit - b18 3
knit - b17 3
knit - b16 3
knit - b15 3
knit - b14 3
knit - b13 3
knit - b12 3
knit - b11 3
knit - b10 3
knit - b9 3
knit - b8 3
knit - b7 3
knit - b6 3
knit - b5 3
knit - b4 3
knit - b3 3
knit - b2 3
knit - b1 3
;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:
xfer b20 f20
xfer b19 f19
xfer b18 f18
xfer b17 f17
xfer b16 f16
xfer b15 f15
xfer b14 f14
xfer b13 f13
xfer b12 f12
xfer b11 f11
xfer b10 f10
xfer b9 f9
xfer b8 f8
xfer b7 f7
xfer b6 f6
xfer b5 f5
xfer b4 f4
xfer b3 f3
xfer b2 f2
xfer b1 f1

;knit a plain row through the stacked stitches and return carrier to the right edge:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3

;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3
; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Take carrier out with yarn inserting hook:
outhook 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

; === Twisted Tucks === 
;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

;Use a twisted tuck to cast on every stitch.
;Note: this requires a new pass for every stitch, so is pretty slow!
;There are both faster and fancier cast-ons.
;On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
;Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
miss - f20 3
tuck + f20 3
tuck + f19 3
tuck + f18 3
tuck + f17 3
tuck + f16 3
tuck + f15 3
tuck + f14 3
tuck + f13 3
tuck + f12 3
tuck + f11 3
tuck + f10 3
tuck + f9 3
tuck + f8 3
tuck + f7 3
tuck + f6 3
tuck + f5 3
tuck + f4 3
tuck + f3 3
tuck + f2 3
tuck + f1 3
;Set stitch table entry for knitting:
x-stitch-number 105
;knit a plain row to bring the carrier back to the right:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3
; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Take carrier out with yarn inserting hook:
outhook 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

; === I-Cord === 
;Bring in carrier:
inhook 3
;Set stitch table entry for cast-on:
x-stitch-number 101

;On SWGN2 machines, carriers start on the right,
;so will start by making a closed tube bind-off for the cord on the right.

;All-needle closed-tube cast-on, with carrier ending on the left:
rack -0.75
tuck - f20 3
tuck - b20 3
tuck - f19 3
tuck - b19 3
tuck - f18 3
tuck - b18 3
tuck - f17 3
tuck - b17 3
tuck - f16 3
tuck - b16 3
rack 0

;Set stitch table entry for knitting:
x-stitch-number 105

;Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
;Start first course of the tube:
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;send out yarn inserting hook; it is no longer needed to hold the yarn in place:
releasehook 3
;Middle of tube:
knit - b20 3
knit - b19 3
knit - b18 3
knit - b17 3
knit - b16 3
miss - b15 3
xfer f16 bs16
xfer f17 bs17
xfer f18 bs18
xfer f19 bs19
xfer f20 bs20
rack -1
xfer bs16 f15
xfer bs17 f16
xfer bs18 f17
xfer bs19 f18
xfer bs20 f19
rack 0
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
tuck + f20 3
xfer b16 fs16
xfer b17 fs17
xfer b18 fs18
xfer b19 fs19
xfer b20 fs20
rack 1
xfer fs16 b15
xfer fs17 b16
xfer fs18 b17
xfer fs19 b18
xfer fs20 b19
rack 0
knit - b19 3
knit - b18 3
knit - b17 3
knit - b16 3
knit - b15 3
miss - b14 3
xfer f15 bs15
xfer f16 bs16
xfer f17 bs17
xfer f18 bs18
xfer f19 bs19
rack -1
xfer bs15 f14
xfer bs16 f15
xfer bs17 f16
xfer bs18 f17
xfer bs19 f18
rack 0
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
tuck + f19 3
xfer b15 fs15
xfer b16 fs16
xfer b17 fs17
xfer b18 fs18
xfer b19 fs19
rack 1
xfer fs15 b14
xfer fs16 b15
xfer fs17 b16
xfer fs18 b17
xfer fs19 b18
rack 0
knit - b18 3
knit - b17 3
knit - b16 3
knit - b15 3
knit - b14 3
miss - b13 3
xfer f14 bs14
xfer f15 bs15
xfer f16 bs16
xfer f17 bs17
xfer f18 bs18
rack -1
xfer bs14 f13
xfer bs15 f14
xfer bs16 f15
xfer bs17 f16
xfer bs18 f17
rack 0
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
tuck + f18 3
xfer b14 fs14
xfer b15 fs15
xfer b16 fs16
xfer b17 fs17
xfer b18 fs18
rack 1
xfer fs14 b13
xfer fs15 b14
xfer fs16 b15
xfer fs17 b16
xfer fs18 b17
rack 0
knit - b17 3
knit - b16 3
knit - b15 3
knit - b14 3
knit - b13 3
miss - b12 3
xfer f13 bs13
xfer f14 bs14
xfer f15 bs15
xfer f16 bs16
xfer f17 bs17
rack -1
xfer bs13 f12
xfer bs14 f13
xfer bs15 f14
xfer bs16 f15
xfer bs17 f16
rack 0
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
tuck + f17 3
xfer b13 fs13
xfer b14 fs14
xfer b15 fs15
xfer b16 fs16
xfer b17 fs17
rack 1
xfer fs13 b12
xfer fs14 b13
xfer fs15 b14
xfer fs16 b15
xfer fs17 b16
rack 0
knit - b16 3
knit - b15 3
knit - b14 3
knit - b13 3
knit - b12 3
miss - b11 3
xfer f12 bs12
xfer f13 bs13
xfer f14 bs14
xfer f15 bs15
xfer f16 bs16
rack -1
xfer bs12 f11
xfer bs13 f12
xfer bs14 f13
xfer bs15 f14
xfer bs16 f15
rack 0
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
tuck + f16 3
xfer b12 fs12
xfer b13 fs13
xfer b14 fs14
xfer b15 fs15
xfer b16 fs16
rack 1
xfer fs12 b11
xfer fs13 b12
xfer fs14 b13
xfer fs15 b14
xfer fs16 b15
rack 0
knit - b15 3
knit - b14 3
knit - b13 3
knit - b12 3
knit - b11 3
miss - b10 3
xfer f11 bs11
xfer f12 bs12
xfer f13 bs13
xfer f14 bs14
xfer f15 bs15
rack -1
xfer bs11 f10
xfer bs12 f11
xfer bs13 f12
xfer bs14 f13
xfer bs15 f14
rack 0
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
tuck + f15 3
xfer b11 fs11
xfer b12 fs12
xfer b13 fs13
xfer b14 fs14
xfer b15 fs15
rack 1
xfer fs11 b10
xfer fs12 b11
xfer fs13 b12
xfer fs14 b13
xfer fs15 b14
rack 0
knit - b14 3
knit - b13 3
knit - b12 3
knit - b11 3
knit - b10 3
miss - b9 3
xfer f10 bs10
xfer f11 bs11
xfer f12 bs12
xfer f13 bs13
xfer f14 bs14
rack -1
xfer bs10 f9
xfer bs11 f10
xfer bs12 f11
xfer bs13 f12
xfer bs14 f13
rack 0
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
tuck + f14 3
xfer b10 fs10
xfer b11 fs11
xfer b12 fs12
xfer b13 fs13
xfer b14 fs14
rack 1
xfer fs10 b9
xfer fs11 b10
xfer fs12 b11
xfer fs13 b12
xfer fs14 b13
rack 0
knit - b13 3
knit - b12 3
knit - b11 3
knit - b10 3
knit - b9 3
miss - b8 3
xfer f9 bs9
xfer f10 bs10
xfer f11 bs11
xfer f12 bs12
xfer f13 bs13
rack -1
xfer bs9 f8
xfer bs10 f9
xfer bs11 f10
xfer bs12 f11
xfer bs13 f12
rack 0
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
tuck + f13 3
xfer b9 fs9
xfer b10 fs10
xfer b11 fs11
xfer b12 fs12
xfer b13 fs13
rack 1
xfer fs9 b8
xfer fs10 b9
xfer fs11 b10
xfer fs12 b11
xfer fs13 b12
rack 0
knit - b12 3
knit - b11 3
knit - b10 3
knit - b9 3
knit - b8 3
miss - b7 3
xfer f8 bs8
xfer f9 bs9
xfer f10 bs10
xfer f11 bs11
xfer f12 bs12
rack -1
xfer bs8 f7
xfer bs9 f8
xfer bs10 f9
xfer bs11 f10
xfer bs12 f11
rack 0
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
tuck + f12 3
xfer b8 fs8
xfer b9 fs9
xfer b10 fs10
xfer b11 fs11
xfer b12 fs12
rack 1
xfer fs8 b7
xfer fs9 b8
xfer fs10 b9
xfer fs11 b10
xfer fs12 b11
rack 0
knit - b11 3
knit - b10 3
knit - b9 3
knit - b8 3
knit - b7 3
miss - b6 3
xfer f7 bs7
xfer f8 bs8
xfer f9 bs9
xfer f10 bs10
xfer f11 bs11
rack -1
xfer bs7 f6
xfer bs8 f7
xfer bs9 f8
xfer bs10 f9
xfer bs11 f10
rack 0
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
tuck + f11 3
xfer b7 fs7
xfer b8 fs8
xfer b9 fs9
xfer b10 fs10
xfer b11 fs11
rack 1
xfer fs7 b6
xfer fs8 b7
xfer fs9 b8
xfer fs10 b9
xfer fs11 b10
rack 0
knit - b10 3
knit - b9 3
knit - b8 3
knit - b7 3
knit - b6 3
miss - b5 3
xfer f6 bs6
xfer f7 bs7
xfer f8 bs8
xfer f9 bs9
xfer f10 bs10
rack -1
xfer bs6 f5
xfer bs7 f6
xfer bs8 f7
xfer bs9 f8
xfer bs10 f9
rack 0
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
tuck + f10 3
xfer b6 fs6
xfer b7 fs7
xfer b8 fs8
xfer b9 fs9
xfer b10 fs10
rack 1
xfer fs6 b5
xfer fs7 b6
xfer fs8 b7
xfer fs9 b8
xfer fs10 b9
rack 0
knit - b9 3
knit - b8 3
knit - b7 3
knit - b6 3
knit - b5 3
miss - b4 3
xfer f5 bs5
xfer f6 bs6
xfer f7 bs7
xfer f8 bs8
xfer f9 bs9
rack -1
xfer bs5 f4
xfer bs6 f5
xfer bs7 f6
xfer bs8 f7
xfer bs9 f8
rack 0
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
tuck + f9 3
xfer b5 fs5
xfer b6 fs6
xfer b7 fs7
xfer b8 fs8
xfer b9 fs9
rack 1
xfer fs5 b4
xfer fs6 b5
xfer fs7 b6
xfer fs8 b7
xfer fs9 b8
rack 0
knit - b8 3
knit - b7 3
knit - b6 3
knit - b5 3
knit - b4 3
miss - b3 3
xfer f4 bs4
xfer f5 bs5
xfer f6 bs6
xfer f7 bs7
xfer f8 bs8
rack -1
xfer bs4 f3
xfer bs5 f4
xfer bs6 f5
xfer bs7 f6
xfer bs8 f7
rack 0
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
tuck + f8 3
xfer b4 fs4
xfer b5 fs5
xfer b6 fs6
xfer b7 fs7
xfer b8 fs8
rack 1
xfer fs4 b3
xfer fs5 b4
xfer fs6 b5
xfer fs7 b6
xfer fs8 b7
rack 0
knit - b7 3
knit - b6 3
knit - b5 3
knit - b4 3
knit - b3 3
miss - b2 3
xfer f3 bs3
xfer f4 bs4
xfer f5 bs5
xfer f6 bs6
xfer f7 bs7
rack -1
xfer bs3 f2
xfer bs4 f3
xfer bs5 f4
xfer bs6 f5
xfer bs7 f6
rack 0
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
tuck + f7 3
xfer b3 fs3
xfer b4 fs4
xfer b5 fs5
xfer b6 fs6
xfer b7 fs7
rack 1
xfer fs3 b2
xfer fs4 b3
xfer fs5 b4
xfer fs6 b5
xfer fs7 b6
rack 0
knit - b6 3
knit - b5 3
knit - b4 3
knit - b3 3
knit - b2 3
miss - b1 3
xfer f2 bs2
xfer f3 bs3
xfer f4 bs4
xfer f5 bs5
xfer f6 bs6
rack -1
xfer bs2 f1
xfer bs3 f2
xfer bs4 f3
xfer bs5 f4
xfer bs6 f5
rack 0
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
tuck + f6 3
xfer b2 fs2
xfer b3 fs3
xfer b4 fs4
xfer b5 fs5
xfer b6 fs6
rack 1
xfer fs2 b1
xfer fs3 b2
xfer fs4 b3
xfer fs5 b4
xfer fs6 b5
rack 0
knit - b5 3
knit - b4 3
knit - b3 3
knit - b2 3
knit - b1 3
miss - b0 3
xfer f1 bs1
xfer f2 bs2
xfer f3 bs3
xfer f4 bs4
xfer f5 bs5
rack -1
xfer bs1 f0
xfer bs2 f1
xfer bs3 f2
xfer bs4 f3
xfer bs5 f4
rack 0
knit + f0 3
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
tuck + f5 3
xfer b1 fs1
xfer b2 fs2
xfer b3 fs3
xfer b4 fs4
xfer b5 fs5
rack 1
xfer fs1 b0
xfer fs2 b1
xfer fs3 b2
xfer fs4 b3
xfer fs5 b4
rack 0
knit - b4 3
knit - b3 3
knit - b2 3
knit - b1 3
knit - b0 3
miss - b-1 3
xfer f0 bs0
xfer f1 bs1
xfer f2 bs2
xfer f3 bs3
xfer f4 bs4
rack -1
xfer bs0 f-1
xfer bs1 f0
xfer bs2 f1
xfer bs3 f2
xfer bs4 f3
rack 0
knit + f-1 3
knit + f0 3
knit + f1 3
knit + f2 3
knit + f3 3
tuck + f4 3
xfer b0 fs0
xfer b1 fs1
xfer b2 fs2
xfer b3 fs3
xfer b4 fs4
rack 1
xfer fs0 b-1
xfer fs1 b0
xfer fs2 b1
xfer fs3 b2
xfer fs4 b3
rack 0
knit - b3 3
knit - b2 3
knit - b1 3
knit - b0 3
knit - b-1 3
miss - b-2 3
xfer f-1 bs-1
xfer f0 bs0
xfer f1 bs1
xfer f2 bs2
xfer f3 bs3
rack -1
xfer bs-1 f-2
xfer bs0 f-1
xfer bs1 f0
xfer bs2 f1
xfer bs3 f2
rack 0
knit + f-2 3
knit + f-1 3
knit + f0 3
knit + f1 3
knit + f2 3
tuck + f3 3
xfer b-1 fs-1
xfer b0 fs0
xfer b1 fs1
xfer b2 fs2
xfer b3 fs3
rack 1
xfer fs-1 b-2
xfer fs0 b-1
xfer fs1 b0
xfer fs2 b1
xfer fs3 b2
rack 0
knit - b2 3
knit - b1 3
knit - b0 3
knit - b-1 3
knit - b-2 3
miss - b-3 3
xfer f-2 bs-2
xfer f-1 bs-1
xfer f0 bs0
xfer f1 bs1
xfer f2 bs2
rack -1
xfer bs-2 f-3
xfer bs-1 f-2
xfer bs0 f-1
xfer bs1 f0
xfer bs2 f1
rack 0
knit + f-3 3
knit + f-2 3
knit + f-1 3
knit + f0 3
knit + f1 3
tuck + f2 3
xfer b-2 fs-2
xfer b-1 fs-1
xfer b0 fs0
xfer b1 fs1
xfer b2 fs2
rack 1
xfer fs-2 b-3
xfer fs-1 b-2
xfer fs0 b-1
xfer fs1 b0
xfer fs2 b1
rack 0
knit - b1 3
knit - b0 3
knit - b-1 3
knit - b-2 3
knit - b-3 3
miss - b-4 3
xfer f-3 bs-3
xfer f-2 bs-2
xfer f-1 bs-1
xfer f0 bs0
xfer f1 bs1
rack -1
xfer bs-3 f-4
xfer bs-2 f-3
xfer bs-1 f-2
xfer bs0 f-1
xfer bs1 f0
rack 0
knit + f-4 3
knit + f-3 3
knit + f-2 3
knit + f-1 3
knit + f0 3
tuck + f1 3
xfer b-3 fs-3
xfer b-2 fs-2
xfer b-1 fs-1
xfer b0 fs0
xfer b1 fs1
rack 1
xfer fs-3 b-4
xfer fs-2 b-3
xfer fs-1 b-2
xfer fs0 b-1
xfer fs1 b0
rack 0
;Finish last course of tube (and get carrier to the left):
knit - b0 3
knit - b-1 3
knit - b-2 3
knit - b-3 3
knit - b-4 3

;Closed bind-off on the tube:
xfer b-4 f-4
knit + f-4 3
rack -1
xfer f-4 b-3
knit + b-3 3
rack 0
xfer b-3 f-3
knit + f-3 3
rack -1
xfer f-3 b-2
knit + b-2 3
rack 0
xfer b-2 f-2
knit + f-2 3
rack -1
xfer f-2 b-1
knit + b-1 3
rack 0
xfer b-1 f-1
knit + f-1 3
rack -1
xfer f-1 b0
knit + b0 3
rack 0
xfer b0 f0
knit + f0 3
rack -1
xfer f0 b1
knit + b1 3
rack 0
xfer b1 f1

;Knit regular course to get carrier to the right:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
; ---- single jersey sheet ----
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3
;right-going row:
knit + f1 3
knit + f2 3
knit + f3 3
knit + f4 3
knit + f5 3
knit + f6 3
knit + f7 3
knit + f8 3
knit + f9 3
knit + f10 3
knit + f11 3
knit + f12 3
knit + f13 3
knit + f14 3
knit + f15 3
knit + f16 3
knit + f17 3
knit + f18 3
knit + f19 3
knit + f20 3
;left-going row:
knit - f20 3
knit - f19 3
knit - f18 3
knit - f17 3
knit - f16 3
knit - f15 3
knit - f14 3
knit - f13 3
knit - f12 3
knit - f11 3
knit - f10 3
knit - f9 3
knit - f8 3
knit - f7 3
knit - f6 3
knit - f5 3
knit - f4 3
knit - f3 3
knit - f2 3
knit - f1 3

; ---- take carrier out and drop remaining loops ----
;Take carrier out with yarn inserting hook:
outhook 3

;drop loops:
drop f1
drop f2
drop f3
drop f4
drop f5
drop f6
drop f7
drop f8
drop f9
drop f10
drop f11
drop f12
drop f13
drop f14
drop f15
drop f16
drop f17
drop f18
drop f19
drop f20

//title: Cast-On Sampler (plain javascript)
// Creates several sheets, all with different cast-ons.

//Write header:
console.log(';!knitout-2');
console.log(';;Machine: SWGN2');
console.log(';;Carriers: 1 2 3 4 5 6 7 8 9 10');

//Parameters:
let carrier = "3"; //carrier name
let min = 1; //needle number of left edge
let max = 20; //needle number of right edge
let rows = 20; //rows of knitting in each sample
let cordWidth = 4; //cord width (for I-cord cast-on)

// === Alternating Tucks === 
//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

//On SWGN2 machines, carriers start on the right,
//so will start tucking onto needles right-to-left,
//and will be sure to tuck the rightmost needle in the first pass:
for (let n = max; n >= min; n -= 1) {
	//tuck alternating needles, making sure to do the right edge:
	if ((max - n) % 2 === 0) {
		console.log(`tuck - f${n} ${carrier}`);
	}
}
//now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for (let n = min; n <= max; n += 1) {
	if ((max - n) % 2 !== 0) {
		console.log(`tuck + f${n} ${carrier}`);
	}
}
//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);
//knit two plain rows to allow cast-on stitches to relax:
// two isn't set in stone here -- it's just convenient
// for this example code to have the carrier end up on the right.
for (let n = max; n >= min; n -= 1) {
	console.log(`knit - f${n} ${carrier}`);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
console.log(`outhook ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

// === All-Needle Welt === 
//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

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

//Need to use quarter-pitch racking to tuck all needles in one pass:
console.log(`rack -0.75`);

for (let n = max; n >= min; n -= 1) {
	console.log(`tuck - f${n} ${carrier}`);
	console.log(`tuck - b${n} ${carrier}`);
}

//Return to aligned racking:
console.log(`rack 0`);

//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);

//Do a rows of plain knitting on the front and back:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
for (let n = max; n >= min; n -= 1) {
	console.log(`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 (let n = max; n >= min; n -= 1) {
	console.log(`xfer b${n} f${n}`);
}

//knit a plain row through the stacked stitches and return carrier to the right edge:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}

//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
console.log(`outhook ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

// === Twisted Tucks === 
//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

//Use a twisted tuck to cast on every stitch.
//Note: this requires a new pass for every stitch, so is pretty slow!
//There are both faster and fancier cast-ons.
//On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
//Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
console.log(`miss - f${max} ${carrier}`);
for (let n = max; n >= min; n -= 1) {
	console.log(`tuck + f${n} ${carrier}`);
}
//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);
//knit a plain row to bring the carrier back to the right:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
console.log(`outhook ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

// === I-Cord === 
//Bring in carrier:
console.log(`inhook ${carrier}`);
//Set stitch table entry for cast-on:
console.log(`x-stitch-number 101`);

//On SWGN2 machines, carriers start on the right,
//so will start by making a closed tube bind-off for the cord on the right.

//All-needle closed-tube cast-on, with carrier ending on the left:
console.log(`rack -0.75`);
for (let n = max; n >= max - cordWidth; n -= 1) {
	console.log(`tuck - f${n} ${carrier}`);
	console.log(`tuck - b${n} ${carrier}`);
}
console.log(`rack 0`);

//Set stitch table entry for knitting:
console.log(`x-stitch-number 105`);

//Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
//Start first course of the tube:
for (let n = max - cordWidth; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
//send out yarn inserting hook; it is no longer needed to hold the yarn in place:
console.log(`releasehook ${carrier}`);
//Middle of tube:
for (let tubeMax = max; tubeMax >= min; tubeMax -= 1) {
	for (let n = tubeMax; n >= tubeMax - cordWidth; n -= 1) {
		console.log(`knit - b${n} ${carrier}`);
	}
	console.log(`miss - b${(tubeMax-cordWidth-1)} ${carrier}`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer f${n} bs${n}`);
	}
	console.log(`rack -1`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer bs${n} f${(n-1)}`);
	}
	console.log(`rack 0`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`knit + f${(n-1)} ${carrier}`);
	}
	console.log(`tuck + f${tubeMax} ${carrier}`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer b${n} fs${n}`);
	}
	console.log(`rack 1`);
	for (let n = tubeMax - cordWidth; n <= tubeMax; n += 1) {
		console.log(`xfer fs${n} b${(n-1)}`);
	}
	console.log(`rack 0`);
}
//Finish last course of tube (and get carrier to the left):
for (let n = min - 1; n >= min - cordWidth - 1; n -= 1) {
	console.log(`knit - b${n} ${carrier}`);
}

//Closed bind-off on the tube:
for (let n = min - cordWidth - 1; n <= min - 1; n += 1) {
	console.log(`xfer b${n} f${n}`);
	console.log(`knit + f${n} ${carrier}`);
	console.log(`rack -1`);
	console.log(`xfer f${n} b${(n+1)}`);
	console.log(`knit + b${(n+1)} ${carrier}`);
	console.log(`rack 0`);
}
console.log(`xfer b${min} f${min}`);

//Knit regular course to get carrier to the right:
for (let n = min; n <= max; n += 1) {
	console.log(`knit + f${n} ${carrier}`);
}
// ---- single jersey sheet ----
for (let r = 0; r <= rows; r += 1) {
	if (r % 2 === 0) {
		//left-going row:
		for (let n = max; n >= min; n -= 1) {
			console.log(`knit - f${n} ${carrier}`);
		}
	} else {
		//right-going row:
		for (let n = min; n <= max; n += 1) {
			console.log(`knit + f${n} ${carrier}`);
		}
	}
}

// ---- take carrier out and drop remaining loops ----
//Take carrier out with yarn inserting hook:
console.log(`outhook ${carrier}`);

//drop loops:
for (let n = min; n <= max; n += 1) {
	console.log(`drop f${n}`);
}

#title: Cast-On Sampler (plain python)
# Creates several sheets, all with different cast-ons.

#Write header:
print(';!knitout-2')
print(';;Machine: SWGN2')
print(';;Carriers: 1 2 3 4 5 6 7 8 9 10')

#Parameters:
carrier = "3" #carrier name
min = 1 #needle number of left edge
max = 20 #needle number of right edge
rows = 20 #rows of knitting in each sample
cordWidth = 4 #cord width (for I-cord cast-on)

# === Alternating Tucks === 
#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

#On SWGN2 machines, carriers start on the right,
#so will start tucking onto needles right-to-left,
#and will be sure to tuck the rightmost needle in the first pass:
for n in range(max, min-1, -1):
	#tuck alternating needles, making sure to do the right edge:
	if (max - n) % 2 == 0:
		print(f"tuck - f{n} {carrier}")
#now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for n in range(min, max+1, 1):
	if (max - n) % 2 != 0:
		print(f"tuck + f{n} {carrier}")
#Set stitch table entry for knitting:
print(f"x-stitch-number 105")
#knit two plain rows to allow cast-on stitches to relax:
# two isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(max, min-1, -1):
	print(f"knit - f{n} {carrier}")
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
print(f"outhook {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

# === All-Needle Welt === 
#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

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

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

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

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

#Set stitch table entry for knitting:
print(f"x-stitch-number 105")

#Do a rows of plain knitting on the front and back:
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
for n in range(max, min-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(max, min-1, -1):
	print(f"xfer b{n} f{n}")

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

#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
print(f"outhook {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

# === Twisted Tucks === 
#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
#Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
print(f"miss - f{max} {carrier}")
for n in range(max, min-1, -1):
	print(f"tuck + f{n} {carrier}")
#Set stitch table entry for knitting:
print(f"x-stitch-number 105")
#knit a plain row to bring the carrier back to the right:
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
print(f"outhook {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

# === I-Cord === 
#Bring in carrier:
print(f"inhook {carrier}")
#Set stitch table entry for cast-on:
print(f"x-stitch-number 101")

#On SWGN2 machines, carriers start on the right,
#so will start by making a closed tube bind-off for the cord on the right.

#All-needle closed-tube cast-on, with carrier ending on the left:
print(f"rack -0.75")
for n in range(max, max - cordWidth-1, -1):
	print(f"tuck - f{n} {carrier}")
	print(f"tuck - b{n} {carrier}")
print(f"rack 0")

#Set stitch table entry for knitting:
print(f"x-stitch-number 105")

#Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
#Start first course of the tube:
for n in range(max - cordWidth, max+1, 1):
	print(f"knit + f{n} {carrier}")
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
print(f"releasehook {carrier}")
#Middle of tube:
for tubeMax in range(max, min-1, -1):
	for n in range(tubeMax, tubeMax - cordWidth-1, -1):
		print(f"knit - b{n} {carrier}")
	print(f"miss - b{tubeMax-cordWidth-1} {carrier}")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer f{n} bs{n}")
	print(f"rack -1")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer bs{n} f{n-1}")
	print(f"rack 0")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"knit + f{n-1} {carrier}")
	print(f"tuck + f{tubeMax} {carrier}")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer b{n} fs{n}")
	print(f"rack 1")
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		print(f"xfer fs{n} b{n-1}")
	print(f"rack 0")
#Finish last course of tube (and get carrier to the left):
for n in range(min - 1, min - cordWidth - 1-1, -1):
	print(f"knit - b{n} {carrier}")

#Closed bind-off on the tube:
for n in range(min - cordWidth - 1, min - 1+1, 1):
	print(f"xfer b{n} f{n}")
	print(f"knit + f{n} {carrier}")
	print(f"rack -1")
	print(f"xfer f{n} b{n+1}")
	print(f"knit + b{n+1} {carrier}")
	print(f"rack 0")
print(f"xfer b{min} f{min}")

#Knit regular course to get carrier to the right:
for n in range(min, max+1, 1):
	print(f"knit + f{n} {carrier}")
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			print(f"knit - f{n} {carrier}")
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			print(f"knit + f{n} {carrier}")

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
print(f"outhook {carrier}")

#drop loops:
for n in range(min, max+1, 1):
	print(f"drop f{n}")

#title: Cast-On Sampler (python with knitout module)
# Creates several sheets, all with different cast-ons.

import knitout
K = knitout.Writer('1 2 3 4 5 6 7 8 9 10');
K.addHeader('Machine', 'SWGN2');

#Parameters:
carrier = "3" #carrier name
min = 1 #needle number of left edge
max = 20 #needle number of right edge
rows = 20 #rows of knitting in each sample
cordWidth = 4 #cord width (for I-cord cast-on)

# === Alternating Tucks === 
#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

#On SWGN2 machines, carriers start on the right,
#so will start tucking onto needles right-to-left,
#and will be sure to tuck the rightmost needle in the first pass:
for n in range(max, min-1, -1):
	#tuck alternating needles, making sure to do the right edge:
	if (max - n) % 2 == 0:
		K.tuck("-", 'f' + str(n), carrier)
#now, moving left-to-right, tuck the needles that were not tucked on the first pass:
for n in range(min, max+1, 1):
	if (max - n) % 2 != 0:
		K.tuck("+", 'f' + str(n), carrier)
#Set stitch table entry for knitting:
K.stitchNumber(105)
#knit two plain rows to allow cast-on stitches to relax:
# two isn't set in stone here -- it's just convenient
# for this example code to have the carrier end up on the right.
for n in range(max, min-1, -1):
	K.knit("-", 'f' + str(n), carrier)
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
K.outhook(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))

# === All-Needle Welt === 
#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

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

#Need to use quarter-pitch racking to tuck all needles in one pass:
K.rack(-0.75)

for n in range(max, min-1, -1):
	K.tuck("-", 'f' + str(n), carrier)
	K.tuck("-", 'b' + str(n), carrier)

#Return to aligned racking:
K.rack(0)

#Set stitch table entry for knitting:
K.stitchNumber(105)

#Do a rows of plain knitting on the front and back:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
for n in range(max, min-1, -1):
	K.knit("-", 'b' + str(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(max, min-1, -1):
	K.xfer('b' + str(n), 'f' + str(n))

#knit a plain row through the stacked stitches and return carrier to the right edge:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)

#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
K.outhook(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))

# === Twisted Tucks === 
#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

#Use a twisted tuck to cast on every stitch.
#Note: this requires a new pass for every stitch, so is pretty slow!
#There are both faster and fancier cast-ons.
#On SWGN2 machines, carriers start on the right, so will start with rightmost needle.
#Miss the rightmost needle to ensure yarn inserting hook is parked to its right instead of left:
K.miss("-", 'f' + str(max), carrier)
for n in range(max, min-1, -1):
	K.tuck("+", 'f' + str(n), carrier)
#Set stitch table entry for knitting:
K.stitchNumber(105)
#knit a plain row to bring the carrier back to the right:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
K.outhook(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))

# === I-Cord === 
#Bring in carrier:
K.inhook(carrier)
#Set stitch table entry for cast-on:
K.stitchNumber(101)

#On SWGN2 machines, carriers start on the right,
#so will start by making a closed tube bind-off for the cord on the right.

#All-needle closed-tube cast-on, with carrier ending on the left:
K.rack(-0.75)
for n in range(max, max - cordWidth-1, -1):
	K.tuck("-", 'f' + str(n), carrier)
	K.tuck("-", 'b' + str(n), carrier)
K.rack(0)

#Set stitch table entry for knitting:
K.stitchNumber(105)

#Knit a small tube, leaving an extra stitch to the right and moving the stitches every course:
#Start first course of the tube:
for n in range(max - cordWidth, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
#send out yarn inserting hook; it is no longer needed to hold the yarn in place:
K.releasehook(carrier)
#Middle of tube:
for tubeMax in range(max, min-1, -1):
	for n in range(tubeMax, tubeMax - cordWidth-1, -1):
		K.knit("-", 'b' + str(n), carrier)
	K.miss("-", 'b' + str(tubeMax-cordWidth-1), carrier)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('f' + str(n), 'bs' + str(n))
	K.rack(-1)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('bs' + str(n), 'f' + str(n-1))
	K.rack(0)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.knit("+", 'f' + str(n-1), carrier)
	K.tuck("+", 'f' + str(tubeMax), carrier)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('b' + str(n), 'fs' + str(n))
	K.rack(1)
	for n in range(tubeMax - cordWidth, tubeMax+1, 1):
		K.xfer('fs' + str(n), 'b' + str(n-1))
	K.rack(0)
#Finish last course of tube (and get carrier to the left):
for n in range(min - 1, min - cordWidth - 1-1, -1):
	K.knit("-", 'b' + str(n), carrier)

#Closed bind-off on the tube:
for n in range(min - cordWidth - 1, min - 1+1, 1):
	K.xfer('b' + str(n), 'f' + str(n))
	K.knit("+", 'f' + str(n), carrier)
	K.rack(-1)
	K.xfer('f' + str(n), 'b' + str(n+1))
	K.knit("+", 'b' + str(n+1), carrier)
	K.rack(0)
K.xfer('b' + str(min), 'f' + str(min))

#Knit regular course to get carrier to the right:
for n in range(min, max+1, 1):
	K.knit("+", 'f' + str(n), carrier)
# ---- single jersey sheet ----
for r in range(0, rows+1, 1):
	if r % 2 == 0:
		#left-going row:
		for n in range(max, min-1, -1):
			K.knit("-", 'f' + str(n), carrier)
	else:
		#right-going row:
		for n in range(min, max+1, 1):
			K.knit("+", 'f' + str(n), carrier)

# ---- take carrier out and drop remaining loops ----
#Take carrier out with yarn inserting hook:
K.outhook(carrier)

#drop loops:
for n in range(min, max+1, 1):
	K.drop('f' + str(n))


K.write('cast-on-sampler.swgn2.k')