home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / WINWAIS / VB / TELNET.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-02-13  |  24.6 KB  |  908 lines

  1. VERSION 2.00
  2. Begin Form telnet_form 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Telnet"
  6.    ClientHeight    =   4020
  7.    ClientLeft      =   1380
  8.    ClientTop       =   2580
  9.    ClientWidth     =   6135
  10.    DrawMode        =   16  'Whiteness
  11.    FontBold        =   0   'False
  12.    FontItalic      =   0   'False
  13.    FontName        =   "Host Presenter"
  14.    FontSize        =   9
  15.    FontStrikethru  =   0   'False
  16.    FontUnderline   =   0   'False
  17.    Height          =   4710
  18.    Left            =   1320
  19.    LinkMode        =   1  'Source
  20.    LinkTopic       =   "Form1"
  21.    MaxButton       =   0   'False
  22.    MinButton       =   0   'False
  23.    ScaleHeight     =   4020
  24.    ScaleWidth      =   6135
  25.    Top             =   1950
  26.    Width           =   6255
  27.    Begin WinSock WinSock1 
  28.       Client_or_Server=   0  'Client
  29.       Interval        =   0
  30.       IPName          =   ""
  31.       Left            =   600
  32.       LicDate         =   0
  33.       License1        =   ""
  34.       License2        =   ""
  35.       Licensed        =   0
  36.       Linger          =   0   'False
  37.       Port            =   0
  38.       RecvBufSize     =   0
  39.       SendBufSize     =   0
  40.       Top             =   60
  41.    End
  42.    Begin Timer cursor_timer 
  43.       Interval        =   300
  44.       Left            =   90
  45.       Top             =   60
  46.    End
  47.    Begin Menu telnet_file_menu 
  48.       Caption         =   "&File"
  49.       Begin Menu menu_connect 
  50.          Caption         =   "&Connect"
  51.       End
  52.       Begin Menu menu_disconnect 
  53.          Caption         =   "&Disconnect"
  54.       End
  55.       Begin Menu menu_exit 
  56.          Caption         =   "&Exit"
  57.       End
  58.    End
  59.    Begin Menu font_menu 
  60.       Caption         =   "Fonts"
  61.       Begin Menu font_7_menu 
  62.          Caption         =   "7 Point"
  63.          Checked         =   -1  'True
  64.       End
  65.       Begin Menu font_9_menu 
  66.          Caption         =   "9 Point"
  67.       End
  68.    End
  69. Dim insert_mode As Integer
  70. Dim parm(9) As Integer
  71. Dim pno As Integer
  72. Dim row As Integer
  73. Dim col As Integer
  74. Dim save_row As Integer
  75. Dim save_col As Integer
  76. Dim comm_buffer(23) As String * 80
  77. Dim control_on As Integer
  78. Dim cursor_is_on As Integer
  79. Dim tabno As Integer
  80. Dim tab_table(20) As Integer
  81. Dim txth As Integer
  82. Dim txtw As Integer
  83. Dim graphics As Integer
  84. Dim graph_chars As String
  85. Dim attributes As Integer
  86. Const ATTR_BOLD = 1
  87. Const ATTR_REVERSE = 2
  88. Dim parsedata(10) As Integer
  89. Dim ppno As Integer
  90. Dim sw_ugoahead As Integer
  91. Dim sw_igoahead As Integer
  92. Dim sw_echo As Integer
  93. Dim sw_linemode As Integer
  94. Dim sw_termsent As Integer
  95. Dim substate As Integer
  96. Const GO_NORM = 0
  97. Const GO_ESC1 = 1
  98. Const GO_ESC2 = 2
  99. Const GO_ESC3 = 3
  100. Const GO_ESC4 = 4
  101. Const GO_ESC5 = 5
  102. Const GO_IAC1 = 6
  103. Const GO_IAC2 = 7
  104. Const GO_IAC3 = 8
  105. Const GO_IAC4 = 9
  106. Const GO_IAC5 = 10
  107. Const GO_IAC6 = 11
  108. Const SUSP = 237
  109. Const ABORT = 238
  110. Const SE = 240
  111. Const NOP = 241
  112. Const DM = 242
  113. Const break = 243
  114. Const IP = 244
  115. Const AO = 245
  116. Const AYT = 246
  117. Const EC = 247
  118. Const EL = 248
  119. Const GOAHEAD = 249
  120. Const SB = 250
  121. Const WILLTEL = 251
  122. Const WONTTEL = 252
  123. Const DOTEL = 253
  124. Const DONTTEL = 254
  125. Const IAC = 255
  126. 'Const BINARY = 0
  127. Const ECHO = 1
  128. Const RECONNECT = 2
  129. Const SGA = 3
  130. Const AMSN = 4
  131. Const STATUS = 5
  132. Const TIMING = 6
  133. Const RCTAN = 7
  134. Const OLW = 8
  135. Const OPS = 9
  136. Const OCRD = 10
  137. Const OHTS = 11
  138. Const OHTD = 12
  139. Const OFFD = 13
  140. Const OVTS = 14
  141. Const OVTD = 15
  142. Const OLFD = 16
  143. Const XASCII = 17
  144. Const LOGOUT = 18
  145. Const BYTEM = 19
  146. Const DET = 20
  147. Const SUPDUP = 21
  148. Const SUPDUPOUT = 22
  149. Const SENDLOC = 23
  150. Const TERMTYPE = 24
  151. Const EOR = 25
  152. Const TACACSUID = 26
  153. Const OUTPUTMARK = 27
  154. Const TERMLOCNUM = 28
  155. Const REGIME3270 = 29
  156. Const X3PAD = 30
  157. Const NAWS = 31
  158. Const TERMSPEED = 32
  159. Const TFLOWCNTRL = 33
  160. Const LINEMODE = 34
  161.                            
  162. Const MODE = 1
  163. 'Const EDIT = 1
  164. Const TRAPSIG = 2
  165. Const MODE_ACK = 4
  166. Const SOFT_TAB = 8
  167. Const LIT_ECHO = 16
  168. Const FORWARDMASK = 2
  169. Const SLC = 3
  170. Const NO_SUPPORT = 0
  171. Const CANTCHANGE = 1
  172. Const SLC_VALUE = 2
  173. Const SLC_DEFAULT = 3
  174. Const SLC_LEVELBITS = 3
  175. Const SLC_ACK = 128
  176. Const SLC_SYNCH = 1
  177. Const SLC_BRK = 2
  178. Const SLC_IP = 3
  179. Const SLC_AO = 4
  180. Const SLC_AYT = 5
  181. Const SLC_EOR = 6
  182. Const SLC_ABORT = 7
  183. Const SLC_EOF = 8
  184. Const SLC_SUSP = 9
  185. Const SLC_EC = 10
  186. Const SLC_EL = 11
  187. Const SLC_EW = 12
  188. Const SLC_RP = 13
  189. Const SLC_LNEXT = 14
  190. Const SLC_XON = 15
  191. Const SLC_XOFF = 16
  192. Const SLC_FORW1 = 17
  193. Const SLC_FORW2 = 18
  194. Const SLC_MCL = 19
  195. Const SLC_MCR = 20
  196. Const SLC_MCWL = 21
  197. Const SLC_MCWR = 22
  198. Const SLC_MCBOL = 23
  199. Const SLC_MCEOL = 24
  200. Const SLC_INSRT = 25
  201. Const SLC_OVER = 26
  202. Const SLC_ECR = 27
  203. Const SLC_EWR = 28
  204. Const SLC_EBOL = 29
  205. Const SLC_EEOL = 30
  206. Const XDISPLOC = 35
  207. Const XOPTIONS = 255
  208. Const Negotiate = 1
  209. ' Key Codes
  210. Const KEY_LBUTTON = &H1
  211. Const KEY_RBUTTON = &H2
  212. Const KEY_CANCEL = &H3
  213. Const KEY_MBUTTON = &H4    ' NOT contiguous with L & RBUTTON
  214. Const KEY_BACK = &H8
  215. Const KEY_TAB = &H9
  216. Const KEY_CLEAR = &HC
  217. Const KEY_RETURN = &HD
  218. Const KEY_SHIFT = &H10
  219. Const KEY_CONTROL = &H11
  220. Const KEY_MENU = &H12
  221. Const KEY_PAUSE = &H13
  222. Const KEY_CAPITAL = &H14
  223. Const KEY_ESCAPE = &H1B
  224. Const KEY_SPACE = &H20
  225. Const KEY_PRIOR = &H21
  226. Const KEY_NEXT = &H22
  227. Const KEY_END = &H23
  228. Const KEY_HOME = &H24
  229. Const KEY_LEFT = &H25
  230. Const KEY_UP = &H26
  231. Const KEY_RIGHT = &H27
  232. Const KEY_DOWN = &H28
  233. Const KEY_SELECT = &H29
  234. Const KEY_PRINT = &H2A
  235. Const KEY_EXECUTE = &H2B
  236. Const KEY_SNAPSHOT = &H2C
  237. Const KEY_INSERT = &H2D
  238. Const KEY_DELETE = &H2E
  239. Const KEY_HELP = &H2F
  240. ' KEY_A thru KEY_Z are the same as their ASCII equivalents: 'A' thru 'Z'
  241. ' KEY_0 thru KEY_9 are the same as their ASCII equivalents: '0' thru '9'
  242. Const KEY_NUMPAD0 = &H60
  243. Const KEY_NUMPAD1 = &H61
  244. Const KEY_NUMPAD2 = &H62
  245. Const KEY_NUMPAD3 = &H63
  246. Const KEY_NUMPAD4 = &H64
  247. Const KEY_NUMPAD5 = &H65
  248. Const KEY_NUMPAD6 = &H66
  249. Const KEY_NUMPAD7 = &H67
  250. Const KEY_NUMPAD8 = &H68
  251. Const KEY_NUMPAD9 = &H69
  252. Const KEY_MULTIPLY = &H6A
  253. Const KEY_ADD = &H6B
  254. Const KEY_SEPARATOR = &H6C
  255. Const KEY_SUBTRACT = &H6D
  256. Const KEY_DECIMAL = &H6E
  257. Const KEY_DIVIDE = &H6F
  258. Const KEY_F1 = &H70
  259. Const KEY_F2 = &H71
  260. Const KEY_F3 = &H72
  261. Const KEY_F4 = &H73
  262. Const KEY_F5 = &H74
  263. Const KEY_F6 = &H75
  264. Const KEY_F7 = &H76
  265. Const KEY_F8 = &H77
  266. Const KEY_F9 = &H78
  267. Const KEY_F10 = &H79
  268. Const KEY_F11 = &H7A
  269. Const KEY_F12 = &H7B
  270. Const KEY_F13 = &H7C
  271. Const KEY_F14 = &H7D
  272. Const KEY_F15 = &H7E
  273. Const KEY_F16 = &H7F
  274. Const KEY_NUMLOCK = &H90
  275. Sub cursor_timer_Timer ()
  276.   draw_cursor
  277. End Sub
  278. Sub draw_cursor ()
  279. Dim x As Integer
  280. Dim y As Integer
  281.     If cursor_is_on Then
  282.       cursor_is_on = False
  283.     Else
  284.       cursor_is_on = True
  285.     End If
  286.       
  287.     If cursor_is_on Then
  288.       x = col * txtw
  289.       y = row * txth
  290.       telnet_form.DrawMode = 6
  291.       telnet_form.Line (x, y)-(x + txtw, y + txth), , BF
  292.       telnet_form.DrawMode = 16
  293.     End If
  294. End Sub
  295. Function esc1 (ch As String) As Integer
  296.   esc1 = GO_NORM             ' default return value is normal character
  297.   Select Case ch
  298.     Case Chr$(8)             ' embedded backspace
  299.       col = col - 1
  300.     Case "7"                 ' save cursor
  301.       save_row = row
  302.       save_col = col
  303.     Case "8"                 ' restore cursor
  304.       row = save_row
  305.       col = save_col
  306.     Case "c"                 ' look at VSIreset()
  307.     Case "D"                 ' cursor down
  308.       row = row + 1
  309.     Case "E"                 ' next line
  310.       row = row + 1
  311.       col = 0
  312.     Case "H"                 ' set tab
  313.       tab_table(tabno) = col
  314.       tabno = tabno + 1
  315.     Case "I"                 ' look at bp_ESC_I()
  316.     Case "M"                 ' cursor up
  317.       row = row - 1
  318.     Case "Z"                 ' send ident
  319.     Case "["                 ' requires further processing
  320.       Erase parm
  321.       pno = 0
  322.       esc1 = GO_ESC2
  323.     Case ">"                 ' DECPAM off
  324.     Case "="                 ' DECPAM on
  325.     Case "#"                 ' requires further processing
  326.       Erase parm
  327.       pno = 0
  328.       esc1 = GO_ESC3
  329.     Case "("                 ' requires further processing
  330.       Erase parm
  331.       pno = 0
  332.       esc1 = GO_ESC4
  333.     Case ")"                 ' requires further processing
  334.       Erase parm
  335.       pno = 0
  336.       esc1 = GO_ESC5
  337.   End Select
  338. End Function
  339. Function esc2 (ch As String) As Integer
  340.   ' handle ESC [ sequences
  341.   esc2 = GO_NORM
  342.   Select Case ch
  343.     Case Chr$(8)             ' backspace
  344.       col = col - 1
  345.       esc2 = GO_ESC2
  346.     Case "0" To "9"          ' numeric parameters
  347.       parm(pno) = parm(pno) * 10 + Val(ch$)
  348.       esc2 = GO_ESC2
  349.     Case "?"                 ' default (no) parameter
  350.       parm(pno) = -2
  351.       pno = pno + 1
  352.       esc2 = GO_ESC2
  353.     Case ";"                 ' parameter separator
  354.       pno = pno + 1
  355.       esc2 = GO_ESC2
  356.     Case "A"                 ' cursor back n rows
  357.       If parm(0) < 1 Then
  358.          row = row - 1
  359.       Else
  360.         row = row - parm(0)
  361.       End If
  362.     Case "B"                 ' cursor forward n rows
  363.       If parm(0) < 1 Then
  364.         row = row + 1
  365.       Else
  366.         row = row + parm(0)
  367.       End If
  368.     Case "C"                 ' cursor forward n cols
  369.       If parm(0) < 1 Then
  370.         col = col + 1
  371.       Else
  372.         col = col + parm(0)
  373.       End If
  374.     Case "D"                 ' cursor back n columns
  375.       If parm(0) < 1 Then
  376.         col = col - 1
  377.       Else
  378.         col = col - parm(0)
  379.       End If
  380.     Case "H"                 ' set cursor address
  381.       row = parm(0) - 1
  382.       col = parm(1) - 1
  383.     Case "J"
  384.       test_bounds
  385.       Select Case parm(0)
  386.         Case -1, 0           ' erase from cursor to end of screen
  387.           telnet_form.Line (col * txtw, row * txth)-(telnet_form.Width, (row + 1) * txth), , BF
  388.           telnet_form.Line (0, (row + 1) * txth)-(telnet_form.Width, telnet_form.Height), , BF
  389.           comm_buffer(row) = Left$(comm_buffer(row), col)
  390.           For y = row + 1 To 23
  391.             comm_buffer(y) = ""
  392.           Next y
  393.         Case 1               ' erase from screen begin to cursor
  394.           telnet_form.Line (0, 0)-(telnet_form.Width, row * txth), , BF
  395.           telnet_form.Line (0, row * txth)-(col * txtw, (row + 1) * txth), , BF
  396.           comm_buffer(row) = Space$(col) + Right$(comm_buffer(row), Len(comm_buffer(row)) - col)
  397.           For y = 0 To row - 1
  398.             comm_buffer(y) = ""
  399.           Next y
  400.         Case 2               ' erase entire screen
  401.           telnet_form.Cls
  402.           For y = 0 To 23
  403.             comm_buffer(y) = ""
  404.           Next y
  405.       End Select
  406.     Case "K"
  407.       test_bounds
  408.       Select Case parm(0)
  409.         Case -1, 0           ' erase from cursor to end of line
  410.           telnet_form.Line (col * txtw, row * txth)-(telnet_form.Width, (row + 1) * txth), , BF
  411.           comm_buffer(row) = Left$(comm_buffer(row), col)
  412.         Case 1               ' erase from begin of line to cursor
  413.           telnet_form.Line (0, row * txth)-((col + 1) * txtw, (row + 1) * txth), , BF
  414.           comm_buffer(row) = Space$(col) + Right$(comm_buffer(row), Len(comm_buffer(row)) - col)
  415.         Case 2               ' erase entire line
  416.           telnet_form.Line (0, row * txth)-(Width, (row + 1) * txth), , BF
  417.           comm_buffer(row) = ""
  418.       End Select
  419.     Case "L"                 ' insert lines
  420.     Case "M"                 ' delete lines
  421.     Case "P"                 ' delete characters
  422.     Case "c"                 ' look at VTsendident()
  423.     Case "f"
  424.       row = parm(0) - 1
  425.       col = parm(1) - 1
  426.     Case "g"                 ' clear tabs
  427.     Case "h"                 ' look at VSIsetoption(1)
  428.     Case "i"                 ' print though mode
  429.     Case "l"                 ' look at VSIsetoption(0)
  430.     Case "m"
  431.       For y = 0 To pno
  432.         Select Case parm(y)
  433.           Case Is < 1       ' reset attributes
  434.             attributes = 0
  435.           Case 1            ' bold
  436.             attributes = attributes Or ATTR_BOLD
  437.           Case 4            ' underline
  438.           Case 5            ' blink
  439.           Case 6            ' blink
  440.           Case 7            ' reverse
  441.             attributes = attributes Or ATTR_REVERSE
  442.         End Select
  443.       Next y
  444.     Case "n"
  445.       Select Case parm(0)
  446.         Case 5               ' look at VTsendstat()
  447.         Case 6               ' look at VTsendpos
  448.       End Select
  449.     Case "q"
  450.     Case "r"                 ' set window bounds (top, bottom)
  451.   End Select
  452. End Function
  453. Function esc3 (ch As String) As Integer
  454.   ' handle ESC # sequences
  455.   esc3 = GO_NORM
  456.   Select Case ch
  457.     Case Chr$(8)
  458.       col = col - 1
  459.       esc3 = GO_ESC3
  460.     Case "8"                 ' look at VTalign()
  461.   End Select
  462. End Function
  463. Function esc4 (ch As String) As Integer
  464.   ' handle ESC ( sequences
  465.   esc4 = GO_NORM
  466.   Select Case ch
  467.     Case Chr$(8)
  468.       col = col - 1
  469.       esc4 = GO_ESC4
  470.     Case "A", "B", "1"       ' select text character set
  471.       graphics = False
  472.     Case "0", "2"            ' select graphic character set
  473.       graphics = True
  474.   End Select
  475. End Function
  476. Function esc5 (ch As String) As Integer
  477.   ' handle ESC ) sequences
  478.   esc5 = GO_NORM
  479.   Select Case ch
  480.     Case Chr$(8)
  481.       col = col - 1
  482.       esc5 = GO_ESC5
  483.     Case "A", "B", "1"       ' select text character set
  484.       graphics = False
  485.     Case "0", "2"            ' select graphic character set
  486.       graphics = True
  487.   End Select
  488. End Function
  489. Sub font_7_menu_Click ()
  490.   telnet_form.FontSize = 7.5
  491.   font_7_menu.Checked = True
  492.   font_9_menu.Checked = False
  493.   txth = telnet_form.TextHeight("A")
  494.   txtw = telnet_form.TextWidth("A")
  495.   telnet_form.Height = txth * 30
  496.   telnet_form.Width = txtw * 82
  497.   telnet_form.Left = 500
  498.   telnet_form.Top = 500
  499. End Sub
  500. Sub font_9_menu_Click ()
  501.   telnet_form.FontSize = 9
  502.   font_7_menu.Checked = False
  503.   font_9_menu.Checked = True
  504.   txth = telnet_form.TextHeight("A")
  505.   txtw = telnet_form.TextWidth("A")
  506.   telnet_form.Height = txth * 30
  507.   telnet_form.Width = txtw * 82
  508.   telnet_form.Left = 0
  509.   telnet_form.Top = 0
  510. End Sub
  511. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  512.   Dim ch As String
  513.   ch = Chr$(0)
  514.   Select Case KeyCode
  515.     Case KEY_RETURN
  516.       cursor_timer.Enabled = False
  517.       x = col * txtw
  518.       y = row * txth
  519.       DrawMode = 16
  520.       Line (x, y)-(x + txtw, y + txth), , BF
  521.     Case KEY_CONTROL
  522.       control_on = True
  523.     Case KEY_END
  524.       ch = Chr$(27) + "[K"
  525.     Case KEY_HOME
  526.       ch = Chr$(27) + "[H"
  527.     Case KEY_LEFT
  528.       ch = Chr$(27) + "[D"
  529.     Case KEY_UP
  530.       ch = Chr$(27) + "[A"
  531.     Case KEY_RIGHT
  532.       ch = Chr$(27) + "[C"
  533.     Case KEY_DOWN
  534.       ch = Chr$(27) + "[B"
  535.     Case KEY_F1
  536.       ch = Chr$(27) + "OP"
  537.     Case KEY_F2
  538.       ch = Chr$(27) + "OQ"
  539.     Case KEY_F3
  540.       ch = Chr$(27) + "OR"
  541.     Case KEY_F4
  542.       ch = Chr$(27) + "OS"
  543.     Case Else
  544.       If control_on And KeyCode > 63 Then
  545.         ch = Chr$(KeyCode - 64)
  546.       End If
  547.   End Select
  548.   If ch > Chr$(0) And WinSock1.Open Then
  549.     WinSock1.Send = ch
  550.   End If
  551. End Sub
  552. Sub Form_KeyPress (KeyAscii As Integer)
  553. Dim ch As String
  554.   ch = Chr$(KeyAscii)
  555.   If control_on Then
  556.     If KeyAscii > 63 Then
  557.       ch = Chr$(KeyAscii - 64)
  558.     Else
  559.       ch = Chr$(0)
  560.     End If
  561.   End If
  562.   If ch > Chr$(0) And WinSock1.Open Then
  563.     WinSock1.Send = ch
  564.   End If
  565. End Sub
  566. Sub Form_KeyUp (KeyCode As Integer, Shift As Integer)
  567.     Select Case KeyCode
  568.       Case KEY_CONTROL
  569.         control_on = False
  570.     End Select
  571. End Sub
  572. Sub Form_Load ()
  573.     'telnet_form.windowstate = MAXIMIZED
  574.      
  575.     cursor_timer.Enabled = False
  576.     telnet_form.FontSize = 7.5
  577.     font_7_menu.Checked = True
  578.     font_9_menu.Checked = False
  579.     txth = telnet_form.TextHeight("A")
  580.     txtw = telnet_form.TextWidth("A")
  581.     telnet_form.Left = 500
  582.     telnet_form.Top = 500
  583.     telnet_form.Height = txth * 30
  584.     telnet_form.Width = txtw * 82
  585.     row = 0
  586.     col = 0
  587.     save_row = 0
  588.     save_col = 0
  589.     tabno = 0
  590.     graphics = False
  591.     sw_echo = True
  592.     For x = 0 To 23
  593.       comm_buffer(x) = ""
  594.     Next x
  595.     For x = 0 To 19
  596.       tab_table(x) = 0
  597.     Next x
  598.     graph_chars = "ABCDEFGHI" + Chr$(217) + Chr$(191) + Chr$(218) + Chr$(192) + "NOP" + Chr$(196) + "RSTUVW" + Chr$(179) + "YZ"
  599.     If Command$ = "" Then
  600.       menu_connect_click
  601.     Else
  602.       WinSock1.IPName = Trim$(Command$)
  603.       WinSock1.Port = 23
  604.       WinSock1.Open = True
  605.       msg$ = Chr$(IAC) + Chr$(DOTEL) + Chr$(ECHO)
  606.       msg$ = msg$ + Chr$(IAC) + Chr$(DOTEL) + Chr$(SGA)
  607.       msg$ = msg$ + Chr$(IAC) + Chr$(WILLTEL) + Chr$(NAWS)
  608.       WinSock1.Send = msg$
  609.       menu_connect.Enabled = False
  610.     End If
  611. End Sub
  612. Sub Form_Unload (Cancel As Integer)
  613.   If WinSock1.Open = True Then
  614.     WinSock1.Open = False
  615.   End If
  616. End Sub
  617. Function iac1 (ch As String) As Integer
  618.       
  619.   iac1 = GO_NORM
  620.   Select Case Asc(ch)
  621.     Case DOTEL
  622.       Debug.Print "DO ";
  623.       iac1 = GO_IAC2
  624.     Case DONTTEL
  625.       Debug.Print "DONT "
  626.     Case WILLTEL
  627.       Debug.Print "WILL ";
  628.       iac1 = GO_IAC3
  629.     Case WONTTEL
  630.       Debug.Print "WONT ";
  631.       iac1 = GO_IAC4
  632.     Case SB
  633.       Debug.Print "SB ";
  634.       iac1 = GO_IAC5
  635.       pno = 0
  636.       substate = 0
  637.     Case SE
  638.       Debug.Print "SE "
  639.       ' End of negotiation string, string is in parsedata()
  640.       Select Case parsedata(0)
  641.         Case TERMTYPE
  642.           If parsedata(1) = 1 Then
  643.             Debug.Print "SENT: SB TERMTYPE VT100"
  644.             telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(SB) + Chr$(TERMTYPE) + "vt100" + Chr$(0) + Chr$(IAC) + Chr$(SE)
  645.           End If
  646.       End Select
  647.   End Select
  648. End Function
  649. Function iac2 (ch As String) As Integer
  650.       
  651.   'DO Processing
  652.   iac2 = GO_NORM
  653.   Select Case Asc(ch)
  654.     Case SGA
  655.       Debug.Print "SGA"
  656.       If Not sw_igoahead Then
  657.         telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(WILLTEL) + Chr$(SGA)
  658.         sw_igoahead = True
  659.       End If
  660.     Case TERMTYPE
  661.       Debug.Print "TERMTYPE"
  662.       If Not sw_termsent Then
  663.         sw_termsent = True
  664.         telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(WILLTEL) + Chr$(TERMTYPE)
  665.       End If
  666.     Case NAWS
  667.       Debug.Print "NAWS"
  668.       telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(SB) + Chr$(NAWS) + Chr$(0) + Chr$(80) + Chr$(0) + Chr$(24) + Chr$(IAC) + Chr$(SE)
  669.     Case Else
  670.       Debug.Print "OTHER"
  671.       telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(WONTTEL) + ch
  672.   End Select
  673. End Function
  674. Function iac3 (ch As String) As Integer
  675.       
  676.   ' WILL Processing
  677.   iac3 = GO_NORM
  678.       
  679.   Select Case Asc(ch)
  680.     Case SGA
  681.       Debug.Print "SGA"
  682.       If Not sw_ugoahead Then
  683.         sw_ugoahead = True
  684.         telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(DOTEL) + Chr$(SGA)
  685.         Debug.Print "SENT: DO SGA"
  686.       End If
  687.     Case ECHO
  688.       Debug.Print "ECHO"
  689.       If Not sw_echo Then
  690.         sw_echo = True
  691.         telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(DOTEL) + Chr$(ECHO)
  692.         Debug.Print "SENT: DO ECHO"
  693.       End If
  694.     Case TIMING
  695.       Debug.Print "TIMING"
  696.       sw_timing = 0
  697.     Case Else
  698.       Debug.Print "SENT:  DONT OTHER"
  699.       telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(DONTTEL) + ch
  700.   End Select
  701. End Function
  702. Function iac4 (ch As String) As Integer
  703.   ' WONT Processing
  704.   iac4 = GO_NORM
  705.   Select Case Asc(ch)
  706.     Case ECHO
  707.       Debug.Print "ECHO"
  708.       If sw_echo Then
  709.         sw_echo = False
  710.         telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(DONTTEL) + Chr$(ECHO)
  711.         Debug.Print "SENT: DONT ECHO"
  712.       End If
  713.     Case TIMING
  714.       Debug.Print "TIMING"
  715.       sw_timing = 0
  716.     Case Else
  717.       Debug.Print "SENT: DONT OTHER"
  718.       telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(DONT) + ch
  719.   End Select
  720. End Function
  721. Function iac5 (ch As String) As Integer
  722.   ' Collect parms after SB and until another IAC
  723.   ich = Asc(ch)
  724.   If ich = IAC Then
  725.     iac5 = GO_IAC1
  726.     Exit Function
  727.   End If
  728.   Debug.Print "SUBPARM ";
  729.   parsedata(ppno) = ich
  730.   ppno = ppno + 1
  731.   iac5 = GO_IAC5
  732. End Function
  733. Function iac6 (ch As String) As Integer
  734.   ' End of negotiation string, string is in parsedata()
  735.   Select Case parsedata(0)
  736.     Case TERMTYPE
  737.       If parsedata(1) = 1 Then
  738.         Debug.Print "SENT: SB TERMTYPE VT100"
  739.         telnet_form.WinSock1.Send = Chr$(IAC) + Chr$(SB) + Chr$(TERMTYPE) + "vt100" + Chr$(0) + Chr$(IAC) + Chr$(SE)
  740.       End If
  741.   End Select
  742. End Function
  743. Sub menu_connect_click ()
  744.   If WinSock1.Open = True Then
  745.     WinSock1.Open = False
  746.   End If
  747.   connect_form.Show 1
  748.   Unload connect_form
  749.   If WinSock1.IPName <> "" And WinSock1.Port <> 0 And WinSock1.Open = False Then
  750.     WinSock1.Open = True
  751.     msg$ = Chr$(IAC) + Chr$(DOTEL) + Chr$(ECHO)
  752.     msg$ = msg$ + Chr$(IAC) + Chr$(DOTEL) + Chr$(SGA)
  753.     msg$ = msg$ + Chr$(IAC) + Chr$(WILLTEL) + Chr$(NAWS)
  754.     WinSock1.Send = msg$
  755.     Debug.Print "SENT: DO ECHO"
  756.     Debug.Print "SENT: DO SGA"
  757.     Debug.Print "SENT: WILL NAWS"
  758.   End If
  759. End Sub
  760. Sub menu_disconnect_Click ()
  761.   If WinSock1.Open = True Then
  762.     WinSock1.Open = False
  763.     draw_cursor
  764.     menu_connect_click
  765.   End If
  766. End Sub
  767. Sub menu_exit_Click ()
  768.   If WinSock1.Open Then
  769.     WinSock1.Open = False
  770.   End If
  771.   End
  772. End Sub
  773. Function norm_char (ch As String) As Integer
  774. Dim ich As Integer
  775. Dim x As Integer
  776. Dim y As Integer
  777.   If ch < Chr$(32) Then
  778.     ich = Asc(ch)
  779.     Select Case ich
  780.       Case 7                 ' bell
  781.         Beep
  782.       Case 8                 ' backspace
  783.         col = col - 1
  784.       Case 9                 ' tab
  785.         For y = 0 To 19
  786.           If col < tab_table(y) Then
  787.             Exit For
  788.           End If
  789.         Next y
  790.         col = tab_table(y)
  791.       Case 10                ' line feed
  792.         row = row + 1
  793.       Case 11                ' vertical tab
  794.         row = row + 1
  795.       Case 12                ' form feed
  796.         row = row + 1
  797.       Case 13                ' carriage return
  798.         col = 0
  799.       Case 14                ' set graphics mode
  800.       Case 15                ' set character mode
  801.       Case 27
  802.         norm_char = GO_ESC1
  803.     End Select
  804.   ElseIf ch = Chr$(IAC) Then
  805.     norm_char = GO_IAC1
  806.   Else
  807.     test_bounds
  808.     If graphics Then
  809.       ch = Mid$(graph_chars, Asc(UCase$(ch)) - 64, 1)
  810.     End If
  811.       
  812.     x = col * txtw
  813.     y = row * txth
  814.     telnet_form.Line (x, y)-(x + txtw, y + txth), , BF
  815.     telnet_form.CurrentX = x
  816.     telnet_form.CurrentY = y
  817.     telnet_form.Print ch;
  818.       
  819.     If attributes And ATTR_BOLD Then
  820.       telnet_form.CurrentX = x + 8
  821.       telnet_form.CurrentY = y
  822.       telnet_form.Print ch;
  823.     End If
  824.       
  825.     If attributes And ATTR_REVERSE Then
  826.       telnet_form.CurrentX = x
  827.       telnet_form.CurrentY = y
  828.       telnet_form.DrawMode = 6
  829.       telnet_form.Line (x, y)-(x + txtw, y + txth), , BF
  830.       telnet_form.DrawMode = 16
  831.     End If
  832.       
  833.     Mid$(comm_buffer(row), col + 1, 1) = ch
  834.     col = col + 1
  835.       
  836.   End If
  837. End Function
  838. Sub test_bounds ()
  839. Dim y As Integer
  840.   If row < 0 Then
  841.     row = 0
  842.   End If
  843.   If col < 0 Then
  844.     col = 0
  845.   ElseIf col > 79 Then
  846.     col = 0
  847.     row = row + 1
  848.   End If
  849.   ' test for next row past the botton of the screen.  if it is
  850.   ' scroll the entire screen up one row.  this is a good place
  851.   ' to add logic for a scroll back buffer
  852.   If row > 23 Then
  853.     telnet_form.Cls
  854.     For row = 0 To 22
  855.       comm_buffer(row) = comm_buffer(row + 1)
  856.       blk$ = blk$ + comm_buffer(row) + Chr$(13) + Chr$(10)
  857.     Next row
  858.     telnet_form.Print blk$
  859.     comm_buffer(23) = ""
  860.     row = 23
  861.   End If
  862. End Sub
  863. Sub WinSock1_Recv ()
  864. Dim x As Integer
  865. Dim y As Integer
  866. Dim ch As String * 1
  867. Static cmd As Integer
  868.   cursor_timer.Enabled = False
  869.   x = col * txtw
  870.   y = row * txth
  871.   DrawMode = 16
  872.   Line (x, y)-(x + txtw, y + txth), , BF
  873.   msg$ = WinSock1.Recv
  874.   For x = 1 To Len(msg$)
  875.     ch = Mid$(msg$, x, 1)
  876.     Select Case cmd
  877.       Case GO_NORM
  878.         cmd = norm_char(ch)
  879.       Case GO_ESC1
  880.         cmd = esc1(ch)
  881.       Case GO_ESC2
  882.         cmd = esc2(ch)
  883.       Case GO_ESC3
  884.         cmd = esc3(ch)
  885.       Case GO_ESC4
  886.         cmd = esc4(ch)
  887.       Case GO_ESC5
  888.         cmd = esc5(ch)
  889.       
  890.       Case GO_IAC1
  891.         cmd = iac1(ch)
  892.       Case GO_IAC2
  893.         cmd = iac2(ch)
  894.       Case GO_IAC3
  895.         cmd = iac3(ch)
  896.       Case GO_IAC4
  897.         cmd = iac4(ch)
  898.       Case GO_IAC5
  899.         cmd = iac5(ch)
  900.       Case GO_IAC6
  901.         cmd = iac6(ch)
  902.       Case Else
  903.         MsgBox "Invalid 'next (" + Str$(cmd) + ")' processing routine in cmd loop"
  904.     End Select
  905.   Next x
  906.   cursor_timer.Enabled = True
  907. End Sub
  908.