*(TALK.RMD)
CONNECT talk
SET VAR vkey TEXT, vclscount INT, vresume INT, +
  vlastcls INT
SET MESSAGE OFF
IF vlastcls IS NULL THEN
   SET VAR vlastcls = 0
ENDIF

DECLARE c1 SCROLL CURSOR FOR SELECT * FROM actions +
 WHERE Frame >= .vlastcls ORDER BY Frame

OPEN c1
FETCH NEXT FROM c1 INTO +
 vFrame i1, vAction i2, vWords i3, vULR i4, +
 vULC i5, vLRR i6, vLRC i7, vFColor i8, vBColor i9
WHILE sqlcode = 0 THEN

  IF vresume = 0 OR vresume IS NULL THEN

    SWITCH (.vAction)

    CASE CLS
      CLS

      SET VAR vlastcls = .vFrame

      BREAK

    CASE BOX

      SET VAR bulr = (.vULR + 1)
      SET VAR bulc = (.vULC + 1)
      SET VAR blrr = (.vLRR + 1)
      SET VAR blrc = (.vLRC + 1)
      CLS FROM .bulr .bulc TO .blrr .blrc black

      CLS FROM .vULR .vULC TO .vLRR .vLRC .vBColor

      BREAK

    CASE WORDS

      SET VAR vwords TEXT = (.vwords)
      WRITE .vwords = .vLRR AT .vULR .vULC +
        .vFColor ON .vBColor

      SET VAR vkey = (GETKEY(0))
      SWITCH (.vkey)

      CASE [Esc]
        SET VAR vlastcls = 0
        CLS
        QUIT

      CASE [Up]
      CASE [PgUp]
        SET VAR vclscount = 0
        WHILE sqlcode = 0 THEN
          FETCH PRIOR FROM c1 INTO +
           vFrame i1, vAction i2, vWords i3,+
           vULR i4, vULC i5, vLRR i6, vLRC i7, +
           vFColor i8, vBColor i9
          IF vclscount >= 2 THEN
            BREAK
          ENDIF
          IF vAction = 'CLS' THEN
            SET VAR vclscount = (.vclscount + 1)
          ENDIF
        ENDWHILE
        BREAK

      CASE [PgDn]
        SET VAR vclscount = 0
        WHILE sqlcode = 0 THEN
          FETCH NEXT FROM c1 INTO +
           vFrame i1, vAction i2, vWords i3,+
           vULR i4, vULC i5, vLRR i6, vLRC i7, +
           vFColor i8, vBColor i9
          IF vAction = 'CLS' THEN
            FETCH PRIOR FROM c1 INTO +
             vFrame i1, vAction i2, vWords i3,+
             vULR i4, vULC i5, vLRR i6, vLRC i7, +
             vFColor i8, vBColor i9
            BREAK
          ENDIF
        ENDWHILE
        BREAK

      CASE [Alt][F1]
          SET KEYMAP [Alt][F2] = 'run talk.rmd[enter]'
          SNAP resume.scn FROM 1,1 TO 25,80
          SET VAR vresume = .vFrame
          QUIT
        DEFAULT
        BREAK

      ENDSW
      BREAK

    CASE RUN

      IF vkey <> '[F2]' THEN

        SNAP resume.scn FROM 1,1 TO 25,80
        SET VAR vresume = .vFrame
        QUIT TO .vWords

      ENDIF
      BREAK

    ENDSW

  ELSE

    IF vFrame > .vresume THEN
      SET VAR vresume = 0
      DISPLAY resume.scn AT 1,1
      ERASE resume.scn
    ENDIF

  ENDIF

  FETCH NEXT FROM c1 INTO +
   vFrame i1, vAction i2, vWords i3,+
   vULR i4, vULC i5, vLRR i6, vLRC i7, +
   vFColor i8, vBColor i9

ENDWHILE
CLOSE c1
DROP CURSOR c1
SET VAR vlastcls = 0
CLS
SET MESSAGE ON
RETURN


