;*Demo of Telnet SET/FETCH commands          v1.00

;*****************************************************************************
;* Written by:  Symantec ASPECT Assist                                       *
;*                                                                           *                                                                             
;* This script file will give the user the option of either capturing data   *
;* in half hour increments, or in 24 hour increments. The Capture file will  *
;* close after a predefined period of inactivity on the port.                *
;*                                                                           *
;* This ASPECT script is intended only as a sample of ASPECT programming.    *
;* Symantec makes no warranty of any kind, express or implied, including     *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*                                                                           *
;* Technical Support is not provided on this script.                         *                                                                          *
;*****************************************************************************


;*****************************************************************************
;*   GLOBAL VARIABLES                                                        *
;*****************************************************************************
string szSetXwindow
string szSetBaudrate
integer nzSet1
integer nzSet2
integer nzSet3
integer nzSet4
integer nzSet5
long nzSetBaudrate

;*****************************************************************************
;*                                                                           *
;* MAIN                                                                      *
;* Calls: windisplaysub, getinfosub, and dialogsub                           *
;* Modifies globals: None                                                    *                                                                          *
;*                                                                           *
;*****************************************************************************
proc main
   
   when dialog 0 call changeinfosub
   when userexit call cleanupsub
   
   windisplaysub ()
   getinfosub ()
   dialogsub ()
   
endproc


;*****************************************************************************
;*                                                                           *
;* GETINFOSUB ()                                                             *
;* The procedure getinfosub collects all of the Telnet                       *
;*                                                                           *
;* Calls:                                                                    *
;* Called by: Main, WhateverElse                                             *
;* Modifies globals: Var1                                                    *
;*                                                                           *
;*****************************************************************************
proc getinfosub

   fetch TELNET autologon nzSet1
   fetch TELNET binarymode nzSet2
   fetch TELNET negotiation nzSet3
   fetch TELNET terminal type nzSet4
   fetch TELNET terminal size nzSet5
   fetch TELNET xwindow szSetXwindow
   fetch TELNET baudrate nzSetBaudrate 

   ltoa nzSetBaudrate szSetBaudrate

   if nzSetBaudrate == 0
      szSetBaudrate = "Disabled"
   endif
   if nullstr szSetXwindow
      szSetXwindow = "Disabled"
   endif
   
   if nzSet3 == 1
      nzSet3 = 0
   else
      nzSet3 = 1
   endif   

endproc



;*****************************************************************************
;*                                                                           *
;* DIALOGSUB ()                                                              *
;* The procedure dialogsub has several checkboxes to set different telnet    *
;* setup options. By choosing an option and clicking ENTER will update the   *
;* settings in the OPTIONS | TELNET OPTIONS, window                          *
;*                                                                           *
;* Calls: WHEN event in main                                                 *
;* Called by: main                                                           *
;* Modifies globals: None                                                    *
;*                                                                           *
;*****************************************************************************
proc dialogsub

   dialogbox 0 110 26 226 180 67 "Telnet SET/FETCH Options" 
      checkbox 11 54 12 118 11 "Telnet Autologon  OFF | ON" nzSet1
      checkbox 12 54 32 118 11 "Telnet Binarymode   OFF | ON" nzSet2
      checkbox 13 54 52 118 11 "Telnet Negotiation OFF | ON" nzSet3
      checkbox 14 54 90 118 11 "Telnet Terminal Type OFF | ON" nzSet4
      checkbox 15 54 71 118 11 "Telnet Terminal Size OFF | ON" nzSet5
      editbox 16 103 113 109 11 szSetXwindow 
      editbox 17 103 129 109 11 szSetBaudrate 
      pushbutton 21 34 156 72 13 "ENTER" OK 
      pushbutton 22 120 156 72 13 "CANCEL" CANCEL 
      text 6 14 113 74 11 "Telnet  xwindow string" left 
      text 7 14 129 72 11 "Telnet Baudrate" left
     enddialog 

endproc



;*****************************************************************************
;*                                                                           *
;* CHANGEINFOSUB ()                                                          *
;* The procedure changeinfosub catches the dialog event                      *
;*                                                                           *
;* Calls: main, cleanupsub                                                   *
;* Called by: main                                                           *
;* Modifies globals: None                                                    *
;*                                                                           *
;*****************************************************************************
proc changeinfosub

integer catchevent0

   dlgevent 0 catchevent0
   
   switch catchevent0
      case 21
         if nzSet1 == 1
            set TELNET autologon ON   
         else 
            set TELNET autologon OFF
         endif
         if nzSet2 == 1
            set TELNET binarymode ON
         else
            set TELNET binarymode OFF
         endif
         if nzSet3 == 0
            set TELNET negotiation ON
         else 
            set TELNET negotiation OFF
         endif
         if nzSet4 == 1
            set TELNET terminal type ON
         else
            set TELNET terminal type OFF
         endif
         if nzSet5 == 1
            set TELNET terminal size ON
         else
            set TELNET terminal size OFF
         endif
         
         atol szSetBaudrate nzSetBaudrate
         
         set TELNET baudrate nzSetBaudrate
         set TELNET xwindow szSetXwindow
      
         call main
                  
      endcase
      case 22
         call cleanupsub
      endcase
   endswitch    

endproc



;*****************************************************************************
;*                                                                           *
;* WINDISPLAYSUB ()                                                          *
;* The procedure windisplaysub opens the Telnet setup window to display      *
;* settings.  Options | Telnet Options                                       *
;*                                                                           *
;* Calls: None                                                               *
;* Called by: main                                                           *
;* Modifies globals: None                                                    *
;*                                                                           *
;*****************************************************************************
proc windisplaysub

   termkey ALT 'O'
   mspause 250 
   termkey 'E'
   pause 6
   sendkey ALT 'O'   

endproc



;*****************************************************************************
;*                                                                           *
;* CLEANUPSUB ()                                                             *
;* The procedure cleanupsub exits all dialog boxes then exits the script.    *
;*                                                                           *
;* Calls: None                                                               *
;* Called by: main, changeinfosub                                            *
;* Modifies globals: None                                                    *
;*                                                                           *
;*****************************************************************************
proc cleanupsub

   exit
   
endproc

