Syntax Error on line 128

An endsub has appeared outside of a subroutine definition.

Edit the Settings File for Fusion Chess

For the sake of debugging, here is the full GAME Code program that this error occurred in. The lines have been properly indented to help you spot scope errors.

   0 echo This preset now uses the new code for identifying check, checkmate, and stalemate. Let me know of any problems with it.
   1 setflag a1 a8 h1 h8 e1 e8
   2 set k findpiece k spaces
   3 set K findpiece K spaces
   4 set ep false
   5 include chess
   6 set plies 0
   7 setconst maxplies 0
   8 sub postauto1
   9   inc plies
  10   if > #plies @maxplies
  11     if fn moved origin dest and match moved Q M A Y X O and not capture and empty origin
  12       if == moved Y
  13         if checkleap origin dest 1 1
  14           ask "Whick will you do?", "Move the Pope", "", "Move the King, leaving behind the Bishop", "K-dest; B-origin", "Move the Bishop, leaving behind the King", "B-dest; K-origin"
  15         elseif checkleap origin dest 1 0
  16           ask "Which will you do?", "Move the Pope", "", "Move the King, leaving behind the Bishop", "K-dest; B-origin"
  17         else
  18           ask "Which will you do?", "Move the Pope", "", "Move the Bishop, leaving behind the King", "B-dest; K-origin"
  19         endif
  20       elseif == moved O
  21         if checkleap origin dest 1 0
  22           ask "Whick will you do?", "Move the Dragon King", "", "Move the King, leaving behind the Rook", "K-dest; R-origin", "Move the Rook, leaving behind the King", "R-dest; K-origin"
  23         elseif checkleap origin dest 1 0
  24           ask "Which will you do?", "Move the Dragon King", "", "Move the King, leaving behind the Rook", "K-dest; R-origin"
  25         else
  26           ask "Which will you do?", "Move the Dragon King", "", "Move the Rook, leaving behind the King", "R-dest; K-origin"
  27         endif
  28       elseif fn N origin dest
  29         if == moved M
  30           ask "Which will you do?", "Move the Marshall", "", "Move out the Knight, leaving behind the Rook", "N-dest; R-origin"
  31         elseif == moved A
  32           ask "Which will you do?", "Move the Paladin", "", "Move out the Knight, leaving behind the Bishop", "N-dest; B-origin"
  33         elseif == moved X and not #incheck
  34           ask "Which will you do?", "Move the Eques Rex", "", "Move out the Knight, leaving behind the King", "N-dest; K-origin"
  35         endif
  36       elseif fn B origin dest
  37         if == moved Q
  38           ask "Which will you do?", "Move the Queen", "", "Move out the Bishop, leaving behind the Rook", "B-dest; R-origin"
  39         elseif == moved A
  40           ask "Which will you do?", "Move the Paladin", "", "Move out the Bishop, leaving behind the Knight", "B-dest; N-origin"
  41         endif
  42       elseif fn R origin dest
  43         if == moved Q
  44           ask "Which will you do?", "Move the Queen", "", "Move out the Rook, leaving behind the Bishop", "R-dest; B-origin"
  45         elseif == moved A
  46           ask "Which will you do?", "Move the Marshall", "", "Move out the Rook, leaving behind the Knight", "R-dest; N-origin"
  47         endif
  48       endif
  49     endif
  50   endif
  51   if not equal moved P
  52     set ep false
  53     if != space dest moved
  54       die You may not change the type of this piece.
  55     endif
  56   endif
  57   set legal false
  58   if match moved P K
  59     gosub moved origin dest
  60     if equal moved K
  61       set K dest
  62     endif
  63   elseif match moved Q R B N
  64     set legal fn moved origin dest
  65     if == moved R
  66       unsetflag origin
  67     else
  68       unsetflag dest
  69     endif
  70   endif
  71   if not var legal
  72     die You may not move a moved from origin to dest
  73   endif
  74   if isupper old
  75     if == old moved or not match moved R B N K or not match old R B N
  76       die You may not fuse these two pieces together.
  77     elseif == moved space dest
  78       if match B old moved
  79         appendmove Q-dest
  80       elseif match N old moved
  81         appendmove M-dest
  82       elseif == moved K
  83         appendmove O-dest
  84       endif
  85     elseif match B old moved
  86       if match N old moved
  87         appendmove A-dest
  88       elseif == moved K
  89         appendmove Y-dest
  90       endif
  91     elseif == moved K and == old N
  92       appendmove X-dest
  93     endif
  94   elseif match R old moved
  95     if match B old moved
  96       if != space dest Q
  97         die A Rook and Bishop cannot fuse into anything but a Queen.
  98       endif
  99     elseif match N old moved
 100       if != space dest M
 101         die A Rook and Knight cannot fuse into anything but a Marshall.
 102       endif
 103     elseif == moved K
 104       if != space dest O
 105         die A Rook and King cannot fuse into anything but a Dragon King.
 106       endif
 107     endif
 108   elseif match B old moved
 109     if match N old moved
 110       if != space dest A
 111         die A Knight and Bishop cannot fuse into anything but a Paladin.
 112       endif
 113     elseif == moved K
 114       if != space dest Y
 115         die A King and Bishop cannot fuse into anything but a Pope.
 116       endif
 117     endif
 118   elseif == moved K and == old N
 119     if != space dest X
 120       die A King and Knight cannot fuse into anything but an Eques Rex.
 121     endif
 122   elseif match moved Q M A O Y X and == moved space dest and not capture
 123   endif
 124 endif
 125 if fn ATTACKEDBYB #K
 126   die You may not move into check.
 127 endif
 128 endsub
 129 sub postauto2
 130   inc plies
 131   if not equal moved p
 132     set ep false
 133     if != space dest moved
 134       die You may not change the type of this piece.
 135     endif
 136   endif
 137   set legal false
 138   if match moved p k
 139     gosub moved origin dest
 140     if equal moved k
 141       set k dest
 142     endif
 143   elseif match moved q r b n
 144     set legal fn toupper moved origin dest
 145     if == moved r
 146       unsetflag origin
 147     else
 148       unsetflag dest
 149     endif
 150   endif
 151   if not var legal
 152     die You may not move a moved from origin to dest
 153   endif
 154   if isupper old
 155     if == old moved or not match moved r b n k or not match old r b n
 156       die You may not fuse these two pieces together.
 157     elseif == moved space dest
 158       if match b old moved
 159         appendmove q-dest
 160       elseif match n old moved
 161         appendmove m-dest
 162       elseif == moved k
 163         appendmove o-dest
 164       endif
 165     elseif match b old moved
 166       if match n old moved
 167         appendmove a-dest
 168       elseif == moved k
 169         appendmove y-dest
 170       endif
 171     elseif == moved k and == old n
 172       appendmove x-dest
 173     endif
 174   elseif match r old moved
 175     if match b old moved
 176       if != space dest q
 177         die A Rook and Bishop cannot fuse into anything but a Queen.
 178       endif
 179     elseif match n old moved
 180       if != space dest m
 181         die A Rook and Knight cannot fuse into anything but a Marshall.
 182       endif
 183     elseif == moved k
 184       if != space dest o
 185         die A Rook and King cannot fuse into anything but a Dragon King.
 186       endif
 187     endif
 188   elseif match b old moved
 189     if match n old moved
 190       if != space dest a
 191         die A Knight and Bishop cannot fuse into anything but a Paladin.
 192       endif
 193     elseif == moved k
 194       if != space dest y
 195         die A King and Bishop cannot fuse into anything but a Pope.
 196       endif
 197     endif
 198   elseif == moved k and == old n
 199     if != space dest q
 200       die A King and Knight cannot fuse into anything but an Eques Rex.
 201     endif
 202   elseif match moved Q M A O Y X and == moved space dest and == old @
 203   endif
 204   if fn ATTACKEDBYW #k
 205     die You may not move into check.
 206   endif
 207 endsub
 208 resetconst maxplies plies
 209 set checks sub checks #K
 210 if var checks
 211   if sub checkmated #K #checks
 212     say Checkmate! Black has won!
 213     won
 214   else
 215     say Check!
 216   endif
 217 elseif sub stalemated #K
 218   say Stalemate! The game is drawn.
 219   drawn
 220 endif
 221 end
 222 

functions

uservar

Array ( [0] => Array ( [main] => Array ( ) ) )

mline

Array ( [0] => MoveLine Object ( [movenum] => 0 [move] => [level] => 0 [comment] => [length] => 0 [newturn] => [turn] => 0 ) )

allmoves

Array ( )

movelist

constants

Array ( )