This will close the n'th side of an n sided polygon, in HMS format.
Angular input and output is in degrees minutes seconds, i.e. 90.3030.
Quadrant bearings are not supported.


Eg.

Dist&Brg?
10 0
CONT
Dist&Brg?
10 30.3030
CONT
Dist&Brg?
10 135.3050
CONT
Dist&Brg?
CONT
Dist: 16.6686669939
Brg: 226.275377889

EXIT will kill FoClo and clean up three variables, a, EXIT and Supp.
Angles can be greater than 360, i.e. 405 is equivalent to 45.
Angles can be negative, i.e. -270 is equivalent to 90.

mwgupton@mb.sympatico.ca



 { 1 -16 } CF
   1 SF CONT
   'EXIT' STO
   180 SWAP HMS-
   'Supp' STO {
EXIT { } Supp { } {
} CONT } TMENU { }
'a' STO
  DO "Dist&Brg?"
HALT
    IFERR HMS -16
SF V2 a + 'a' STO
DROP
    THEN DROP a
OBJ 2 SWAP
      START
        IFERR +
        THEN 1 SF
        END
      NEXT
      IFERR NEG V
HMS DUP DUP
        IF 0 <
        THEN 360
HMS+ SWAP DROP
        ELSE
          IF 360 >
          THEN 360
HMS-
          END
        END "Brg"
TAG SWAP "Dist"
TAG SWAP 1 SF
      THEN 1 SF
      END
    END
  UNTIL 1 FS?
  END 2 MENU { EXIT
Supp a } PURGE -16
CF

