q command on

;  This adv-tel also supports 4 sessions - SPM 
; This command file gives full-screen StateSave when moving between
; TelnetManager sessions.  Copy it into your Advanced Telnet directory.

; In your AUTOEXEC.BAT, Create a DOS environment variable TMS pointing
; to where you want the StateSave files written.
;            e.g.     SET TMS=C:\REFLECT

;  Load ADV-TEL /Z  (along with any other switches you use.)
;
;    Note:  ***** REQUIRES TELNET MANAGER Beta v2.12 OR GREATER *****

; NOTES:
; You can run a command file within a session as long as it doesn't
; use V8 or V9.
; Each session screen is saved in a file  TM<n>.STA  where <n> = session #
; V1 contains the session number
; V2 contains the function being performed on that session.
; V8 is a flag.  The previous session is saved only if V8 = "save"
; V9 contains the previous session number.

   continue on
   set literal-escape "~"
; Get the environment variable for where to write StateSave files, and
; append a "\" if not already there
   let v7 = env("TMS")
   if not mid(v7,length(v7),length(v7)) = "\"
      let v7 = v7 & "\"
   endif
   goto $2
   goto End

:Connecting
:Disconnected
   display "^m^jSession #$1: $2 $3 $4 $5 $6 ^m^j"
   del $7tm$1.sta
   let v8 = ""
   goto End

:Suspending
  ;XOFF the host
  ;transmit "^s"
   stsave $7tm$1.sta delete
 ;This turns off ReGIS in R4, ClearScreen for R2/4 and R1/7
   display "^[[>99l ^[[H^[[2J ^[H^[J^m^jSession #$1: $2 $3 $4 $5 $6 ^m^j"
   let v8 = ""
   goto End

:Resuming
   if v8 = "save" or not exist("$7tm$9.sta")
      ;XOFF the host
      ;transmit "^s"
       stsave $7tm$9.sta delete
   endif
   stload $7tm$1.sta
  ;XON the host
  ;transmit "^q"
   del    $7tm$1.sta
   let v8 = "save"

:End
   let v9 = v1
   continue off
   q command off
