FOCALCMS Usage notes: FOCALCMS uses normal CMS terminal input routines. Some input characters cause special handling. You may need to pick different symbols for CHARDEL and LINEND or set these OFF to disable some of the line editing. CP SET LINEDIT OFF CP TERMINAL ESCAPE OFF Sample scripts ============== n-Queens -------- 01.10 c 8-Queens problem in Focal-8 01.20 c Hacked by Akira KIDA, SDI00379@niftyserve.or.jp 10.10 c main 10.20 s nQueen = 8 10.30 d 20 10.40 s Count = 0; s pend = 0 10.50 s n = 0; d 30 10.60 d 60 10.70 t %1.0, "Total ", Count, " answers", ! 10.80 q 20.10 c initialize 20.20 f i = 0, nQueen - 1; s Pos(i) = 0; s Row(i) = 1 20.40 f i = 0, nQueen * 2 - 2; s Up(i) = 1 20.50 f i = 0, nQueen * 2 - 2; s Down(i - nQueen + 1) = 1 20.60 s k = 0 20.70 r 30.10 c generate(n) 30.20 c make sure to use individual control variables in each nest levels 30.30 f k(n) = 0, nQueen - 1; d 40 30.40 r 40.10 c generate(n) body 40.20 i (-(Row(k(n)) * Up(n + k(n)) * Down(n - k(n)))) 40.30; r 40.30 s Pos(n) = k(n) 40.40 i (n - nQueen + 1) 40.50; d 50; r 40.50 s Row(k(n)) = 0; s Up(n + k(n)) = 0; s Down(n - k(n)) = 0 40.60 s n = n + 1; d 30; s n = n - 1 40.70 s Down(n - k(n)) = 1; s Up(n + k(n)) = 1; s Row(k(n)) = 1 40.80 r 50.10 c answer 50.20 s Count = Count + 1; s pend = pend + 1 50.30 f i = 0, nQueen - 1; s ans(pend * nQueen + i) = Pos(i) 50.40 i (pend - 3) 50.50; d 60 50.50 r 60.10 c flush answer 60.20 i (-pend) 60.30; r 60.30 f a = 1, pend; t %1.0, " Solution #", Count - pend + a, " " 60.40 t ! 60.50 f i = 0, nQueen - 1; d 70 60.60 t ! ; s pend = 0 60.70 r 70.10 c answer inner loop 70.20 f a = 1, pend; d 80 70.30 t ! 70.40 r 80.10 t " " 80.20 f j = 0, nQueen - 1; d 90 80.30 r 90.10 c answer print element 90.20 i (ans(a * nQueen + i) - j) 90.50, 90.30, 90.50 90.30 t " Q" 90.40 r 90.50 t " ." 90.60 r