home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / hp9816.zip / hpbasc.txt next >
Text File  |  1990-03-09  |  228KB  |  6,275 lines

  1. 1  !  RE-SAVE  "HPBASC"
  2. 3  !  KERMIT - Version 1.03
  3. 4  !  For Hewlett-Packard Co.
  4. 5  !  Family 9000 - Series 200/300
  5. 6  !  HP-BASIC (RMB) Workstations
  6. 7  !==================================================================
  7. 8  ! Revision History:
  8. 9  !------------------------------------------------------------------
  9. 10 ! Revision 1.03    -  Feb 20, 1990
  10. 11 ! Added Columbia University File Naming for HPB prefix
  11. 12 ! Transfer Status shown in STATUS command
  12. 13 ! Parity OFF Fixed (SET PARITY OFF)
  13. 14 ! Ksendf: changed IF R_capas=1 to Rcap_a=1 to shutoff A Packets
  14. 15 ! fixed SET SEND ATTRIBUTE OFF command, added send_at to COM decl
  15. 16 ! changed capas mask to 40 '(' from 42 '*' to eliminate long packets
  16. 17 !-------------------------------------------------------------------
  17. 18 ! Revision 1.03  -  Oct 11 1989
  18. 19 ! RPACK: Hardcoded Unchar Function to trap NUM("null") problem
  19. 20 ! Disabled Serial Port Interrupts - not really needed
  20. 21 ! Revised VT100 terminal escape processor
  21. 22 ! Added Client capability (GET Command)
  22. 23 ! Fixed Problem with the SET PARITY command not changing parity.
  23. 24 ! Fixed the SET DISPLAY 8/ON command to display non-printable
  24. 25 !  characters in the ranges 0-31, 128-256
  25. 26 ! Fixed Problem with MORE command printing to printer
  26. 27 ! Added xon/xoff flow to terminal emulator 'GET_INLENGTH' code
  27. 28 ! Added hardware xon/xoff to Sf28 (Set_frame on 98628)
  28. 29 ! Change Output Buffer to 1024b Input Buffer to 4096b
  29. 30 ! Added transfers shutdown in QUIT command
  30. 31 ! Added SET MARK command - to change 'start of packet' mark
  31. 32 ! Fixed SET SOURCE and SET DESTINATION Disc Drive Code
  32. 33 ! Add Newline toggle in Terminal Escape line
  33. 34 ! Fixed Terminal Session Logging
  34. 35 ! Grouped CSUBS at end of program code
  35. 36 ! Add VT100 APPL Mode Sequences for CTRL-0--9 keys
  36. 37 ! Add SET PARITY ON/OFF to disable parity CHECKING
  37. 38 !------------------------------------------------------------------
  38. 39 ! Revision 1.02  -  Apr 3 1989
  39. 40 ! Fixed prob with path msi$ not DIM long enough
  40. 41 ! removed pause when remote switch is set on serial card
  41. 42 ! removed trap preventing receive of PROG file type
  42. 43 ! added code to detect and ignore SRM interfaces
  43. 44 ! added ability to specify any filetype in CONVERT command
  44. 45 !------------------------------------------------------------------
  45. 46 ! Revision 1.01  -  Mar 20 1989
  46. 47 ! Two errors in Kreceive decoding &#& and &## Binary Sequences
  47. 48 ! Implemented PROG file transfers
  48. 49 ! Problem with modem disconnecting before Send or Receive
  49. 50 ! Trap for no serial ports found
  50. 51 ! Terminal leaving stray cursors on screen
  51. 52 ! Error Check on remote S packet - non-numeric sent for blk chk type
  52. 53 !------------------------------------------------------------------
  53. 54 ! Revision 1.0
  54. 55 ! Original Release Mar 1 1989
  55. 56 !==========================================================================
  56. 57 !  To obtain a copy of this software contact:
  57. 58 !
  58. 59 !  |  KERMIT Distributon
  59. 60 !  |  Columbia University
  60. 61 !  |  Center For Computing Activities
  61. 62 !  |  612 W. 115 St.
  62. 63 !  |  New York, N.Y.     10025
  63. 64 ! or
  64. 65 !  |  INTEREX - HP Users Group (Requires Membership)
  65. 66 !  |  680 Almanor Ave
  66. 67 !  |  Sunnyvale, CA.   94086-3513
  67. 68 !-----------------------------------------------
  68. 69 ! Written By:
  69. 70 ! Andrew Campagnola
  70. 71 ! Hewlett-Packard Co.
  71. 72 ! Mesurement Systems Operation
  72. 73 ! P.O. Box 301
  73. 74 ! Loveland, Colorado  80539-0301
  74. 75 !
  75. 76 ! You're encouraged to write with comments, suggestions,
  76. 77 ! and bug reports.
  77. 78 !==========================================================================
  78. 79  ! KERMIT   Copyright (C) 1981,1988
  79. 80  ! Trustees of Columbia University, New York City, N.Y.
  80. 81  ! Permission is granted to any individual or institution to use, copy or
  81. 82  ! redistribute this software provided it is not sold, and this copyright
  82. 83  ! is retained.
  83. 84  !==========================================================================
  84. 85  ! DISCLAIMER:
  85. 86  ! This software is provided as is.
  86. 87  ! No warantee is made of any kind with respect to this program including,
  87. 88  ! but not limited to, implied warantees of merchantability or fitness for
  88. 89  ! a particular purpose.
  89. 90  ! Neither Hewlett-Packard nor the author shall be liable for errors or
  90. 91  ! incidental damages in connection with the use of this material.
  91. 92 !==========================================================================
  92. 93    CONTROL KBD,3;4,40        ! speed up keyboard
  93. 94    COM Version$[80],K$[180],Setup$[80]
  94. 95    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  95. 96    COM /Port/ @Out_buff,@Com_out,Output_buffer$[1000] BUFFER
  96. 97    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$[4000] BUFFER,Com_card
  97. 98    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$[3],Parity_type$[4]
  98. 99    COM /Frame/ Flow$[10],Hshake$[10]
  99. 100   COM /Portsc/ Sports(1:10)
  100. 101   COM /Path/ Cur_msi$[256],S_path$[256],S_msi$[20],D_path$[256],D_msi$[20]
  101. 102   !========================================================================
  102. 103 Version:Version$="HP-9000  Kermit-RMB  
  103. Release 1.03  20 Feb 1990 
  104. "
  105. 104   Active=0
  106. 105   In_term=0
  107. 106   CONTROL CRT,21;1   ! Reset CRT
  108. 107   PRINTER IS CRT
  109. 108   GRAPHICS ON
  110. 109   WINDOW 0,80,26,0
  111. 110   CSIZE 3.5
  112. 111   KEY LABELS OFF
  113. 112  !------------------------------
  114. 113   CLEAR ERROR
  115. 114   GOSUB Config
  116. 115   CALL Kermit
  117. 116  !------------------------------
  118. 117   CALL Shutdown
  119. 118   CONTROL CRT,21;1
  120. 119   KEY LABELS ON
  121. 120   MASS STORAGE IS Cur_msi$
  122. 121   PRINT TABXY(1,Crt_lines);"KERMIT DONE."
  123. 122   CONTROL KBD,3;6,60        ! restore kbd speed
  124. 123   STOP
  125. 124!======================================================================
  126. 125 Config:!
  127. 126   COM /Crt/ Crt_lines,Crt_width
  128. 127   STATUS CRT,9;Crt_width
  129. 128   STATUS CRT,13;Crt_lines
  130. 129   Crt_lines=Crt_lines-7
  131. 130   No_com_ports=0
  132. 131   Com_card=0
  133. 132 !
  134. 133 ! Check For BIN Files Loaded
  135. 134 !
  136. 135   Sbin=0
  137. 136   Dbin=0
  138. 137   Sbin=VAL(SYSTEM$("VERSION: SERIAL"))
  139. 138   Dbin=VAL(SYSTEM$("VERSION: DCOMM "))
  140. 139   IF Sbin=0 OR Dbin=0 THEN 
  141. 140     BEEP 2000,.05
  142. 141     WAIT .05
  143. 142     BEEP 2000,.05
  144. 143   END IF
  145. 144   IF Sbin=0 THEN PRINT "SERIAL BIN not Loaded, LOAD BIN or Continue (F2)"
  146. 145   IF Dbin=0 THEN PRINT "DCOMM  BIN not Loaded, LOAD BIN or Continue (F2)"
  147. 146   IF Dbin=0 OR Sbin=0 THEN PAUSE
  148. 147 !
  149. 148 ! Identify the Com Ports installed
  150. 149 !
  151. 150   ON ERROR GOSUB Sc_err
  152. 151   FOR Sc=8 TO 31
  153. 152     RESET Sc
  154. 153     STATUS Sc,0;Id
  155. 154     SELECT Id
  156. 155     CASE 2
  157. 156       Com_port=Sc
  158. 157       No_com_ports=No_com_ports+1
  159. 158       Com_card=98626              ! COULD BE 98644 IF JUMPER IS CUT
  160. 159       Sports(No_com_ports)=Sc
  161. 160     CASE 52                       ! 98628 or SRM
  162. 161       STATUS Sc,3;Com_protocol   ! SRM=3 Datacomm=1,2
  163. 162       IF Com_protocol<3 THEN     ! Not an SRM Card
  164. 163         Com_port=Sc
  165. 164         No_com_ports=No_com_ports+1
  166. 165         Com_card=98628
  167. 166         Sports(No_com_ports)=Sc
  168. 167       END IF
  169. 168     CASE 66
  170. 169       Com_port=Sc
  171. 170       No_com_ports=No_com_ports+1
  172. 171       Com_card=98644
  173. 172       Sports(No_com_ports)=Sc
  174. 173     CASE 180
  175. 174       BEEP 2000,.05
  176. 175       PRINT "Remote Switch is set on Serial Port ";Sc;" - Port can't be used"
  177. 176     END SELECT
  178. 177   NEXT Sc
  179. 178   OFF ERROR 
  180. 179   IF No_com_ports=0 THEN 
  181. 180     BEEP 
  182. 181     PRINT TABXY(1,Crt_lines);"No Serial Ports Found "
  183. 182   ELSE
  184. 183     REDIM Sports(1:No_com_ports)
  185. 184   END IF
  186. 185   IF No_com_ports>1 THEN 
  187. 186     PRINT USING "////"
  188. 187     PRINT "Serial Ports Found at Select Codes ";
  189. 188     FOR P=1 TO No_com_ports
  190. 189       PRINT Sports(P);
  191. 190     NEXT P
  192. 191     Com_port=Sports(1)
  193. 192     PRINT 
  194. 193     PRINT "Active Port is Select Code  ";Com_port
  195. 194     PRINT "Use Kermit SET PORT Command to Change"
  196. 195   END IF
  197. 196 !
  198. 197 ! Identify Card Model
  199. 198 !
  200. 199   IF No_com_ports>0 THEN 
  201. 200     STATUS Com_port,0;Id
  202. 201     SELECT Id
  203. 202     CASE 2
  204. 203       Com_card=98626              ! COULD BE 98644 IF JUMPER IS CUT
  205. 204     CASE 52
  206. 205       Com_card=98628
  207. 206     CASE 66
  208. 207       Com_card=98644
  209. 208     CASE ELSE
  210. 209       BEEP 
  211. 210       PRINT "Unknown Card Type, Reporting Card ID as: ";Id
  212. 211     END SELECT
  213. 212 !
  214. 213 ! Reset the Serial Interface
  215. 214 !
  216. 215     CALL Reset_port
  217. 216   END IF
  218. 217   RETURN 
  219. 218 !------------------------------------------
  220. 219 Sc_err:  !
  221. 220   Id=0
  222. 221   CLEAR ERROR
  223. 222   ERROR RETURN
  224. 223  !-----------------------------------------
  225. 224   END
  226. 225 !=========================================================================
  227. 226 Kinit:SUB Kermit_com_init
  228. 227 Kci:  !
  229. 228     OPTION BASE 1
  230. 229     DIM Misc$[100]
  231. 230     ON ERROR GOSUB Kci_err
  232. 231    !
  233. 232    ! Initialize all constants here
  234. 233    !
  235. 234     COM /Kerm/ INTEGER Maxp,Maxtry,Mypad,Mytmo,Mypchar,Myeol,Myquote
  236. 235     Maxp=94
  237. 236     Maxtry=10
  238. 237     Mypad=0
  239. 238     Mytmo=8                ! my timeout period
  240. 239     Mypchar=0
  241. 240     Myeol=NUM("
  242. ")          ! LF
  243. 241     Myquote=NUM("#")
  244. 242    !
  245. 243     COM /Kerm/ INTEGER Size,Rpsiz,Spsiz,Pad,Capas,Send_at
  246. 244     Size=0
  247. 245     Rpsiz=94
  248. 246     Spsiz=94
  249. 247     Pad=0
  250. 248     Ptmo=8
  251. 249     Capas=0     ! extended capabilities off
  252. 250     Send_at=1   ! use attribute packets if possible
  253. 251    !
  254. 252     COM /Kerm/ INTEGER Image,Parflg,Pktdeb
  255. 253     Remote=0
  256. 254     Image=0
  257. 255     Parflg=0
  258. 256     Turn=0
  259. 257     Lecho=0
  260. 258     Debug=0
  261. 259     Pktdeb=0
  262. 260     Display=8     ! Shut Off Send and receive Packets
  263. 261    !
  264. 262     COM /Kerm/ INTEGER Filnamcnv,Blk_chk,Quote,Eol,Smark
  265. 263     Filnamcnv=0
  266. 264     Filecount=0
  267. 265     Timer=1
  268. 266     Quote=NUM("#")
  269. 267     Eol=10              ! Linefeed
  270. 268     Blk_chk=1
  271. 269     Smark=1        ! CHR$(1)
  272. 270    !
  273. 271     COM /Kerm2/ State$[1],Cchksum$[1],Eof_mode$[10],INTEGER Eof_mode,Timer,Ptmo
  274. 272     State$="S"
  275. 273     Eof_mode$="CTRL-Z ON"
  276. 274     Eof_mode=1
  277. 275    !
  278. 276    ! Other COM areas
  279. 277    !
  280. 278     COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  281. 279     COM /Frame/ Baud,Data_bits,Stop_bits,On_off$,Parity_type$
  282. 280     COM /Frame/ Flow$,Hshake$
  283. 281     COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  284. 282     COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  285. 283     COM /Term/ Term_type$[10],S_log,D_log,Filewarn,Discard,@S_log,@D_log
  286. 284     COM /Term/ Kerm_esc$[2],S_log$[80],D_log$[80],INTEGER Remote,Lecho,Turn,Display
  287. 285     COM /Term/ Term_mode$[10]
  288. 286     COM /Path/ Cur_msi$,S_path$,S_msi$,D_path$,D_msi$
  289. 287     COM /Mode/ Mode_line,Newline
  290. 288  !
  291. 289  !  Initialize Serial Port
  292. 290     Newline=1           ! Auto append Lf in terminal after Cr
  293. 291     Mode_line=1         ! baud and parity indicator line in terminal on|off
  294. 292     Lecho=1
  295. 293     Baud=9600
  296. 294     Flow$="XON/XOFF"
  297. 295     Hshake$="NONE"
  298. 296     Term_type$="VT100"
  299. 297     Term_mode$="NUMERIC"
  300. 298     Data_bits=8
  301. 299     Stop_bits=1
  302. 300     On_off$="OFF"        ! Parity Checking
  303. 301     Parity_type$="NONE"
  304. 302     Filewarn=1
  305. 303   !
  306. 304     REPEAT
  307. 305       Bad_msi=1
  308. 306       Cur_msi$=SYSTEM$("MSI")
  309. 307       MASS STORAGE IS Cur_msi$
  310. 308     UNTIL Bad_msi
  311. 309     Misc=POS(Cur_msi$,"CS80")
  312. 310     IF Misc THEN Cur_msi$=Cur_msi$[1,Misc-1]&Cur_msi$[Misc+4]
  313. 311     Misc$=Cur_msi$
  314. 312     S_msi$=Misc$[POS(Misc$,":")]
  315. 313     D_msi$=Misc$[POS(Misc$,":")]
  316. 314     IF POS(Misc$,"/") THEN          ! get  d_path$
  317. 315       D_path$=Misc$[1,POS(Misc$,":")-1]&"/"
  318. 316       S_path$=Misc$[1,POS(Misc$,":")-1]&"/"
  319. 317     ELSE
  320. 318       D_path$=""
  321. 319       S_path$=""
  322. 320     END IF
  323. 321   !
  324. 322     S_log$=D_path$&"SES_LOG"&D_msi$
  325. 323     D_log$=D_path$&"PKT_LOG"&D_msi$
  326. 324     S_log=0
  327. 325     D_log=0
  328. 326     !
  329. 327     Remote=0
  330. 328     Kermit_exit=0
  331. 329     Kerm_esc$=CHR$(29)&"C"        ! CTRL-] C
  332. 330     SUBEXIT    !-----------------------------------------------------
  333. 331 Kci_err:  !
  334. 332     SELECT ERRN
  335. 333     CASE 90! mass storage system error
  336. 334       RESET 7       ! assumes mass storage on 7
  337. 335     CASE 76,72,52   ! bad unit code in msi, drive not found
  338. 336       DISP "Mass Storage Volume not On-line please enter a valid MSI "
  339. 337       OUTPUT KBD;Cur_msi$;" H";
  340. 338       ENTER KBD;Cur_msi$
  341. 339       DISP 
  342. 340       Bad_msi=0
  343. 341       ERROR RETURN
  344. 342     CASE 163,167
  345. 343       CLEAR ERROR
  346. 344       ERROR RETURN
  347. 345     CASE ELSE
  348. 346       DISP ERRM$
  349. 347       PAUSE
  350. 348     END SELECT
  351. 349     RETURN 
  352. 350   SUBEND
  353. 351    !================  End of  Kermit Com Init ============================
  354. 352 Kermit:SUB Kermit
  355. 353     IF NOT Active THEN CALL Kermit_com_init
  356. 354     OPTION BASE 1
  357. 355     COM Version$,K$,Setup$
  358. 356     COM /Crt/ Crt_lines,Crt_width
  359. 357     COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  360. 358     COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  361. 359     COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  362. 360     COM /Frame/ Baud,Data_bits,Stop_bits,On_off$,Parity_type$
  363. 361     COM /Frame/ Flow$,Hshake$
  364. 362     COM /Kerm/ INTEGER Maxp,Maxtry,Mypad,Mytmo,Mypchar,Myeol,Myquote
  365. 363     COM /Kerm/ INTEGER Size,Rpsiz,Spsiz,Pad,Capas,Send_at
  366. 364     COM /Kerm/ INTEGER Image,Parflg,Pktdeb
  367. 365     COM /Kerm/ INTEGER Filnamcnv,Blk_chk,Quote,Eol,Smark
  368. 366     COM /Kerm2/ State$,Cchksum$,Eof_mode$,INTEGER Eof_mode,Timer,Ptmo
  369. 367     COM /Term/ Term_type$,S_log,D_log,Filewarn,Discard,@S_log,@D_log
  370. 368     COM /Term/ Kerm_esc$[2],S_log$,D_log$,INTEGER Remote,Lecho,Turn,Display
  371. 369     COM /Term/ Term_mode$
  372. 370     COM /Path/ Cur_msi$,S_path$,S_msi$,D_path$,D_msi$
  373. 371     COM /Mode/ Mode_line,Newline
  374. 372     COM /Def/ Define$(5,10)[30],No_define
  375. 373     COM /Portsc/ Sports(1:10)
  376. 374    !
  377. 375     DIM Kl$[300],Cmds$(1:80)[50]
  378. 376     DIM Init_cmd$[300],Cat$(1:1)[80]
  379. 377     DIM Def_cmd$[30],Filename$[256],Localname$[256]
  380. 378     DIM F$[80],F_path$[80],F_msi$[80],Fp$[80],Fm$[80],T_msi$[80],T_path$[80]
  381. 379     DIM Line$[512],Misc$[80],Msg$[80],Misc2$[80],Misc3$[80]
  382. 380     INTEGER Rc,Bdat_item
  383. 381  !---------------------------------------------------------------------------------
  384. 382  ! Entry point from Terminal Emulator - Kermit Shell
  385. 383     IF Remote=1 THEN GOTO Shell_entry
  386. 384  !---------------------------------------------------------------------------------
  387. 385  !  Initialize Serial Port
  388. 386     CALL Set_frame(Baud)  ! Other values passed in COM
  389. 387  !
  390. 388     CONTROL CRT,10;1
  391. 389     IF NOT Active THEN    ! Look for HPBINIT File
  392. 390       Active=1
  393. 391       PRINT TABXY(1,Crt_lines-1)
  394. 392       PRINT Version$
  395. 393       PRINT "? For Help"
  396. 394       PRINT 
  397. 395       Init_file=0
  398. 396       ASSIGN @File TO "HPBINIT";RETURN Rc
  399. 397       IF NOT Rc THEN Init_file=1
  400. 398     END IF
  401. 399     Remote=0
  402. 400     Kermit_exit=0
  403. 401     Prompt$="KERMIT-RMB>"
  404. 402     DISP 
  405. 403     IF Init_file THEN 
  406. 404       PRINT "KERMIT Initialization: "
  407. 405       PRINT 
  408. 406       Cmds$(1)="TAKE"
  409. 407       Cmds$(2)="HPBINIT"
  410. 408       GOTO Kermit_exec
  411. 409     END IF
  412. 410 Shell_entry: !------------------------------------------------------------------
  413. 411     Prompt$="KERMIT-RMB>"
  414. 412     REPEAT     ! Until Exit or Quit Command is given
  415. 413       ON ERROR GOSUB K_error
  416. 414 Parse1:  !
  417. 415       REPEAT   ! Until Kermit Command is Entered
  418. 416         OUTPUT KBD;Prompt$&Kl$;      ! kl$ may have errored kermit line
  419. 417         ENTER KBD;Kl$
  420. 418         Parse_kl(Kl$,Cmds$(*),No_cmds,Prompt$)  ! return Kl$ as Kl$(2..)
  421. 419       UNTIL No_cmds>0
  422. 420       DISP 
  423. 421       Msg$=" Not Recognized         "
  424. 422     !
  425. 423 Kermit_exec:  !
  426. 424  !
  427. 425  ! Notes on Kermit Shell:
  428. 426  !
  429. 427  ! Error Levels  1,2,3,4         That command is not a kermit command
  430. 428  ! Error Levels  20,30,40        That parameter is missing
  431. 429  ! Ni=1                          Valid Kermit Command Not Implemented
  432. 430  ! Err_level     -1              Print Msg$
  433. 431  !
  434. 432       ON ERROR GOSUB K_error
  435. 433       SELECT Cmds$(1)             ! Do a Select on the Kermit Command
  436. 434  !--------------------------------
  437. 435 A:    CASE ""
  438. 436 B:    CASE "BYE"
  439. 437         Ni=1
  440. 438 C:    CASE "CLEAR","CLR"       ! Clear Serial Buffer, cycle transfers
  441. 439         CALL Clear
  442. 440       CASE "CLS"
  443. 441         CLEAR SCREEN
  444. 442       CASE "CLOSE","CLO"
  445. 443         SELECT Cmds$(2)
  446. 444         CASE "PACKET","PAC","P"
  447. 445           D_log=0                 ! Close  PKT_LOG
  448. 446           OUTPUT @D_log;END
  449. 447           ASSIGN @D_log TO *
  450. 448         CASE "SESSION","SES","S"
  451. 449           S_log=0                 ! Close  SES_LOG
  452. 450           OUTPUT @S_log;END
  453. 451           ASSIGN @S_log TO *
  454. 452         CASE ELSE
  455. 453           Err_level=2
  456. 454         END SELECT
  457. 455       CASE "COMMENT","COM"
  458. 456         Ni=1
  459. 457       CASE "CONNECT","C","CON"
  460. 458         IF Cmds$(1)="C" THEN Cmds$(1)="CONNECT"
  461. 459         Remote=1
  462. 460         IF NOT In_term THEN 
  463. 461           CALL Terminal
  464. 462           PRINTER IS CRT
  465. 463           PRINT TABXY(1,Crt_lines);
  466. 464           In_term=0
  467. 465         ELSE
  468. 466           GOTO Ex      ! goto EXIT command code - don't respawn term
  469. 467         END IF
  470. 468         Supress_echo=1
  471. 469       CASE "CONVERT"               ! Unique Command
  472. 470         Misc$=Cmds$(2)    ! filename to convert
  473. 471         IF Cmds$(3)="TO" THEN 
  474. 472           New_type$=Cmds$(4)
  475. 473           IF LEN(Cmds$(5)) THEN Flen=VAL(Cmds$(5))
  476. 474         ELSE
  477. 475           New_type$=Cmds$(3)
  478. 476           IF LEN(Cmds$(4)) THEN Flen=VAL(Cmds$(4))
  479. 477         END IF
  480. 478         IF NOT LEN(New_type$) THEN 
  481. 479           PRINT "Usage:  CONVERT  <Filename> [TO] <Filetype> [Secors]"
  482. 480           PRINT "<Filetype>  -nnnn | ASCII | HPUX | BDAT | PROG "
  483. 481           Supress_echo=1
  484. 482         ELSE
  485. 483           IF Flen THEN 
  486. 484             CALL Convert(Misc$,New_type$,Rc,Flen)
  487. 485           ELSE
  488. 486             CALL Convert(Misc$,New_type$,Rc)
  489. 487           END IF
  490. 488         END IF
  491. 489       CASE "COPY"
  492. 490         IF Cmds$(3)="TO" THEN 
  493. 491           Cmds$(3)=Cmds$(4)      ! Normalize to cmds$(3)=destination
  494. 492         END IF
  495. 493         IF Cmds$(3)[1,1]=":" THEN   ! Add name to msi
  496. 494           Misc$=Cmds$(2)
  497. 495           Parse_filename(Misc$,F_msi$,F_path$)
  498. 496           Misc2$=Misc$      ! save filename
  499. 497           Misc$=Cmds$(3)
  500. 498           Parse_filename(Misc$,F_msi$,F_path$)
  501. 499           Cmds$(3)=F_path$&Misc2$&F_msi$
  502. 500         END IF
  503. 501 !
  504. 502         COPY Cmds$(2) TO Cmds$(3)
  505. 503       CASE "MSI","CD"
  506. 504         ON ERROR GOTO Nocwd
  507. 505         MASS STORAGE IS Cmds$(2)
  508. 506         GOTO Cwdok
  509. 507 Nocwd:  !
  510. 508         Msg$="Can't access: "&Cmds$(2)
  511. 509         Err_level=-1
  512. 510 Cwdok:  ON ERROR GOSUB K_error
  513. 511 D:    CASE "DEFINE","DEF"   ! Define a command macro
  514. 512       !
  515. 513       ! determine if macro is being defined or purged
  516. 514       !
  517. 515         Def_id=0
  518. 516         FOR I=1 TO No_define
  519. 517           IF Define$(I,1)=Cmds$(2) THEN   ! macro exists
  520. 518             Def_id=I
  521. 519             IF No_cmds=2 THEN      ! purge macro
  522. 520               FOR X=1 TO 10
  523. 521                 Define$(Def_id,X)=""
  524. 522               NEXT X
  525. 523               Def_id=-1
  526. 524             END IF
  527. 525           END IF
  528. 526         NEXT I
  529. 527         IF Def_id=0 THEN    ! create a new macro
  530. 528           No_define=No_define+1
  531. 529           Def_id=No_define
  532. 530           Define$(Def_id,1)=Cmds$(2)     ! macro name
  533. 531        !
  534. 532        ! need to pack commands up to comma
  535. 533        !
  536. 534           I=3
  537. 535           Def_cmd=2
  538. 536           REPEAT
  539. 537             IF Cmds$(I)="," THEN 
  540. 538               Define$(Def_id,Def_cmd)=Def_cmd$
  541. 539               Def_cmd=Def_cmd+1
  542. 540               Def_cmd$=""
  543. 541             ELSE
  544. 542               Def_cmd$=Def_cmd$&Cmds$(I)&" "
  545. 543             END IF
  546. 544             I=I+1
  547. 545           UNTIL I=No_cmds+1
  548. 546           Define$(Def_id,Def_cmd)=Def_cmd$
  549. 547           Def_cmd$=""
  550. 548         END IF! define macro
  551. 549        !
  552. 550       CASE "DELETE","DEL","PURGE"
  553. 551         PURGE Cmds$(2)
  554. 552         PRINT "Purged ";Cmds$(2)
  555. 553         Supress_echo=1
  556. 554       CASE "DIAL"           ! Call Terminal and Dial a Modem
  557. 555         Remote=1
  558. 556         Modem_init$="AT L2 C1"
  559. 557         CALL Terminal(Cmds$(2),Modem_init$,"HAYES")
  560. 558       CASE "DO"
  561. 559         Do=0
  562. 560         FOR I=1 TO No_define
  563. 561           IF Cmds$(2)=Define$(I,1) THEN Do=I
  564. 562         NEXT I
  565. 563         IF Do THEN 
  566. 564           PRINT "Executing Macro ";Define$(Do,1)
  567. 565           Shell=1
  568. 566           FOR I=2 TO 10
  569. 567             IF LEN(Define$(Do,I)) THEN 
  570. 568               PRINT "<exec> ";Define$(Do,I)
  571. 569               Kl$=Prompt$&Define$(Do,I)
  572. 570               Parse_kl(Kl$,Cmds$(*),No_cmds,Prompt$)! return Kl$ as Kl$(2..)
  573. 571               GOSUB Kermit_exec
  574. 572             END IF
  575. 573           NEXT I
  576. 574           Shell=0
  577. 575         ELSE
  578. 576           PRINT "Macro: ";Cmds$(2);"  not defined"
  579. 577         END IF
  580. 578       CASE "DUMP"                     ! Unique command to RMB
  581. 579         ON ERROR GOTO No_hexedit
  582. 580         CALL Hex_edit(Cmds$(2))
  583. 581         Supress_echo=1
  584. 582         GOTO Dump_exit
  585. 583 No_hexedit:!
  586. 584         ON ERROR GOSUB No_hexedit_file
  587. 585         Misc$="HPBMISC"
  588. 586         DISP "Loading Hex Editor, Please Wait ..."
  589. 587         LOADSUB Hex_edit FROM Misc$
  590. 588         DISP 
  591. 589         CALL Hex_edit(Cmds$(2))
  592. 590         GOTO Dump_exit
  593. 591 No_hexedit_file: !
  594. 592         DISP "Cant load Hex Editor  - file: HPBMISC not found - plese enter path and MSI  "
  595. 593         OUTPUT KBD;Misc$&Source_msi$;
  596. 594         ENTER KBD;Misc$
  597. 595         DISP 
  598. 596         ON ERROR GOTO Dump_exit
  599. 597         RETURN 
  600. 598 Dump_exit:  !
  601. 599       CASE "CAT","DIR"
  602. 600         IF LEN(Cmds$(2)) THEN 
  603. 601           CAT Cmds$(2)
  604. 602         ELSE
  605. 603           CAT 
  606. 604         END IF
  607. 605         Supress_echo=1
  608. 606 E:    CASE "ECHO"                     ! Macro Command
  609. 607         PRINT Kl$
  610. 608         Supress_echo=1
  611. 609       CASE "EDIT"                     ! Unique command to RMB
  612. 610         GOTO No_edit_yet
  613. 611         ON ERROR GOTO Load_editor
  614. 612         Parse_filename(Cmds$(2),F_msi$,F_path$)
  615. 613         IF NOT (LEN(F_msi$)) THEN F_msi$=S_msi$
  616. 614         IF NOT (LEN(F_path$)) THEN F_path$=S_path$
  617. 615         Filename$=F_path$&Cmds$(2)&F_mai$
  618. 616         CALL Edit(Filename$)
  619. 617         GOTO Edit_there
  620. 618 Load_editor:ON ERROR GOSUB K_error
  621. 619         LOADSUB ALL FROM "HPBEDIT"
  622. 620         CALL Edit(Cmds$(2),S_msi$,S_path$)
  623. 621 Edit_there:  !
  624. 622 No_edit_yet:!
  625. 623         Ni=1
  626. 624       CASE "EXIT"
  627. 625 Ex:     Kermit_exit=1
  628. 626         PRINTER IS CRT;EOL CHR$(10)
  629. 627 F:    CASE "FINISH"       ! Suspend Remote Server
  630. 628         Ni=1
  631. 629  !--------------------------------------------------------------------------
  632. 630 G:    CASE "GET"          ! Client Receive file via Server
  633. 631         Get_cmd=1
  634. 632         SELECT Cmds$(2)
  635. 633         CASE "?"
  636. 634           PRINT "Syntax:  GET  <Remote File> [<Local File> | , ]  [File Type] [File Length] "
  637. 635           PRINT "         GET  <Remote File> [<Local File> | , ]     <BDAT>  [# Records | , ] [Recl] "
  638. 636         CASE ELSE
  639. 637           Filename$=Cmds$(2)
  640. 638 !
  641. 639 !  Process Filename, MSI, and Path
  642. 640 !
  643. 641           IF LEN(Cmds$(3)) THEN 
  644. 642             Localname$=Cmds$(3)
  645. 643             IF LEN(Localname$) AND Localname$<>"," THEN 
  646. 644               CALL Parse_filename(Localname$,F_msi$,F_path$)
  647. 645             ELSE
  648. 646               Localname$=""
  649. 647             END IF
  650. 648      !
  651. 649             IF (LEN(F_msi$)=0) THEN  ! msi for incomming file not spec
  652. 650               F_msi$=D_msi$
  653. 651               F_path$=D_path$
  654. 652             END IF
  655. 653           END IF
  656. 654         !
  657. 655           IF LEN(Localname$) THEN 
  658. 656             K_receive(Filename$,F_msi$,F_path$,Ftype$,Recl,File_length,Get_cmd,Localname$)
  659. 657           ELSE
  660. 658             K_receive(Filename$,F_msi$,F_path$,Ftype$,Recl,File_length,Get_cmd)
  661. 659           END IF
  662. 660         END SELECT
  663. 661 !--------------------------------------------------------------------------
  664. 662 H:    CASE "HANGUP"             ! Disconnect Modem (lower DTR)
  665. 663         SELECT Com_card
  666. 664         CASE 98626,98644
  667. 665           STATUS Com_port,5;C5
  668. 666           CONTROL Com_port,5;BINAND(C5,254)
  669. 667         CASE 98628
  670. 668         CASE ELSE
  671. 669           DISP "UNKNOWN COM CARD ";Com_card
  672. 670         END SELECT
  673. 671       CASE "HELP","?"               ! ? as first command involkes full help
  674. 672         Kh=0
  675. 673         Help_filename$="HPBHELP"
  676. 674         REPEAT
  677. 675           ON ERROR GOTO No_help
  678. 676           CALL Kermit_help(Cmds$(*),No_cmds,Kl$)
  679. 677           Kh=1
  680. 678           GOTO Khdone
  681. 679 No_help:  OFF ERROR 
  682. 680           ON ERROR GOTO No_help_file
  683. 681           DISP "Loading Help File"
  684. 682           LOADSUB ALL FROM Help_filename$
  685. 683           GOTO Khdone
  686. 684           DISP 
  687. 685 No_help_file:OFF ERROR 
  688. 686           Help_found=0
  689. 687           DISP "Can't Find File - Give MSI "
  690. 688           OUTPUT KBD;Help_filename$;
  691. 689           ENTER KBD;Help_filename$
  692. 690           IF NOT POS(Help_filename$,":") THEN Kh=1
  693. 691           DISP 
  694. 692 Khdone:        !
  695. 693         UNTIL Kh
  696. 694         Supress_echo=1
  697. 695       CASE "HOST"          ! Send command for HOST execution
  698. 696         Ni=1
  699. 697 I:    CASE "INPUT"         ! Wait on COM Port for this ascii string
  700. 698         Ni=1
  701. 699 L:    CASE "LOCAL"         ! Execute a local BASIC command
  702. 700         ON ERROR GOTO Local_err   !Warning - doesn't trap kbd line execution
  703. 701         OUTPUT KBD;Kl$;" E";
  704. 702         GOTO Local_exit
  705. 703 Local_err: !
  706. 704         PRINT ERRM$
  707. 705 Local_exit:OFF ERROR 
  708. 706         CLEAR LINE
  709. 707       CASE "LOG"        ! Session Log Commands
  710. 708         ON ERROR GOSUB K_error
  711. 709         Slog_try=0      ! Attemps to open file
  712. 710         Dlog_try=0
  713. 711         SELECT Cmds$(2)
  714. 712         CASE "SESSION","S","SES"          ! Activate session logging
  715. 713           S_log=1
  716. 714           IF S_log THEN 
  717. 715             IF LEN(Cmds$(3)) THEN 
  718. 716               Misc$=Cmds$(3)
  719. 717               Parse_filename(Misc$,Misc2$,Misc3$)
  720. 718               IF NOT LEN(Misc$) THEN Misc$="SES_LOG"
  721. 719               IF NOT LEN(Misc2$) THEN Misc2$=D_msi$
  722. 720               IF NOT LEN(Misc3$) THEN Misc3$=D_path$
  723. 721               S_log$=Misc3$&Misc$&Misc2$
  724. 722             END IF
  725. 723           END IF
  726. 724  !
  727. 725           REPEAT
  728. 726             Slog_try=Slog_try+1
  729. 727             ASSIGN @S_log TO S_log$;FORMAT ON,RETURN Rc
  730. 728             IF Rc THEN CREATE S_log$,10000
  731. 729             IF NOT Rc THEN Slog_open=1
  732. 730             IF Rc=76 THEN 
  733. 731               Slog_open=0
  734. 732               Slog_try=4
  735. 733             END IF
  736. 734           UNTIL (NOT Rc) OR (Slog_try>3)
  737. 735           IF Slog_try>3 THEN 
  738. 736             DISP "CAN'T OPEN ";S_log$
  739. 737             S_log=0
  740. 738           ELSE
  741. 739             DISP "Session Logging on to ";S_log$
  742. 740           END IF
  743. 741       !
  744. 742         CASE "PACKET","PAC","P"        ! Open Packet (debug) logging
  745. 743           D_log=1
  746. 744           IF D_log THEN 
  747. 745             IF LEN(Cmds$(3)) THEN 
  748. 746               Misc$=Cmds$(3)
  749. 747               Parse_filename(Misc$,Misc2$,Misc3$)
  750. 748               IF NOT LEN(Misc$) THEN Misc$="PKT_LOG"
  751. 749               IF NOT LEN(Misc2$) THEN Misc2$=D_msi$
  752. 750               IF NOT LEN(Misc3$) THEN Misc3$=D_path$
  753. 751               D_log$=Misc3$&Misc$&Misc2$
  754. 752             END IF
  755. 753           END IF
  756. 754         !
  757. 755           REPEAT
  758. 756             Dlog_try=Dlog_try+1
  759. 757             ASSIGN @D_log TO D_log$;RETURN Rc
  760. 758             IF Rc THEN CREATE ASCII D_log$,100
  761. 759             IF NOT Rc THEN Dlog_open=1
  762. 760             IF Rc=76 THEN 
  763. 761               Dlog_open=0
  764. 762               Dlog_try=4
  765. 763             END IF
  766. 764           UNTIL (NOT Rc) OR (Dlog_try>3)
  767. 765           IF Dlog_try>3 THEN PRINT "CAN'T OPEN ";D_log$
  768. 766           IF Dlog_try>3 THEN D_log=0
  769. 767         END SELECT
  770. 768         OFF ERROR 
  771. 769 M:    CASE "MU"
  772. 770         PRINT "Available Memory: ";SYSTEM$("AVAILABLE MEMORY")
  773. 771         Supress_echo=1
  774. 772 N: !
  775. 773 O:    CASE "OUTPUT","OUT"                  ! Pipe Output to Com Port
  776. 774         OUTPUT @Out_buff;Kl$
  777. 775 P:    CASE "PAUSE"                         !Macro command
  778. 776         WAIT VAL(Cmds$(2))
  779. 777       CASE "PRINT","TYPE","MORE"           ! (filename) [device]
  780. 778         Filename$=Cmds$(2)
  781. 779         IF Cmds$(1)[1,1]="P" THEN 
  782. 780           IF No_cmds>2 THEN 
  783. 781             Pdev=VAL(Cmds$(3))
  784. 782           ELSE
  785. 783             Pdev=701
  786. 784           END IF
  787. 785         ELSE   ! More or Type to Screen
  788. 786           Pdev=CRT
  789. 787         END IF
  790. 788         CALL More(Filename$,Pdev,Cmds$(1))
  791. 789       CASE "PROGRAM","PRO"
  792. 790         Ni=1
  793. 791       CASE "PUSH"  ! NA
  794. 792         Ni=1
  795. 793 Q:    CASE "QUIT","Q","QUI"
  796. 794         Kermit_exit=1
  797. 795 R:    CASE "RECEIVE","REC"      ! RECeive  <Filetype> <FILENAME | , >
  798. 796         SELECT Cmds$(2)
  799. 797         CASE "HP-UX","HPUX","ASCII","BDAT","PROG","SYSTM","BIN",""
  800. 798           Filetype$=Cmds$(2)
  801. 799           F$=Cmds$(3)    ! Filename, MSI, and Path are all part of
  802. 800           F_msi$=""      ! Cmds$(3)
  803. 801           F_path$=""
  804. 802           Rec=0          ! will be sent as "0" if not
  805. 803           Recl=0         ! specified in the command
  806. 804      !
  807. 805           IF No_cmds>3 THEN 
  808. 806             IF Cmds$(4)="," THEN 
  809. 807               Rec=0
  810. 808             ELSE
  811. 809               Rec=VAL(Cmds$(4))
  812. 810             END IF
  813. 811           END IF
  814. 812           IF No_cmds>4 THEN Recl=VAL(Cmds$(5))
  815. 813      !
  816. 814      ! RULES For Filespec:
  817. 815      !
  818. 816      ! 1. If Filename is given only then USE D_msi and D_path.
  819. 817      ! 2. If MSI is given with Filename then DON'T USE D_path.
  820. 818      ! 3. If PATH is given then use it with D_MSI
  821. 819      ! 4. If all three are given use all three.
  822. 820      !
  823. 821      !  Process Filename, MSI, and Path
  824. 822      !
  825. 823           IF LEN(F$) AND F$<>"," THEN 
  826. 824             CALL Parse_filename(F$,F_msi$,F_path$)
  827. 825           END IF
  828. 826      !
  829. 827           IF NOT (LEN(F_msi$)) THEN    ! msi given - invalidate path
  830. 828             F_msi$=D_msi$
  831. 829             F_path$=D_path$
  832. 830           END IF
  833. 831           IF Debug THEN DISP F$,F_msi$,F_path$
  834. 832           CALL K_receive(F$,F_msi$,F_path$,Filetype$,Recl,Rec,0)
  835. 833         CASE ELSE
  836. 834           PRINT "Syntax:  RECeive   [<Filetype>] [<FILENAME> | , ]  [File Length] "
  837. 835           PRINT "         RECeive    <BDAT>  [<FILENAME> | , ]  [# Records | , ] [Recl] "
  838. 836         END SELECT
  839. 837     !-------------------------------------------------------------
  840. 838         Supress_echo=1
  841. 839       CASE "REMOTE","REM"
  842. 840         Ni=1
  843. 841       CASE "RENAME","REN"
  844. 842         IF Cmds$(3)="TO" THEN 
  845. 843           Cmds$(3)=Cmds$(4)
  846. 844         END IF
  847. 845         RENAME Cmds$(2) TO Cmds$(3)
  848. 846       CASE "RUN"
  849. 847         Ni=1
  850. 848 S:    CASE "SEND","SEN"
  851. 849         IF NOT (LEN(Cmds$(2))) THEN Cmds$(2)="?"
  852. 850         SELECT Cmds$(2)
  853. 851         CASE "?"   ! Syntax Help
  854. 852           PRINT "usage:  SEND  <[Path] Filename [MSI]> [Bdat Item]"
  855. 853           PRINT "Bdat Item: <INTEGER | REAL>"
  856. 854           PRINT 
  857. 855         CASE ELSE
  858. 856           F$=Cmds$(2)
  859. 857           SELECT Cmds$(3)
  860. 858           CASE ""
  861. 859             Bdat_item=0  ! Not specified
  862. 860           CASE "INTEGER","INT","INTEGERS"
  863. 861             Bdat_item=1
  864. 862           CASE "REAL","REALS"
  865. 863             Bdat_item=2
  866. 864           CASE ELSE
  867. 865             Bdat_item=3
  868. 866           END SELECT
  869. 867           CALL K_send(F$,Bdat_item)
  870. 868         END SELECT
  871. 869         Supress_echo=1
  872. 870  !
  873. 871       CASE "SCRIPT","SCR"
  874. 872         Ni=1
  875. 873       CASE "SERVER","SER"
  876. 874         Ni=1
  877. 875  !
  878. 876 Set:  !----------------------------    SET COMMANDS   ---------------------
  879. 877  !
  880. 878       CASE "SET","S"
  881. 879         Cmds$(1)="SET"
  882. 880     !
  883. 881     !  Check for proper number of params ??
  884. 882     !
  885. 883         IF No_cmds=4 THEN          ! make sure all parms exist
  886. 884           ON ERROR GOSUB Valerr_4
  887. 885         ELSE
  888. 886           ON ERROR GOSUB Valerr_3
  889. 887         END IF
  890. 888      !
  891. 889         SELECT Cmds$(2)
  892. 890         CASE "?"
  893. 891           PRINT "BAUD     DEBUG       DEStination (DES)      SOURCE       DISPLAY"
  894. 892           PRINT "DUPLEX   ECHO        HandShake (HS)         ESCAPE       FILE   "
  895. 893           PRINT "FLOW     EOF         INComplete (ON=KEEP)   PORT         MARK   "
  896. 894           PRINT "REMOTE   RETRY       SEND        TAKE       TERM         TIMER     "
  897. 895           PRINT 
  898. 896           PRINT 
  899. 897         CASE ""
  900. 898           Err_level=20                      ! missing second parm
  901. 899         CASE "BAUD","SPEED","B"             ! set baud (rate)
  902. 900           IF POS(Kl$,"B ") THEN Kl$="BAUD"&Kl$[(POS(Kl$,"B"))+1]
  903. 901           Req_baud=VAL(Cmds$(3))
  904. 902           IF NOT Err_level THEN CALL Set_frame(Req_baud)
  905. 903         CASE "BLOCK-CHECK"
  906. 904           Ni=1
  907. 905         CASE "COLOR"
  908. 906           SELECT Cmds$(3) ! BLACK,WHite, etc
  909. 907           CASE "BLACK","BLK"
  910. 908             Apen=0
  911. 909           CASE "W","WHITE"
  912. 910             Apen=1
  913. 911           CASE "R","RED"
  914. 912             Apen=2
  915. 913           CASE "Y","YELLOW"
  916. 914             Apen=3
  917. 915           CASE "G","GREEN"
  918. 916             Apen=4
  919. 917           CASE "C","CYAN"
  920. 918             Apen=5
  921. 919           CASE "BL","BLUE"
  922. 920             Apen=6
  923. 921           CASE "M","MAGENTA"
  924. 922             Apen=7
  925. 923           END SELECT
  926. 924           SELECT Cmds$(4)
  927. 925           CASE "FG","ALPHA",""
  928. 926             CONTROL CRT,5;Apen
  929. 927           CASE "BG","BACKGROUND"
  930. 928             MOVE 0,0
  931. 929             AREA PEN Apen
  932. 930             RECTANGLE 1000,1000,FILL
  933. 931           CASE ELSE
  934. 932           END SELECT
  935. 933         CASE "DEBUG"                        ! set debug (on|off)
  936. 934           Debug=1
  937. 935           IF Cmds$(3)="OFF" THEN Debug=0
  938. 936         CASE "DEFAULT","DEF"
  939. 937           Msg$="Use SET SOURCE or SET DESTINATION commands"
  940. 938           Err_level=-1
  941. 939         CASE "DELAY"                ! My Delay before "S" init packet
  942. 940           Sdelay=Sval
  943. 941 Setd: !--------------------------------------------------------------------
  944. 942         CASE "DESTINATION","DES","DEST"   ! (Disc drive)
  945. 943           IF NOT LEN(Cmds$(3)) THEN      ! sync with SYSTEM$("MSI")
  946. 944             Misc$=SYSTEM$("MSI")
  947. 945             Parse_filename(Misc$,D_msi$,D_path$)
  948. 946             D_path$=D_path$&Misc$
  949. 947           ELSE  ! a mass storage device was given
  950. 948             REPEAT! strip off quotes from msvs
  951. 949               Qp=POS(Cmds$(3),"""""") ! check for quotes in string
  952. 950               IF Qp THEN Cmds$(3)[Qp,Qp]=""
  953. 951             UNTIL Qp=0
  954. 952  !
  955. 953             Misc$=TRIM$(Cmds$(3))
  956. 954             IF Misc$[1,1]="/" THEN   ! full path given
  957. 955               Parse_filename(Misc$,T_msi$,T_path$)   ! Misc$= Directory
  958. 956               T_path$=T_path$&Misc$&"/"   ! not valid until tested
  959. 957               IF LEN(Misc$)=0 THEN T_path$="/"  ! avoid //
  960. 958             ELSE  ! a relative directory given
  961. 959               IF Misc$[1,1]=":" THEN Setlif=1
  962. 960               Parse_filename(Misc$,T_msi$,T_path$)  ! temp paths
  963. 961               IF Setlif THEN 
  964. 962                 T_path$=""
  965. 963               ELSE
  966. 964                 T_path$=D_path$&Misc$&"/"
  967. 965                 IF LEN(Misc$)=0 THEN T_path$="/"! avoid //
  968. 966               END IF
  969. 967               Setlif=0
  970. 968             END IF
  971. 969             IF LEN(Misc$)=0 THEN D_path$="/"  ! if root / was given only
  972. 970  !
  973. 971             ON ERROR GOTO Nodmsi
  974. 972             MASS STORAGE IS T_path$&T_msi$
  975. 973             D_path$=T_path$   ! t_path$ OK make permanent
  976. 974             IF LEN(T_msi$) THEN D_msi$=T_msi$
  977. 975             GOTO Dmsiok
  978. 976 Nodmsi:     PRINT TABXY(1,Crt_lines);"Can't Access: ";T_path$&T_msi$;RPT$(" ",20)
  979. 977 Dmsiok:     OFF ERROR 
  980. 978           END IF
  981. 979 Sets:      !--------------------------------------------------------
  982. 980         CASE "SOURCE","SRC"
  983. 981           IF NOT LEN(Cmds$(3)) THEN      ! sync with SYSTEM$("MSI")
  984. 982             Misc$=SYSTEM$("MSI")
  985. 983             Parse_filename(Misc$,S_msi$,S_path$)
  986. 984             S_path$=S_path$&Misc$
  987. 985           ELSE  ! a mass storage device was given
  988. 986             REPEAT! strip off quotes from msvs
  989. 987               Qp=POS(Cmds$(3),"""""") ! check for quotes in string
  990. 988               IF Qp THEN Cmds$(3)[Qp,Qp]=""
  991. 989             UNTIL Qp=0
  992. 990  !
  993. 991             Misc$=TRIM$(Cmds$(3))
  994. 992             IF Misc$[1,1]="/" THEN   ! full path given
  995. 993               Parse_filename(Misc$,T_msi$,T_path$)   ! Misc$= Directory
  996. 994               T_path$=T_path$&Misc$&"/"   ! not valid until tested
  997. 995               IF LEN(Misc$)=0 THEN T_path$="/"  ! avoid //
  998. 996             ELSE  ! a relative directory given
  999. 997               IF Misc$[1,1]=":" THEN Setlif=1
  1000. 998               Parse_filename(Misc$,T_msi$,T_path$)  ! temp paths
  1001. 999               IF Setlif THEN 
  1002. 1000                T_path$=""
  1003. 1001              ELSE
  1004. 1002                T_path$=S_path$&Misc$&"/"
  1005. 1003                IF LEN(Misc$)=0 THEN T_path$="/"! avoid //
  1006. 1004              END IF
  1007. 1005              Setlif=0
  1008. 1006            END IF
  1009. 1007            IF LEN(Misc$)=0 THEN S_path$="/"  ! if root / was given only
  1010. 1008 !
  1011. 1009            ON ERROR GOTO Nosmsi
  1012. 1010            MASS STORAGE IS T_path$&T_msi$
  1013. 1011            S_path$=T_path$   ! t_path$ OK make permanent
  1014. 1012            IF LEN(T_msi$) THEN S_msi$=T_msi$
  1015. 1013            GOTO Dmsiok
  1016. 1014 Nosmsi:    PRINT TABXY(1,Crt_lines);"Can't Access: ";T_path$&T_msi$;RPT$(" ",20)
  1017. 1015 Smsiok:    OFF ERROR 
  1018. 1016          END IF
  1019. 1017 !-------------------------------------------------------------------------
  1020. 1018        CASE "DISPLAY"          ! Set Display for kermit or terminal
  1021. 1019          SELECT Cmds$(3)
  1022. 1020          CASE "OFF"
  1023. 1021            Display=0           ! Turn off display during file transfer
  1024. 1022          CASE "ON","8","8BIT","8-BIT"
  1025. 1023            Display=8           ! Show control chars on terminal screen
  1026. 1024          CASE "7","7BIT","7-BIT"
  1027. 1025            Display=7
  1028. 1026          CASE ELSE
  1029. 1027            Err_level=3
  1030. 1028          END SELECT
  1031. 1029        CASE "DUPLEX"               ! Set-Duplex-(HALF|FULL)
  1032. 1030          Duplex$="FULL"
  1033. 1031          SELECT Cmds$(3)
  1034. 1032          CASE "ON","FULL"
  1035. 1033            Duplex$="FULL"
  1036. 1034          CASE "OFF","HALF"
  1037. 1035            Duplex$="HALF"
  1038. 1036            Ni=1
  1039. 1037          END SELECT
  1040. 1038 Se:    CASE "ECHO","LOCAL-ECHO"            ! set echo (local | remote)
  1041. 1039          Lecho=1
  1042. 1040          SELECT Cmds$(3)
  1043. 1041          CASE "OFF","REMOTE"
  1044. 1042            Lecho=0
  1045. 1043          CASE "ON","LOCAL",""
  1046. 1044            Lecho=1
  1047. 1045          CASE ELSE
  1048. 1046            Err_level=3
  1049. 1047          END SELECT
  1050. 1048        CASE "EOF"                        ! Set-EndOfFile-(CTRL-Z|NONE)
  1051. 1049          SELECT Cmds$(3)
  1052. 1050          CASE "CTRL-Z","Z","ON"
  1053. 1051            Eof_mode$="CTRL-Z"            ! Append ^Z at end of ascii file
  1054. 1052            Eof_mode=1
  1055. 1053          CASE "NONE","OFF","NO CTRL-Z"
  1056. 1054            Eof_mode$="NONE"
  1057. 1055            Eof_mode=0
  1058. 1056          CASE ELSE
  1059. 1057            Err_level=3
  1060. 1058          END SELECT
  1061. 1059        CASE "ESCAPE","ESC"                 ! set escape
  1062. 1060          Kerm_esc$[1,1]=TRIM$(UPC$(Cmds$(3)[1,1]))
  1063. 1061 Sfi:   CASE "FILE","F"                     ! set file (parameters)
  1064. 1062          SELECT Cmds$(3)   ![1,3]
  1065. 1063          CASE "?"
  1066. 1064            PRINT "NAME     MODE     WARNING (WARN)   SUPERCEDE (SUP)"
  1067. 1065            PRINT 
  1068. 1066            PRINT 
  1069. 1067          CASE "NAME","NAM"            ! Set-File-Name
  1070. 1068          CASE "TYPE","T","MODE"        ! Set-File-Type
  1071. 1069            IMAGE=0
  1072. 1070            SELECT Cmds$(4)
  1073. 1071            CASE "BINARY","BIN","IMAGE","B"
  1074. 1072              Image=1
  1075. 1073            CASE ELSE
  1076. 1074              Image=0
  1077. 1075            END SELECT
  1078. 1076          CASE "WARNING","WARN"         ! Set-File-Warning
  1079. 1077            Filewarn=1
  1080. 1078            IF Cmds$(4)="OFF" THEN Filewarn=0
  1081. 1079          CASE "SUPERCEDE","SUP"        ! Set-File-Supercede
  1082. 1080            Ni=1
  1083. 1081          CASE ELSE
  1084. 1082            Err_level=3
  1085. 1083          END SELECT
  1086. 1084 Sf:    CASE "FLOW-CONTROL","FLOW","FC"  !  Set-FlowControl
  1087. 1085          SELECT Cmds$(3)
  1088. 1086          CASE "XON","XOFF","X","XONXOFF"
  1089. 1087            Flow$="XON/XOFF"
  1090. 1088          CASE "ENQ","ENQ/ACK"
  1091. 1089            Flow$="ENQ/ACK"
  1092. 1090          CASE "NONE","OFF"
  1093. 1091            Flow$="NONE"
  1094. 1092          CASE ELSE
  1095. 1093            Err_level=3
  1096. 1094          END SELECT
  1097. 1095 Sh:    CASE "HANDSHAKE","HS"   ! TURNAROUND CHAR
  1098. 1096          Hshake$="NONE"
  1099. 1097          IF Cmds$(3)="ON" THEN Hshake$="ON"
  1100. 1098        CASE "IBM"
  1101. 1099          Ni=1
  1102. 1100        CASE "INCOMPLETE","INC" ! Set-Incomplete  (KEEP|DISCARD)
  1103. 1101          Discard=0
  1104. 1102          SELECT Cmds$(3)
  1105. 1103          CASE "OFF","DISCARD","DIS"
  1106. 1104            Discard=1
  1107. 1105          CASE "ON","KEEP","K"
  1108. 1106            Discard=0
  1109. 1107          CASE ELSE
  1110. 1108            Err_level=3
  1111. 1109          END SELECT
  1112. 1110        CASE "INPUT","INP"
  1113. 1111          Ni=1
  1114. 1112        CASE "KEY"
  1115. 1113          Ni=1
  1116. 1114 Sl: !
  1117. 1115 Setport:CASE "PORT","LINE","LIN","POR","P"  ! set port number
  1118. 1116          IF POS(Kl$,"P ") THEN Kl$="PORT"&Kl$[(POS(Kl$,"P"))+1]
  1119. 1117          IF Cmds$(3)="?" THEN 
  1120. 1118            PRINT "Serial Ports:  ";Sports(*)
  1121. 1119            PRINT USING "//"
  1122. 1120          ELSE
  1123. 1121            Shutdown
  1124. 1122            Com_port=VAL(Cmds$(3))
  1125. 1123            STATUS Com_port,0;Id
  1126. 1124            SELECT Id
  1127. 1125            CASE 2
  1128. 1126              Com_card=98626      ! COULD BE 98644 IF JUMPER IS CUT
  1129. 1127            CASE 52
  1130. 1128              Com_card=98628
  1131. 1129            CASE 66
  1132. 1130              Com_card=98644
  1133. 1131            CASE 180
  1134. 1132              BEEP 
  1135. 1133              INPUT "98628 - REMOTE SW IS SET - PLEASE CORRECT ",Dum$
  1136. 1134            END SELECT
  1137. 1135            CALL Reset_port
  1138. 1136          END IF
  1139. 1137          Startup
  1140. 1138 Sm:    CASE "MARKER","MAR","MARK"        ! set start-of-packet character
  1141. 1139      !
  1142. 1140      ! Takes form: SET MARK  <actual single character>  or
  1143. 1141      !             SET MARK  ^A  notation
  1144. 1142      !
  1145. 1143          SELECT LEN(Cmds$(3))
  1146. 1144          CASE 1
  1147. 1145            Smark=NUM(Cmds$(3)[1,1])
  1148. 1146          CASE 2
  1149. 1147            Smark$=CHR$(FNCtl(Cmds$(3)[2,2]))   ! ^A  notation
  1150. 1148            Smark=NUM(Smark$)
  1151. 1149          CASE >2
  1152. 1150            Err_level=3
  1153. 1151          END SELECT
  1154. 1152        CASE "MODE-LINE","ML","MODELINE"
  1155. 1153          SELECT Cmds$(3)
  1156. 1154          CASE "OFF"
  1157. 1155            Mode_line=0
  1158. 1156          CASE "ON"
  1159. 1157            Mode_line=1
  1160. 1158          END SELECT
  1161. 1159        CASE "MODEM","MOD"
  1162. 1160          SELECT Cmds$(3)
  1163. 1161          CASE "VT100"
  1164. 1162            Term$="VT100"
  1165. 1163          CASE ELSE
  1166. 1164            Err_level=3
  1167. 1165          END SELECT
  1168. 1166 Sn:    CASE "NEWLINE","NL"
  1169. 1167          Newline=1
  1170. 1168          SELECT Cmds$(3)
  1171. 1169          CASE "ON"
  1172. 1170            Newline=1
  1173. 1171          CASE "OFF"
  1174. 1172            Newline=0
  1175. 1173          END SELECT
  1176. 1174 Sp:    CASE "PARITY","PAR"
  1177. 1175          SELECT Cmds$(3)
  1178. 1176          CASE "ODD","EVEN","ZERO","MARK","SPACE","ONE"
  1179. 1177            Parity_type$=Cmds$(3)
  1180. 1178            Data_bits=7
  1181. 1179          CASE "NONE"
  1182. 1180            Parity_type$=Cmds$(3)
  1183. 1181            Data_bits=8
  1184. 1182          CASE "OFF","DISABLE"
  1185. 1183            On_off$="OFF"
  1186. 1184          CASE "ON","ENABLE"
  1187. 1185            On_off$="ON"
  1188. 1186          CASE ""
  1189. 1187            Err_level=30
  1190. 1188          CASE ELSE
  1191. 1189            Err_level=4
  1192. 1190          END SELECT
  1193. 1191          CALL Set_frame(Baud)! Other values passed in COM
  1194. 1192     !  CASE "PORT"                       ! same as LINE
  1195. 1193        CASE "PROMPT"
  1196. 1194          Prompt$=Cmds$(3)&">"
  1197. 1195     !
  1198. 1196     !  SET - REMOTE (receive)  KERMIT PARAMETERS
  1199. 1197     !
  1200. 1198 Sr:    CASE "RECEIVE","REC","REMOTE","REM"   ! SET  RECEIVE PARAMETERS
  1201. 1199          ON ERROR GOSUB Valerr_4  ! CMDS$(4) MAY NEED TO BE A VALID NUMBER
  1202. 1200          SELECT Cmds$(3)
  1203. 1201          CASE ""
  1204. 1202            Err_level=30
  1205. 1203          CASE "?"
  1206. 1204            PRINT "END-OF-PACKET (EOP)        PACKET-LENGTH (PL)"
  1207. 1205            PRINT "PAD-CHARACTER (PC)         PADDING (PAD)"
  1208. 1206            PRINT "START-OF-PACKET (MARK)     TIMEOUT (TMO)"
  1209. 1207            PRINT 
  1210. 1208        !
  1211. 1209          CASE "END-OF-PACKET","EOP","EOL"
  1212. 1210          CASE "PACKET-LENGTH","PL"    ! Set-Receive-PacketLength
  1213. 1211            Rpsiz=VAL(Cmds$(4))
  1214. 1212          CASE "PAD-CHARACTER","PC"    ! Set-Receive-PadChar
  1215. 1213            Padchar$=Cmds$(4)
  1216. 1214            Padchar=NUM(Padchar$)
  1217. 1215          CASE "PADDING","PAD"
  1218. 1216            Pad=VAL(Cmds$(4))
  1219. 1217          CASE "PAUSE"
  1220. 1218          CASE "START-OF-PACKET","SOP","MARK"
  1221. 1219            Smark=NUM(Cmds$(4))
  1222. 1220          CASE "TIMEOUT","TMO"                   ! set receive timeout
  1223. 1221            Ptmo=VAL(Cmds$(4))
  1224. 1222          CASE ELSE
  1225. 1223            Err_level=3
  1226. 1224          END SELECT
  1227. 1225          OFF ERROR 
  1228. 1226    !   End Of SET - RECEIVE commands
  1229. 1227    !
  1230. 1228        CASE "RETRY","RET"          ! Set the max retry limit
  1231. 1229          Maxtry=VAL(Cmds$(3))
  1232. 1230        CASE "SERVER"            ! Set Server (Timeout, etc)
  1233. 1231          Ni=1
  1234. 1232     !
  1235. 1233     !  SET - LOCAL (SEND) KERMIT PARAMETERS ============
  1236. 1234     !
  1237. 1235 Ss:    CASE "SEND","SEN"          ! SET-SEND-[Parameter]-[value]
  1238. 1236 Ssend:   ON ERROR GOSUB Valerr_4
  1239. 1237          SELECT Cmds$(3)
  1240. 1238          CASE "?"," ",""
  1241. 1239            PRINT 
  1242. 1240            PRINT "ATTRIBUTE (AT)             PACKET-LENGTH (PL)"
  1243. 1241            PRINT "END-OF-PACKET (EOP)        PAD-CHARACTER (PC)"
  1244. 1242            PRINT "PREFIX CONTROL             PADDING (PAD)"
  1245. 1243            PRINT "PREFIX 8BIT                PREFIX REPEAT"
  1246. 1244            PRINT "TIMEOUT (TIM)              START-OF-PACKET (SOP)"
  1247. 1245            PRINT 
  1248. 1246      !     Err_level=30
  1249. 1247          CASE "AT","ATTRIB","ATTRIBUTE"
  1250. 1248            Send_at=1
  1251. 1249            IF POS(Cmds$(4),"OFF") THEN Send_at=0
  1252. 1250          CASE "END-OF-PACKET","EOP","EOL"     ! SET-SEND-EOP
  1253. 1251            Myeol$=Cmds$(4)
  1254. 1252          CASE "PACKET-LENGTH","PL","LEN"      ! Set-Send-Packet Length
  1255. 1253            Spsiz=VAL(Cmds$(4))
  1256. 1254          CASE "PAD-CHARACTER","PC"
  1257. 1255            Padchar$=Cmds$(4)
  1258. 1256          CASE "PADDING","PAD"
  1259. 1257            Mypad=VAL(Cmds$(4))
  1260. 1258          CASE "PAUSE"
  1261. 1259            Ni=1
  1262. 1260          CASE "PREFIX"               ! set-send-prefix-[type]
  1263. 1261            SELECT Cmds$(4)
  1264. 1262            CASE "CONTROL"
  1265. 1263              Myquote$=Cmds$(5)
  1266. 1264            CASE "8BIT"
  1267. 1265              Myprefix$=Cmds$(5)
  1268. 1266            CASE "REPEAT","REP"
  1269. 1267              Myrepeat$=Cmds$(5)
  1270. 1268            END SELECT
  1271. 1269          CASE "TIMEOUT","TIM"       ! set-send-timeout-[value]
  1272. 1270            Mytmo=VAL(Cmds$(4))
  1273. 1271          CASE "START-OF-PACKET","SOP"
  1274. 1272          END SELECT !   SET - SEND options
  1275. 1273    !
  1276. 1274    !  END OF SET-SEND PARAMETERS =====================
  1277. 1275    !
  1278. 1276 St:    CASE "TAKE","TAKE-ECHO"
  1279. 1277          Take_echo=1
  1280. 1278          IF Cmds$(3)="OFF" THEN Take_echo=0
  1281. 1279          IF Cmds$(3)<>"ON" AND Cmds$(3)<>"OFF" THEN Err_level=3
  1282. 1280        CASE "TERMINAL","TERM","T"               ! Set-Terminal
  1283. 1281          Term_type$="VT100"
  1284. 1282          SELECT Cmds$(3)
  1285. 1283          CASE "VT100"
  1286. 1284            Term_type$="VT100"
  1287. 1285          CASE "VT102"
  1288. 1286            Term_type$="VT102"
  1289. 1287          CASE "MODE"
  1290. 1288            SELECT Cmds$(4)
  1291. 1289            CASE "APPL","APPLICATION"
  1292. 1290              Term_mode$="APPL"
  1293. 1291            CASE "NUM","NUMERIC"
  1294. 1292              Term_mode$="NUMERIC"
  1295. 1293            CASE ELSE
  1296. 1294              PRINT "Syntax:  SET TERM MODE <APPL | NUMERIC>"
  1297. 1295              Err_level=4
  1298. 1296            END SELECT
  1299. 1297          CASE ELSE
  1300. 1298            PRINT TABXY(1,Crt_lines);"Terminal Type ";Cmds$(3);"  Not Implemented - How would you like to write one ?"
  1301. 1299          END SELECT
  1302. 1300        CASE "TIMER","TIM"                       ! Set-Timer (ON|OFF)
  1303. 1301          Timer=1
  1304. 1302          IF Cmds$(3)="OFF" THEN Timer=0
  1305. 1303        CASE "TRANSLATION","TRA","TRANS"
  1306. 1304          Ni=1
  1307. 1305        CASE "WINDOW","WIN"
  1308. 1306          Ni=1
  1309. 1307        CASE ELSE
  1310. 1308          Err_level=2
  1311. 1309        END SELECT     ! KERMIT SET COMMAND
  1312. 1310        OFF ERROR 
  1313. 1311   !=======================================================================
  1314. 1312   !            END  OF  SET  COMMANDS
  1315. 1313   !=======================================================================
  1316. 1314 Sz:!
  1317. 1315 Show:CASE "SHOW","SHO"     ! SHOW THE SET PARAMETERS
  1318. 1316        PRINT 
  1319. 1317        SELECT Cmds$(2)
  1320. 1318        CASE "COMMUNICATIONS","COM","COMM","TERMINAL","TERM"
  1321. 1319          PRINT "TERMINAL TYPE",TAB(35);Term_type$
  1322. 1320          PRINT "BAUD RATE",TAB(35);Baud
  1323. 1321          PRINT "COM PORT",TAB(35);Com_port
  1324. 1322          PRINT "LOCAL ECHO",TAB(35);Local_echo
  1325. 1323          PRINT "HANDSHAKE",TAB(35);Hshake$
  1326. 1324          PRINT "PARITY",TAB(35);Parity_type$,On_off$
  1327. 1325          PRINT "FLOW CONTROL",TAB(35);Flow$
  1328. 1326          PRINT "DEBUG",TAB(35);Debug
  1329. 1327          PRINT "MODEM LINES ACTIVE:  ";TAB(35);
  1330. 1328          STATUS Com_port,11;Ml
  1331. 1329          IF BIT(Ml,4) THEN PRINT "CTS  ";
  1332. 1330          IF BIT(Ml,5) THEN PRINT "DSR  ";
  1333. 1331          IF BIT(Ml,6) THEN PRINT "RI  ";
  1334. 1332          IF BIT(Ml,7) THEN PRINT "CD  ";
  1335. 1333          PRINT 
  1336. 1334          PRINT "TERMINAL LINES ACTIVE:  ";TAB(35);
  1337. 1335          STATUS Com_port,5;Ml
  1338. 1336          IF BIT(Ml,0) THEN PRINT "RTS  ";
  1339. 1337          IF BIT(Ml,1) THEN PRINT "DTR  ";
  1340. 1338          PRINT 
  1341. 1339        CASE "FILE"
  1342. 1340          PRINT "CURRENT MSI",TAB(35);Cur_msi$
  1343. 1341          PRINT "DEFAULT MSI",TAB(35);D_path$,D_msi$
  1344. 1342          PRINT "EOF MODE",TAB(35);Eof_mode$
  1345. 1343          PRINT "INCOMPLETE FILE",TAB(35);Discard
  1346. 1344          PRINT "FILE OVERWRITE",TAB(35);File_warn
  1347. 1345          PRINT "TAKE ECHO",TAB(35);Take_echo
  1348. 1346          PRINT "ATTRIBUTE PACKETS",TAB(35);Att_on
  1349. 1347        CASE "LOGGING","LOG"
  1350. 1348          PRINT "PACKET LOGGING",TAB(35);D_log
  1351. 1349          PRINT "PACKET LOG FILE",TAB(35);D_log$
  1352. 1350          PRINT "SESSION LOGGING",TAB(35);S_log
  1353. 1351          PRINT "SESSION LOG FILE",TAB(35);S_log$
  1354. 1352        CASE "MACRO","MAC"
  1355. 1353          IF No_define THEN 
  1356. 1354            PRINT USING VAL$(No_define)&"(10(K,2(X)),/)";Define$(*)
  1357. 1355          ELSE
  1358. 1356            PRINT "No MACROs currently defined"
  1359. 1357          END IF
  1360. 1358        CASE "MODEM"
  1361. 1359          PRINT "NOT IMPLEMENTED"
  1362. 1360        CASE "PROTOCOL"
  1363. 1361          CALL Kstatus
  1364. 1362        CASE "SERVER"
  1365. 1363          PRINT "NOT IMPLEMENTED"
  1366. 1364        CASE ELSE
  1367. 1365          PRINT "Syntax:  COMM , TERMINAL , FILE , LOG , MODEM , MACRO , PROTOCOL "
  1368. 1366        END SELECT
  1369. 1367        PRINT 
  1370. 1368        Supress_echo=1
  1371. 1369     !
  1372. 1370      CASE "SPACE","SPA"
  1373. 1371        IF NOT LEN(Cmds$(2)) THEN Cmds$(2)=D_msi$
  1374. 1372        Disc_space(Cmds$(2),Total,Largest_hole,Hole_sum,Format$)
  1375. 1373        Cmds$(2)=":"&Cmds$(2)[POS(Cmds$(2),",")]
  1376. 1374        CLEAR SCREEN
  1377. 1375        PRINT TABXY(1,Crt_lines);
  1378. 1376        PRINT "Volume:        ";Cmds$(2)
  1379. 1377        PRINT "Format:        ";Format$
  1380. 1378        PRINT "Space:         ";Total;TAB(35);Total*256
  1381. 1379        PRINT "Frags:         ";Hole_sum;TAB(35);Hole_sum*256
  1382. 1380        PRINT "Largest Hole:  ";Largest_hole;TAB(35);Largest_hole*256
  1383. 1381        PRINT 
  1384. 1382        Supress_echo=1
  1385. 1383      CASE "STATISTICS"
  1386. 1384        Ni=1
  1387. 1385      CASE "STATUS","STAT"       !
  1388. 1386        CALL Kstatus
  1389. 1387        Supress_echo=1
  1390. 1388      CASE "SUBMIT","SUB"    ! BATCH PROCESS
  1391. 1389        Ni=1
  1392. 1390 T:   CASE "TAKE","TAK"             ! execute a command file
  1393. 1391        ASSIGN @File TO Cmds$(2);RETURN Rc
  1394. 1392        IF Rc THEN GOTO Take_done
  1395. 1393        Init_file=1
  1396. 1394        Shell=1
  1397. 1395        IF NOT Init_file THEN PRINT TABXY(1,Crt_lines);"KERMIT Initialization File"
  1398. 1396        REPEAT
  1399. 1397          Init_cmd$=""
  1400. 1398          ENTER @File;Init_cmd$
  1401. 1399          Init_cmd$=UPC$(Init_cmd$)
  1402. 1400          Init_cmd$=Init_cmd$[POS(Init_cmd$,"!")+1]
  1403. 1401          Cmt=POS(Init_cmd$,"!")
  1404. 1402          IF Cmt THEN Init_cmd$=Init_cmd$[1,POS(Init_cmd$,"!")-1]      ! extract from line comment
  1405. 1403          IF NOT LEN(TRIM$(Init_cmd$)) THEN GOTO Skip_cmd
  1406. 1404          IF POS(Init_cmd$,"STOP") THEN 
  1407. 1405            Init_file=0
  1408. 1406            Kl$=""
  1409. 1407          ELSE
  1410. 1408            Cmt=POS(Init_cmd$,"COMMENT")
  1411. 1409            IF NOT Cmt THEN 
  1412. 1410              Kl$=Prompt$&Init_cmd$
  1413. 1411              Parse_kl(Kl$,Cmds$(*),No_cmds,Prompt$)! return Kl$ as Kl$(2..)
  1414. 1412              PRINT Cmds$(1)&" ";Kl$
  1415. 1413              GOSUB Kermit_exec
  1416. 1414            END IF
  1417. 1415          END IF
  1418. 1416 Skip_cmd:       !
  1419. 1417        UNTIL Init_file=0
  1420. 1418        Shell=0
  1421. 1419        Supress_echo=1
  1422. 1420 Take_done:DISP 
  1423. 1421      CASE "TRANSMIT","TRANS"     ! Transmit <filename> [format on/off]
  1424. 1422        IF NOT LEN(Cmds$(3)) THEN 
  1425. 1423          IF Cmds$(3)<>"OFF" AND Cmds$(3)<>"ON" THEN 
  1426. 1424            INPUT "Read File with Format ON or OFF ? ",Cmds$(3)
  1427. 1425            Cmds$(3)=UPC$(Cmds$(3))
  1428. 1426          END IF
  1429. 1427          CALL Transmit(Cmds$(2),Cmds$(3))
  1430. 1428        ELSE
  1431. 1429          CALL Transmit(Cmds$(2))
  1432. 1430        END IF
  1433. 1431   !  CASE "TYPE"  ! same as  PRINT
  1434. 1432 V:   CASE "VER","VERSION"
  1435. 1433        PRINT TABXY(1,Crt_lines);Version$
  1436. 1434 W:   CASE "WHO"
  1437. 1435        Ni=1
  1438. 1436 X:   CASE "XYZZY"
  1439. 1437        Msg$="I see no cave here."
  1440. 1438        Err_level=-1
  1441. 1439      CASE ELSE
  1442. 1440 Y:     Err_level=1   ! invalid kermit command
  1443. 1441 Z:!
  1444. 1442      END SELECT  ! KERMIT COMMANDS
  1445. 1443 !-------------------------------------------------------------------------
  1446. 1444   !
  1447. 1445   ! Process Err_level or echo command
  1448. 1446   !
  1449. 1447      SELECT Err_level
  1450. 1448      CASE 0   ! Valid command - check if implemented before echoing
  1451. 1449        IF Ni THEN 
  1452. 1450          PRINT Cmds$(1)&"  "&Kl$&"  NOT IMPLEMENTED"
  1453. 1451        ELSE
  1454. 1452          IF (Display AND (NOT Init_file)) OR (Init_file AND Take_echo) THEN 
  1455. 1453            IF (NOT In_term) AND (NOT Supress_echo) THEN 
  1456. 1454              PRINT Cmds$(1)&" "&Kl$&RPT$(" ",80)! command executed OK
  1457. 1455            END IF
  1458. 1456          END IF
  1459. 1457        END IF
  1460. 1458        Kl$=""
  1461. 1459      CASE -1
  1462. 1460        PRINT Msg$
  1463. 1461      CASE 1
  1464. 1462        PRINT CHR$(129);Cmds$(Err_level);CHR$(128);" not a KERMIT command"
  1465. 1463      CASE 2,3,4
  1466. 1464        Line$=""
  1467. 1465        FOR I=1 TO Err_level-1
  1468. 1466          Line$=Line$&Cmds$(I)&" "
  1469. 1467        NEXT I
  1470. 1468        PRINT Line$&CHR$(129);Cmds$(Err_level);CHR$(128);" ";Msg$
  1471. 1469      CASE 20,30,40
  1472. 1470        Err_level=Err_level/10
  1473. 1471        PRINT "Parameter # ";Err_level;"  Required"
  1474. 1472      CASE ELSE
  1475. 1473      END SELECT
  1476. 1474  !
  1477. 1475      IF Err_level THEN 
  1478. 1476        IF Err_level>1 THEN Kl$=Cmds$(1)&" "
  1479. 1477        IF Err_level>2 THEN Kl$=Kl$&Cmds$(2)&" "
  1480. 1478        IF Err_level>3 THEN Kl$=Kl$&Cmds$(3)&" "
  1481. 1479        IF Err_level=1 THEN 
  1482. 1480          Kl$=""
  1483. 1481        END IF
  1484. 1482        Err_level=0
  1485. 1483      END IF
  1486. 1484      Ni=0
  1487. 1485      Supress_echo=0
  1488. 1486      IF Shell THEN RETURN     ! recursive gosub to kermit command parser
  1489. 1487    UNTIL Remote OR Kermit_exit
  1490. 1488    SUBEXIT
  1491. 1489 !---------------------------------
  1492. 1490 Valerr_4:  ! BAD VALUE IN SET-RECEIVE
  1493. 1491    Err_level=4
  1494. 1492    IF NOT LEN(Cmds$(4)) THEN Err_level=40
  1495. 1493    ERROR RETURN
  1496. 1494    RETURN 
  1497. 1495 !------------------------------------
  1498. 1496 Valerr_3:!
  1499. 1497    Err_level=3
  1500. 1498    IF NOT LEN(Cmds$(3)) THEN Err_level=30  ! missing third parameter
  1501. 1499    ERROR RETURN
  1502. 1500    RETURN 
  1503. 1501 !------------------------------------------
  1504. 1502 K_error: !
  1505. 1503    SELECT ERRN
  1506. 1504    CASE 76        ! INCORRECT MSVS
  1507. 1505      PRINT ERRM$
  1508. 1506      Rc=76
  1509. 1507      ERROR RETURN
  1510. 1508    CASE 59        ! EOF
  1511. 1509      Init_file=0
  1512. 1510      PRINT "End OF File"
  1513. 1511      ERROR RETURN
  1514. 1512    CASE ELSE
  1515. 1513      PRINT "KERMIT: ";ERRM$
  1516. 1514      ERROR RETURN
  1517. 1515    END SELECT
  1518. 1516    RETURN 
  1519. 1517 !-----------------------------------------
  1520. 1518  SUBEND
  1521. 1519 ! =====================================================================
  1522. 1520 Parser:SUB Parse_kl(Kl$,Cmds$(*),No_cmds,Prompt$)
  1523. 1521 Parse:!
  1524. 1522    Kl$=TRIM$(UPC$(Kl$))
  1525. 1523    DIM Kl_return$[100]
  1526. 1524    MAT Cmds$= ("")
  1527. 1525    Begin_cmd=POS(Kl$,Prompt$)+LEN(Prompt$)
  1528. 1526    IF Begin_cmd=LEN(Prompt$) THEN SUBEXIT
  1529. 1527    Kl$=TRIM$(Kl$[Begin_cmd,LEN(Kl$)])   ! SEPARATE OFF PROMPT
  1530. 1528    I=0
  1531. 1529    REPEAT
  1532. 1530      I=I+1
  1533. 1531      Cmd_end=POS(Kl$," ")
  1534. 1532      IF Cmd_end=0 THEN      ! IF NO BLANKS THEN KL$= LAST COMMAND
  1535. 1533        Cmds$(I)=Kl$[1,80]
  1536. 1534        No_cmds=I
  1537. 1535        Parse_done=1
  1538. 1536      ELSE
  1539. 1537        Cmds$(I)=Kl$[1,Cmd_end-1]
  1540. 1538      END IF
  1541. 1539      IF I=2 THEN Kl_return$=Kl$         ! No, Return Null if single cmd
  1542. 1540      Kl$=TRIM$(Kl$[Cmd_end+1])          ! TRUNCATE KL$
  1543. 1541    !
  1544. 1542    ! Return the argument line (cmd 2-end) as Kl$
  1545. 1543    !
  1546. 1544   !
  1547. 1545   ! Eliminate any Quote Marks in Command
  1548. 1546   !
  1549. 1547      REPEAT
  1550. 1548        Qm=POS(Cmds$(I),"""")
  1551. 1549        IF Qm THEN Cmds$(I)[Qm,Qm]=" "
  1552. 1550      UNTIL Qm=0
  1553. 1551      Cmds$(I)=TRIM$(Cmds$(I))
  1554. 1552   !
  1555. 1553    UNTIL Parse_done
  1556. 1554    Kl$=Kl_return$
  1557. 1555  SUBEND
  1558. 1556 !=========================================================================
  1559. 1557 Transmit:SUB Transmit(Filename$,OPTIONAL Fmt$)
  1560. 1558 Tr:!
  1561. 1559    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  1562. 1560    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  1563. 1561    DIM Line$[256],Out_buff$[512] BUFFER,K$[80],A$[1]
  1564. 1562    REAL Real_no
  1565. 1563    INTEGER Int_no,Slow,Abort_txmit
  1566. 1564  !
  1567. 1565  ! PRINTER IS CRT;EOL ("
  1568. "),WIDTH OFF
  1569. 1566    ON ERROR GOSUB Txmit_err
  1570. 1567    Fmt_onoff$="ON"
  1571. 1568    IF NPAR>1 THEN Fmt_onoff$=Fmt$
  1572. 1569    REPEAT
  1573. 1570      IF Fmt_onoff$="OFF" THEN 
  1574. 1571        ASSIGN @File TO Filename$;FORMAT OFF,RETURN Rc
  1575. 1572      ELSE
  1576. 1573        ASSIGN @File TO Filename$;FORMAT ON,RETURN Rc
  1577. 1574      END IF
  1578. 1575      IF Rc<>0 THEN  ! File Couldn't Be Opened
  1579. 1576        DISP "Can't open file:  ";Filename$;"  (blank name to abort)"
  1580. 1577        OUTPUT KBD;Filename$;" H";
  1581. 1578        ENTER KBD;Filename$
  1582. 1579        Filename$=TRIM$(Filename$)
  1583. 1580        DISP 
  1584. 1581        IF NOT (LEN(Filename$)) THEN SUBEXIT
  1585. 1582      END IF
  1586. 1583    UNTIL Rc=0
  1587. 1584  !
  1588. 1585    DISP "Transmitting FILE: ";Filename$;"   CTRL-C to Exit   CTRL-S  Screen"
  1589. 1586 Get_type:STATUS @File,1;File_type
  1590. 1587    SELECT File_type
  1591. 1588    CASE 2    ! BDAT
  1592. 1589      INPUT "ASCII / INTEGERS / REALS  ?  [ A / I / R ] ",Data_type$
  1593. 1590    CASE 3    ! ASCII
  1594. 1591      Data_type$="ASCII"
  1595. 1592    CASE 4    ! HPUX
  1596. 1593      Data_type$="ASCII"
  1597. 1594    END SELECT
  1598. 1595    ON END @File GOTO Txmit_done
  1599. 1596    ON KBD,2 GOSUB K_serve
  1600. 1597    Startup
  1601. 1598    Scr_echo=1
  1602. 1599    LOOP
  1603. 1600    EXIT IF Abort_txmit=1
  1604. 1601      SELECT UPC$(Data_type$[1,1])
  1605. 1602      CASE "A"
  1606. 1603        ENTER @File;Line$   ! Enter the line and convert to Ascii
  1607. 1604        OUTPUT @Out_buff;Line$     ! Line Used for DMA Transmit
  1608. 1605        IF Scr_echo THEN PRINT Line$
  1609. 1606      CASE "R"
  1610. 1607        DISP "Transmitting REALS from FILE: ";File_name$
  1611. 1608        LOOP
  1612. 1609          ENTER @File;Real_no
  1613. 1610          DISP "TRANSMITTING RECORD # ";Rec,Line$
  1614. 1611          OUTPUT @Out_buff;Real_no   ! This Will Convert REAL to Ascii
  1615. 1612          IF Scr_echo THEN PRINT Real_no
  1616. 1613        END LOOP
  1617. 1614      CASE "I"
  1618. 1615        ENTER @File;Int_no
  1619. 1616        OUTPUT @Out_buff;Int_no
  1620. 1617        IF Scr_echo THEN PRINT Int_no
  1621. 1618      CASE ELSE
  1622. 1619        BEEP 
  1623. 1620        INPUT "BAD DATA TYPE - INPUT AGAIN ",Data_type$
  1624. 1621      END SELECT
  1625. 1622      Rec=Rec+1
  1626. 1623      GOSUB Response
  1627. 1624    END LOOP
  1628. 1625 Txmit_done:  !
  1629. 1626    INPUT "Enter any End-of-file mark to send: ",Endofile$
  1630. 1627    IF LEN(Endofile$) THEN 
  1631. 1628      OUTPUT @Out_buff;Endofile$
  1632. 1629    END IF
  1633. 1630    DISP "File Transfer Complete "
  1634. 1631    ASSIGN @File TO *
  1635. 1632    OFF ERROR 
  1636. 1633    OFF KBD
  1637. 1634    Shutdown
  1638. 1635    SUBEXIT    ! Return to Kermit
  1639. 1636 !-----------------------------------------------------------------------
  1640. 1637 Response:!
  1641. 1638    DISABLE 
  1642. 1639    IF Com_card=98628 THEN 
  1643. 1640      STATUS Com_port,5;In_length
  1644. 1641    ELSE
  1645. 1642      STATUS @In_buff,4;In_length
  1646. 1643    END IF
  1647. 1644  !
  1648. 1645    WHILE In_length
  1649. 1646      ENTER @In_buff USING "#,A";A$
  1650. 1647      Char=NUM(A$)
  1651. 1648 Handle_char: !
  1652. 1649      SELECT Char
  1653. 1650      CASE 32 TO 126      ! sp to ~
  1654. 1651        PRINT A$;
  1655. 1652    !-----------------------------------------
  1656. 1653    ! SELECTED CONTROL CHARACTERS
  1657. 1654    !-----------------------------------------
  1658. 1655      CASE 5                        !""         ! ENQ/ACK
  1659. 1656        OUTPUT @Out_buff;CHR$(6);
  1660. 1657      CASE 10
  1661. 1658        PRINT "
  1662. ";
  1663. 1659      CASE 13
  1664. 1660        PRINT "";
  1665. 1661      CASE 7
  1666. 1662        BEEP 800,.1
  1667. 1663      CASE 8                          !     Backspace
  1668. 1664        STATUS CRT,0;Cx
  1669. 1665        CONTROL CRT,0;MAX(Cx-1,1)
  1670. 1666      CASE 17    !
  1671. 1667        K$=KBD$
  1672. 1668        ENABLE 
  1673. 1669        RETURN 
  1674. 1670      CASE ELSE
  1675. 1671        WAIT .3
  1676. 1672      END SELECT
  1677. 1673 Skip_cp:   !
  1678. 1674      IF Com_card=98628 THEN 
  1679. 1675        STATUS Com_port,5;In_length
  1680. 1676      ELSE
  1681. 1677        STATUS @In_buff,4;In_length
  1682. 1678      END IF
  1683. 1679    END WHILE
  1684. 1680    ENABLE 
  1685. 1681    RETURN 
  1686. 1682 !--------------------------------------
  1687. 1683 Txmit_err:  !
  1688. 1684    BEEP 
  1689. 1685    DISP ERRM$&"  PAUSED "
  1690. 1686    PAUSE
  1691. 1687    RETURN 
  1692. 1688!---------------------------------------
  1693. 1689 K_serve: !
  1694. 1690    K$=KBD$
  1695. 1691    SELECT K$
  1696. 1692    CASE " E","  E"
  1697. 1693      Abort_txmit=0
  1698. 1694    CASE ""            ! CTRL-S
  1699. 1695      IF Scr_echo THEN 
  1700. 1696        Scr_echo=0
  1701. 1697      ELSE
  1702. 1698        Scr_echo=1
  1703. 1699      END IF
  1704. 1700    CASE ELSE
  1705. 1701      Abort_txmit=1
  1706. 1702    END SELECT
  1707. 1703    Ok_cont=1
  1708. 1704    RETURN 
  1709. 1705  SUBEND
  1710. 1706! ======================================================================
  1711. 1707  SUB Terminal(OPTIONAL Phone$,Modinit$,Modem$)
  1712. 1708    OPTION BASE 1
  1713. 1709    COM Version$,K$,Setup$
  1714. 1710    COM /Crt/ Crt_lines,Crt_width
  1715. 1711    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  1716. 1712    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  1717. 1713    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  1718. 1714    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$[3],Parity_type$[4]
  1719. 1715    COM /Frame/ Flow$,Hshake$
  1720. 1716    COM /Term/ Term_type$[10],S_log,D_log,Filewarn,Discard,@S_log,@D_log
  1721. 1717    COM /Term/ Kerm_esc$[2],S_log$,D_log$,INTEGER Remote,Lecho,Turn,Display
  1722. 1718    COM /Term/ Term_mode$
  1723. 1719    COM /Path/ Cur_msi$,S_path$,S_msi$,D_path$,D_msi$
  1724. 1720    COM /Mode/ Mode_line,Newline
  1725. 1721 !
  1726. 1722    DIM A$[80],Hlchar$[1]
  1727. 1723    DIM Key1$[1],Key2$[1],Key3$[1],Esc_seq$[5]
  1728. 1724    INTEGER Cx,Cy,Save_cx,Save_cy,Hl,Hlx,Hly,Ie,If,Il
  1729. 1725    INTEGER Key1,Key2,Key3,Oe,Of,Ol
  1730. 1726    INTEGER Max_buff,Xoff,R_xoff
  1731. 1727    DIM File_buff$[256]
  1732. 1728    Max_buff=MAXLEN(File_buff$)
  1733. 1729    DIM Line$[256]
  1734. 1730    DIM Dial_ext$[80]
  1735. 1731 !
  1736. 1732 ! Vt100 escape processor  (Receive_char)
  1737. 1733 !
  1738. 1734    DIM Esc_seq_str$[20]      !  ,Esc_buf$(0:10)[1]
  1739. 1735    INTEGER Esc_colon(0:5)
  1740. 1736    INTEGER Pn0,Pn1,Pn2,Pn3
  1741. 1737    INTEGER Buf_ptr,Ec,Esc_length,Max_esc_length
  1742. 1738 !
  1743. 1739 Term:!
  1744. 1740    Max_esc_length=10     ! tunable - max length for vt100 seq before abort
  1745. 1741    Blink=.2                               ! cursor speed
  1746. 1742    IF Debug THEN Blink=100
  1747. 1743    In_term=1                              ! In-Terminal Flag
  1748. 1744  ! IF Crt_lines>26 THEN ALPHA HEIGHT 31   ! 24 line terminal emulator
  1749. 1745  !
  1750. 1746  ! Trying to get a 24 line emulator - needs work
  1751. 1747  !
  1752. 1748    SYSTEM PRIORITY 0               ! In case terminal is accidentally
  1753. 1749                                    ! entered recursively form kermit
  1754. 1750    !-------------------------------]
  1755. 1751    ! Interrupt Levels for TERM:
  1756. 1752    !
  1757. 1753    ! 1- Idle Loop - Receive Char
  1758. 1754    !    ON TIMEOUT - Com_port
  1759. 1755    !    ON CYCLE Blink Cursor
  1760. 1756    ! 3- ON KBD Send Character KBD
  1761. 1757    ! 4-
  1762. 1758    ! 5- ON INTR COM_PORT
  1763. 1759    !--------------------------------
  1764. 1760    PRINTER IS CRT;EOL (CHR$(10)),WIDTH OFF
  1765. 1761  ! CONTROL CRT,21;1                     ! clear screen and color map
  1766. 1762    CLEAR SCREEN
  1767. 1763    IF NOT Debug THEN CONTROL CRT,10;0   ! CURSOR OFF
  1768. 1764    Cx=1
  1769. 1765    Cy=1
  1770. 1766    CONTROL CRT,0;Cx,Cy                  ! home cursor
  1771. 1767    Hlx=1                                ! cursor highlight position
  1772. 1768    Hly=1
  1773. 1769   !------------------  SET  ON-EVENTs  Before TRANSFER starts
  1774. 1770    CALL Shutdown        !shutoff transfers if on
  1775. 1771 !  ON INTR Com_port,5 GOSUB Term_intr
  1776. 1772    SELECT Com_card
  1777. 1773    CASE 98626,98644
  1778. 1774      CONTROL Com_port,5;1+2            ! Force DTR and RTS Active
  1779. 1775      IF Hshake$="NONE" THEN            ! Disable Modem HS Lines
  1780. 1776        CONTROL Com_port,12;128+32+16   ! 128=DTR  32=RTS  16=CTS
  1781. 1777      ELSE
  1782. 1778        CONTROL Com_port,12;0       ! Enable Modem HS Lines
  1783. 1779      END IF
  1784. 1780  !   ENABLE INTR Com_port;8+4
  1785. 1781    CASE 98628
  1786. 1782      CONTROL Com_port,8;1+2        ! RTS  DTR  Set Active
  1787. 1783    ! CONTROL Com_port,13;164       ! INT MASK  UART/lost car/break
  1788. 1784    ! CONTROL 23; for HS Lines
  1789. 1785    END SELECT
  1790. 1786   !----------------------------------
  1791. 1787    ON ERROR GOSUB Term_err
  1792. 1788    ON KBD,3 GOSUB Send_char
  1793. 1789    ON TIMEOUT Com_port,10 GOSUB Com_tmo
  1794. 1790    IF NOT Debug THEN ON CYCLE Blink,1 GOSUB Blink
  1795. 1791    CALL Startup
  1796. 1792    STATUS @In_buff,2;Inbuff_size
  1797. 1793    Inbuff_max=.8*Inbuff_size
  1798. 1794    Inbuff_min=.6*Inbuff_size
  1799. 1795    GOSUB Disp_modeline
  1800. 1796    IF NPAR THEN GOSUB Dial_modem
  1801. 1797    REPEAT
  1802. 1798      GOSUB Get_inlength                        ! XON / XOFF
  1803. 1799      IF In_length THEN 
  1804. 1800        GOSUB Receive_char
  1805. 1801      END IF
  1806. 1802    UNTIL Remote=0             ! terminal escape seq trapped in Send_char
  1807. 1803!
  1808. 1804    CONTROL CRT,10;1           ! restore system cursor
  1809. 1805    IF Hl THEN GOSUB Blink     ! remove cursor turds
  1810. 1806    In_term=0                  ! notify Kermit we're out
  1811. 1807    SUBEXIT
  1812. 1808 !========================================================================
  1813. 1809 Disp_modeline:!
  1814. 1810    GCLEAR
  1815. 1811    IF Mode_line THEN 
  1816. 1812      WINDOW 0,80,26,0
  1817. 1813      MOVE 0,26
  1818. 1814      CSIZE 3
  1819. 1815      Kesc_char$=CHR$(NUM(Kerm_esc$[1,1])+64)
  1820. 1816      LABEL "ESC: ^";Kesc_char$;"C  ";Baud;Data_bits;Parity_type$;"  ";On_off$;
  1821. 1817      IF S_log THEN LABEL "  LOG"
  1822. 1818    END IF
  1823. 1819    RETURN 
  1824. 1820 !-------------------------------------------------------------------------
  1825. 1821 Term_intr: !
  1826. 1822    CALL Com_interrupt
  1827. 1823 !
  1828. 1824 ! ON INTR BRANCHES Must be setup with transfers off
  1829. 1825 !
  1830. 1826    Shutdown
  1831. 1827 !  ON INTR Com_port,5 GOSUB Term_intr
  1832. 1828    SELECT Com_card
  1833. 1829    CASE 98628
  1834. 1830      CONTROL Com_port,13;164      ! MASK  4=UART  32=lost carr 128=break
  1835. 1831    CASE 98626,98644
  1836. 1832  !   ON INTR Com_port,1 GOSUB Term_intr
  1837. 1833      ENABLE INTR Com_port;8+4
  1838. 1834    END SELECT
  1839. 1835    ON ERROR GOSUB Term_err
  1840. 1836    Startup
  1841. 1837    RETURN 
  1842. 1838 !----------------------------------------------------------------------
  1843. 1839 Blink:!
  1844. 1840    IF NOT Hl THEN 
  1845. 1841   !
  1846. 1842   ! Produce underscore at current print position
  1847. 1843   ! Establish the current (legal) print position
  1848. 1844   ! And read the crt character at that position
  1849. 1845   !
  1850. 1846      DISABLE        ! disable kbd interrupt
  1851. 1847      STATUS CRT,0;Hlx,Hly
  1852. 1848      Hly=MAX(Hly,1)
  1853. 1849      IF Hly>Crt_lines THEN 
  1854. 1850        Need_scroll=1
  1855. 1851        Hly=MIN(Crt_lines,Hly)    ! hlx=20 after CR on line 19
  1856. 1852      END IF
  1857. 1853    !
  1858. 1854      IF Hlx>80 THEN          ! fixes bug with pos 81 printing in pos 80
  1859. 1855        Hlx=80
  1860. 1856        Wrap=1
  1861. 1857        CONTROL CRT,0;Hlx,Hly ! move to 80
  1862. 1858        IF Hly<=Crt_lines THEN ENTER CRT USING "#,K";Hlchar$
  1863. 1859      ELSE
  1864. 1860        ! leave cx and cy where they are
  1865. 1861        IF Hly<=Crt_lines THEN ENTER CRT USING "#,K";Hlchar$
  1866. 1862      END IF
  1867. 1863    !
  1868. 1864    ! If crt char is null then make it a space
  1869. 1865    !
  1870. 1866      IF Hlchar$="" THEN Hlchar$=" "
  1871. 1867      STATUS CRT,4;Dfm   ! Check Display Functions Mode
  1872. 1868      IF NOT Dfm THEN    ! Don't display CHR$(132) with Display functions on
  1873. 1869    !
  1874. 1870    ! Draw (or redraw) the character with an underscore
  1875. 1871    !
  1876. 1872        PRINT TABXY(Hlx,Hly);CHR$(132);Hlchar$;CHR$(128);
  1877. 1873      END IF
  1878. 1874    !
  1879. 1875    ! Wrap flag indicates that the cursor has moved to a new line
  1880. 1876    !
  1881. 1877      IF Need_scroll THEN 
  1882. 1878        PRINT 
  1883. 1879        Need_scroll=0
  1884. 1880      END IF
  1885. 1881  !
  1886. 1882      IF Wrap THEN              ! wrap around, but leave hlx,hly at 81,hly
  1887. 1883        CONTROL CRT,0;1,Hly+1
  1888. 1884        Wrap=0
  1889. 1885      ELSE
  1890. 1886        CONTROL CRT,0;Hlx,Hly   ! highlighting pushes cursor ahead 1 pos
  1891. 1887      END IF
  1892. 1888    !
  1893. 1889      Hl=1
  1894. 1890      ENABLE 
  1895. 1891  ! END IF
  1896. 1892  !
  1897. 1893    ELSE      !============================================================
  1898. 1894 Unblink: !
  1899. 1895 Ub:!
  1900. 1896  ! Un-blink, remove the underscore
  1901. 1897  !
  1902. 1898      DISABLE 
  1903. 1899      IF Bld THEN PAUSE
  1904. 1900  !
  1905. 1901  !  Record current print position
  1906. 1902  !  Move to underscore highlight
  1907. 1903  !
  1908. 1904      STATUS CRT,0;Cx,Cy      ! remember current cursor
  1909. 1905      IF Ub THEN PAUSE
  1910. 1906      !
  1911. 1907      IF Cy>Crt_lines THEN 
  1912. 1908        Need_scroll=1
  1913. 1909  !  Cy=Crt_lines                 ! leave cy=20
  1914. 1910  !   Cy=MIN(Crt_lines,Cy)
  1915. 1911      END IF
  1916. 1912      CONTROL CRT,0;Hlx,Hly   ! locate to old cursor position
  1917. 1913  !
  1918. 1914  ! Enter the crt char at the old underscore
  1919. 1915  !
  1920. 1916      IF Hly<=Crt_lines THEN ENTER CRT USING "#,K";Hlchar$  ! #A doesn't enter null
  1921. 1917  !
  1922. 1918  ! The underscore can't be a null (remove this code)
  1923. 1919  !
  1924. 1920  ! CRT space characters get entered as nulls ???
  1925. 1921  !
  1926. 1922      IF Hlchar$="" THEN 
  1927. 1923        Hlchar$=" "                                ! avoid null
  1928. 1924      ELSE  ! we have just cleared a character at the end of the line - move
  1929. 1925        IF Cx=80 THEN     ! wrap around
  1930. 1926          IF Hlx=80 THEN 
  1931. 1927            Cy=MIN(Crt_lines,Cy+1)
  1932. 1928            Cx=1
  1933. 1929          END IF
  1934. 1930        END IF
  1935. 1931      END IF
  1936. 1932   !
  1937. 1933   ! redraw the character without the underscore
  1938. 1934   !
  1939. 1935      STATUS CRT,4;Dfm
  1940. 1936      IF NOT Dfm THEN 
  1941. 1937        PRINT TABXY(Hlx,Hly);CHR$(128);Hlchar$;        ! unhighlight
  1942. 1938      END IF
  1943. 1939   !
  1944. 1940   ! Restore the current print position
  1945. 1941   !
  1946. 1942      IF Need_scroll THEN 
  1947. 1943        PRINT 
  1948. 1944        Need_scroll=0
  1949. 1945      END IF
  1950. 1946   !
  1951. 1947      CONTROL CRT,0;Cx,Cy
  1952. 1948      Hl=0
  1953. 1949      ENABLE 
  1954. 1950    END IF  ! hl on or not
  1955. 1951    IF Debug THEN ON CYCLE Blink,1 GOSUB Blink
  1956. 1952    RETURN 
  1957. 1953 !-----------------------------------------------------------------------
  1958. 1954 Dial_modem:!
  1959. 1955    STATUS Com_port,10;Uart
  1960. 1956 !  Dial_ext$=",,,add your phone card # here "
  1961. 1957    IF NPAR>1 THEN 
  1962. 1958      OUTPUT @Out_buff;Modinit$
  1963. 1959    ELSE
  1964. 1960      OUTPUT @Out_buff;"AT L2 C1 "
  1965. 1961    END IF
  1966. 1962    WAIT .5
  1967. 1963    OUTPUT @Out_buff;"ATDT"&Phone$&Dial_ext$
  1968. 1964    RETURN 
  1969. 1965  !------------------------------------------------
  1970. 1966 Send_char:!
  1971. 1967 Sc:!
  1972. 1968    K$=KBD$
  1973. 1969 K: LOOP
  1974. 1970      IF NOT LEN(K$) THEN 
  1975. 1971        GOSUB Receive_char
  1976. 1972        K$=KBD$  ! Check For any keys pressed during Receive_char
  1977. 1973        IF NOT LEN(K$) THEN RETURN 
  1978. 1974      END IF
  1979. 1975 !
  1980. 1976 ! Process K$
  1981. 1977 !----------------------------
  1982. 1978      Key1$=K$[1,1]
  1983. 1979      Key1=NUM(Key1$)
  1984. 1980      K$=K$[2]
  1985. 1981      IF Key1=255 THEN         ! Function Key
  1986. 1982        Key2=NUM(K$)
  1987. 1983        Key2$=CHR$(Key2)
  1988. 1984        K$=K$[2]
  1989. 1985  !
  1990. 1986        IF Key2=255 THEN        ! CTRL + Function Key
  1991. 1987          Key3=NUM(K$)
  1992. 1988          Key3$=CHR$(Key3)
  1993. 1989          K$=K$[2]
  1994. 1990          SELECT Key3$
  1995. 1991          ! Not using any CTRL-Function Keys
  1996. 1992          CASE "E"   ! E
  1997. 1993            IF Kp_mode$="APPL" AND R_xoff=0 THEN OUTPUT @Out_buff;"OM";
  1998. 1994          END SELECT
  1999. 1995        ELSE                             ! Function Key    >
  2000. 1996          SELECT Key2$
  2001. 1997          CASE "E","X"                   ! ENTER
  2002. 1998            IF Newline THEN 
  2003. 1999              IF R_xoff=0 THEN OUTPUT @Out_buff;"
  2004. ";  ! CR-LF
  2005. 2000              IF Lecho THEN 
  2006. 2001                IF Hl THEN GOSUB Blink
  2007. 2002                PRINT "
  2008. ";
  2009. 2003              END IF
  2010. 2004            ELSE
  2011. 2005              IF R_xoff=0 THEN OUTPUT @Out_buff;"";
  2012. 2006              IF Lecho THEN PRINT "";
  2013. 2007            END IF
  2014. 2008 !------------------------------------------------ log session
  2015. 2009            IF S_log THEN 
  2016. 2010              File_buff$=File_buff$&"
  2017. "
  2018. 2011              Fblen=LEN(File_buff$)
  2019. 2012              IF Fblen>=Max_buff-20 THEN 
  2020. 2013                DISP CHR$(129);" ";CHR$(128)
  2021. 2014                OUTPUT @S_log;File_buff$;
  2022. 2015                DISP 
  2023. 2016                File_buff$=""
  2024. 2017              END IF
  2025. 2018            END IF
  2026. 2019 !-----------------------------------------------------------
  2027. 2020 Vt100:! vt-100 Esc Sequences implemented here                         VT100
  2028. 2021 !-----------------------------------------------------------
  2029. 2022          CASE "B"                       ! Backspace (Del)
  2030. 2023            IF R_xoff=0 THEN OUTPUT @Out_buff;CHR$(8);
  2031. 2024            IF Lecho THEN PRINT "";
  2032. 2025  !
  2033. 2026  ! In Cursor_mode$=VT52 action is not taken locally so that the
  2034. 2027  ! remote vi session will echo back the proper character.
  2035. 2028  !
  2036. 2029          CASE "<"                       ! Left Arrow
  2037. 2030            IF Cursor_mode$="VT52" THEN 
  2038. 2031              IF R_xoff=0 THEN OUTPUT @Out_buff;"OD";
  2039. 2032            ELSE
  2040. 2033              IF R_xoff=0 THEN OUTPUT @Out_buff;"D";
  2041. 2034              STATUS CRT,0;Px,Py
  2042. 2035              CONTROL CRT,0;MAX(1,Px-1),Py
  2043. 2036            END IF
  2044. 2037          CASE ">"                       ! Right Arrow
  2045. 2038            IF Cursor_mode$="VT52" THEN 
  2046. 2039              IF R_xoff=0 THEN OUTPUT @Out_buff;"OC";
  2047. 2040            ELSE
  2048. 2041              IF R_xoff=0 THEN OUTPUT @Out_buff;"C";
  2049. 2042              STATUS CRT,0;Px,Py
  2050. 2043              CONTROL CRT,0;MIN(Crt_width,Px+1),Py
  2051. 2044            END IF
  2052. 2045          CASE "^"
  2053. 2046            IF Cursor_mode$="VT52" THEN 
  2054. 2047              IF R_xoff=0 THEN OUTPUT @Out_buff;"OA";
  2055. 2048            ELSE
  2056. 2049              IF R_xoff=0 THEN OUTPUT @Out_buff;"A";
  2057. 2050              STATUS CRT,0;Px,Py
  2058. 2051              CONTROL CRT,0;Px,MAX(1,Py-1)
  2059. 2052            END IF
  2060. 2053          CASE "V"                          ! Down Arrow
  2061. 2054            IF Cursor_mode$="VT52" THEN 
  2062. 2055              IF R_xoff=0 THEN OUTPUT @Out_buff;"OB";
  2063. 2056            ELSE
  2064. 2057              IF R_xoff=0 THEN OUTPUT @Out_buff;"B";
  2065. 2058              STATUS CRT,0;Px,Py
  2066. 2059              CONTROL CRT,0;Px,Py+1
  2067. 2060            END IF
  2068. 2061          CASE "\"                             ! home
  2069. 2062            IF R_xoff=0 THEN OUTPUT @Out_buff;"H";
  2070. 2063            CONTROL CRT,0;1,1
  2071. 2064          CASE "%"                             ! clr-end
  2072. 2065            IF R_xoff=0 THEN OUTPUT @Out_buff;"";
  2073. 2066            STATUS CRT,9;Crt_width
  2074. 2067            STATUS CRT,0;Cx
  2075. 2068            PRINT RPT$(" ",Crt_width-Cx);
  2076. 2069          CASE "#"                             ! clr-line
  2077. 2070            IF R_xoff=0 THEN OUTPUT @Out_buff;"";
  2078. 2071            CONTROL CRT,0;1
  2079. 2072            STATUS CRT,9;Crt_width
  2080. 2073            PRINT RPT$(" ",Crt_width);
  2081. 2074          CASE "K"                             ! cls
  2082. 2075            IF R_xoff=0 THEN OUTPUT @Out_buff;"H"
  2083. 2076            CLEAR SCREEN
  2084. 2077            GOSUB Disp_modeline
  2085. 2078          CASE "U"                             ! caps lock
  2086. 2079            STATUS KBD,0;Capstat
  2087. 2080            IF Capstat THEN 
  2088. 2081              CONTROL KBD,0;0
  2089. 2082            ELSE
  2090. 2083              CONTROL KBD,0;1
  2091. 2084            END IF
  2092. 2085          CASE ")"                            ! tab ==>
  2093. 2086            IF R_xoff=0 THEN OUTPUT @Out_buff;"C";
  2094. 2087            STATUS CRT,0;Cx
  2095. 2088            CONTROL CRT,0;Cx+8
  2096. 2089          CASE ELSE
  2097. 2090            BEEP 300,.01     ! this function key not implemented
  2098. 2091          END SELECT
  2099. 2092        END IF   ! CTRL - Function Key
  2100. 2093      END IF     ! Fuunction Key
  2101. 2094 !
  2102. 2095 !----------------   Ascii and  CTRL-Ascii Processing
  2103. 2096 !
  2104. 2097 Ak:!
  2105. 2098      SELECT Key1
  2106. 2099 Kesc:CASE NUM(Kerm_esc$[1,1])           !  KERMIT Escape  CTRL-]
  2107. 2100        DISP "C: Exit  B:Break  K:Kermit Q:Stop Log  R:Resume Log  M: Modeline E: Echo  N: Nl"
  2108. 2101        Esc_seq$=K$[1,1]
  2109. 2102        WHILE LEN(Esc_seq$)<1    ! Wait for Kermit Escape Completion
  2110. 2103          K$=KBD$
  2111. 2104          Esc_seq$=K$[1,1]
  2112. 2105        END WHILE
  2113. 2106        SELECT UPC$(Esc_seq$)    ! Second Sequence of Kermit Escape
  2114. 2107        CASE "C"                                ! cancel - exit
  2115. 2108          Remote=0
  2116. 2109          OFF KBD
  2117. 2110          IF Mode_line THEN GCLEAR
  2118. 2111          CLEAR SCREEN
  2119. 2112          STATUS @S_log,0;S
  2120. 2113          IF S THEN ASSIGN @S_log TO *
  2121. 2114          S_log=0
  2122. 2115        CASE "B"                                ! send break
  2123. 2116          IF Com_card=98628 THEN 
  2124. 2117            BREAK Com_port
  2125. 2118          ELSE
  2126. 2119            Shutdown
  2127. 2120            BREAK Com_port
  2128. 2121            Startup
  2129. 2122          END IF
  2130. 2123     !    OUTPUT @Out_buff;""     ! work around for FIDO Bulletin Board
  2131. 2124        CASE "S"                                ! stat
  2132. 2125          CALL Kstatus
  2133. 2126          PRINTER IS CRT;EOL (CHR$(10)),WIDTH OFF
  2134. 2127        CASE "Q"                                ! stop logging
  2135. 2128          IF S_log THEN 
  2136. 2129            STATUS @S_log,0;S
  2137. 2130            IF S THEN OUTPUT @S_log;File_buff$;END
  2138. 2131            File_buff$=""
  2139. 2132          END IF
  2140. 2133          S_log=0
  2141. 2134          GOSUB Disp_modeline
  2142. 2135        CASE "R"                                ! resume logging
  2143. 2136          S_log=1
  2144. 2137          GOSUB Disp_modeline
  2145. 2138        CASE "O","0"                            ! transmit null
  2146. 2139          IF R_xoff=0 THEN OUTPUT @Out_buff;"";
  2147. 2140        CASE "?"                                ! help
  2148. 2141        CASE "K"                                ! Kermit Shell
  2149. 2142          PRINTER IS CRT
  2150. 2143          CALL Kermit
  2151. 2144          Remote=1      ! (stay in emulator)
  2152. 2145          Kermit_exit=0
  2153. 2146          CONTROL CRT,10;0
  2154. 2147          PRINTER IS CRT;EOL (CHR$(10)),WIDTH OFF
  2155. 2148          GOSUB Disp_modeline
  2156. 2149        CASE "E"
  2157. 2150          IF Lecho THEN 
  2158. 2151            Lecho=0
  2159. 2152          ELSE
  2160. 2153            Lecho=1
  2161. 2154          END IF
  2162. 2155        CASE "M"          ! Toggle Mode Line
  2163. 2156          IF Mode_line THEN 
  2164. 2157            Mode_line=0
  2165. 2158          ELSE
  2166. 2159            Mode_line=1
  2167. 2160          END IF
  2168. 2161          GOSUB Disp_modeline
  2169. 2162        CASE "N"     ! toggle newline
  2170. 2163          IF Newline THEN 
  2171. 2164            Newline=0
  2172. 2165          ELSE
  2173. 2166            Newline=1
  2174. 2167          END IF
  2175. 2168        CASE ELSE
  2176. 2169        END SELECT         ! second char of kermit terminal escape
  2177. 2170        DISP 
  2178. 2171    !----------------------------------------------
  2179. 2172 Text:CASE 32 TO 47,58 TO 126                            ! printable except numeric
  2180. 2173        IF Lecho THEN PRINT Key1$;              ! ascii character
  2181. 2174        IF R_xoff=0 THEN OUTPUT @Out_buff;Key1$;
  2182. 2175 !
  2183. 2176        IF S_log THEN 
  2184. 2177          File_buff$=File_buff$&Key1$
  2185. 2178          Fblen=LEN(File_buff$)
  2186. 2179          IF Fblen>=Max_buff-20 THEN 
  2187. 2180            DISP CHR$(129);" ";CHR$(128)
  2188. 2181            OUTPUT @S_log;File_buff$;
  2189. 2182            DISP 
  2190. 2183            File_buff$=""
  2191. 2184          END IF
  2192. 2185        END IF
  2193. 2186    !----------------------------------------------
  2194. 2187      CASE 48 TO 57     ! numerics
  2195. 2188        IF R_xoff=0 THEN OUTPUT @Out_buff;Key1$;
  2196. 2189        IF Lecho THEN PRINT Key1$;
  2197. 2190    !----------------------------------------------
  2198. 2191      CASE 0 TO 15,26 TO 31
  2199. 2192 Ctl_char: !
  2200. 2193        IF R_xoff=0 THEN OUTPUT @Out_buff;Key1$;
  2201. 2194        IF Lecho AND Display=8 THEN 
  2202. 2195          DISPLAY FUNCTIONS ON
  2203. 2196          PRINT Key1$;
  2204. 2197          DISPLAY FUNCTIONS OFF
  2205. 2198        END IF
  2206. 2199 !
  2207. 2200      CASE 16 TO 25               ! ANSI - APPLICATION Mode
  2208. 2201                                  ! VT52 Application Mode not Implemented  (? instead of O)
  2209. 2202        IF Kp_mode$="APPL" THEN    ! vt100 application keypad
  2210. 2203          IF R_xoff=0 THEN OUTPUT @Out_buff;"O"&CHR$(Key1+96);
  2211. 2204        ELSE
  2212. 2205          IF R_xoff=0 THEN OUTPUT @Out_buff;Key1$;
  2213. 2206        END IF
  2214. 2207        IF Lecho AND Display=8 THEN 
  2215. 2208          DISPLAY FUNCTIONS ON
  2216. 2209          PRINT Key1$;
  2217. 2210          DISPLAY FUNCTIONS OFF
  2218. 2211        END IF
  2219. 2212      END SELECT
  2220. 2213   !------------------------------------------------
  2221. 2214    EXIT IF Remote=0
  2222. 2215      K$=KBD$            ! flush keyboard buffer
  2223. 2216    END LOOP
  2224. 2217    RETURN 
  2225. 2218!======================================================================
  2226. 2219 Receive_char: !
  2227. 2220 Rc:!
  2228. 2221    GOSUB Get_inlength     ! find In_length of Inbound Buffer
  2229. 2222  !
  2230. 2223    WHILE In_length
  2231. 2224      ENTER @In_buff USING "#,A";A$
  2232. 2225      Char=NUM(A$)
  2233. 2226      IF S_log THEN 
  2234. 2227        File_buff$=File_buff$&A$
  2235. 2228        IF Char=13 AND Newline THEN File_buff$=File_buff$&"
  2236. "
  2237. 2229        Fblen=LEN(File_buff$)
  2238. 2230        IF (Char=13 AND Fblen>=Max_buff-80) OR (Fblen>=Max_buff-10) THEN 
  2239. 2231          DISP CHR$(129);" ";CHR$(128)
  2240. 2232          OUTPUT @S_log;File_buff$;
  2241. 2233          File_buff$=""
  2242. 2234        END IF
  2243. 2235      END IF
  2244. 2236 Handle_char: !
  2245. 2237      SELECT Char
  2246. 2238      CASE 32 TO 126      ! sp to ~
  2247. 2239        PRINT A$;
  2248. 2240    !-----------------------------------------
  2249. 2241    ! SELECTED CONTROL CHARACTERS
  2250. 2242    !-----------------------------------------
  2251. 2243      CASE 127     ! backspace "del"
  2252. 2244        STATUS CRT,0;Cx,Cy
  2253. 2245        IF Cx>1 THEN 
  2254. 2246          CONTROL CRT,0;Cx-1,Cy
  2255. 2247          OUTPUT CRT;" ";
  2256. 2248          CONTROL CRT,0;Cx-1,Cy
  2257. 2249        END IF
  2258. 2250      CASE 5                        !""         ! ENQ/ACK
  2259. 2251        OUTPUT @Out_buff;CHR$(6);
  2260. 2252        IF Flow$="ENQ/ACK" THEN 
  2261. 2253          OUTPUT @Out_buff;CHR$(6);
  2262. 2254        END IF
  2263. 2255      CASE 10                       ! LF
  2264. 2256        IF Hl THEN GOSUB Blink
  2265. 2257        PRINT "
  2266. ";
  2267. 2258        IF S_log THEN OUTPUT @S_log;File_buff$
  2268. 2259        File_buff$=""
  2269. 2260      CASE 13
  2270. 2261        PRINT "";
  2271. 2262      CASE 7
  2272. 2263        BEEP 800,.1
  2273. 2264      CASE 8                          !     Backspace
  2274. 2265        STATUS CRT,0;Cx
  2275. 2266        CONTROL CRT,0;MAX(Cx-1,1)
  2276. 2267      CASE 17                         ! Xon Received
  2277. 2268        IF Flow$="XON/XOFF" THEN 
  2278. 2269          R_xoff=0
  2279. 2270        END IF
  2280. 2271      CASE 19                         ! Xoff Received
  2281. 2272        IF Flow$="XON/XOFF" THEN 
  2282. 2273          R_xoff=1
  2283. 2274        END IF
  2284. 2275!
  2285. 2276! ESCAPE PROCESSING
  2286. 2277!
  2287. 2278      CASE 27                         !     Escape
  2288. 2279     !------------------------
  2289. 2280     !    VT-100  SEQUENCES
  2290. 2281 Rvt:!------------------------
  2291. 2282     !  need to check for buffer length here to avoid end of buffer
  2292. 2283     !
  2293. 2284     ! Repeat until a vt100 escape sequence terminator is found
  2294. 2285     !
  2295. 2286     !
  2296. 2287     !
  2297. 2288 Get_vt100: !
  2298. 2289 Gv: !
  2299. 2290        Esc_seq_str$=""
  2300. 2291        Vt52_seq=0
  2301. 2292        Vt100_seq=0
  2302. 2293        Esc_cmplt=0
  2303. 2294        Esc_cmplt$=""
  2304. 2295        Esc_length=0
  2305. 2296 !
  2306. 2297        REPEAT
  2307. 2298          GOSUB Get_inlength
  2308. 2299        UNTIL In_length
  2309. 2300        ENTER @In_buff USING "#,A";A$    ! [ for vt100
  2310. 2301        Esc_seq_str$=Esc_seq_str$&A$
  2311. 2302  !
  2312. 2303        IF A$="[" THEN       ! vt100 sequence
  2313. 2304          Vt100_seq=1
  2314. 2305          REPEAT
  2315. 2306            REPEAT
  2316. 2307              GOSUB Get_inlength
  2317. 2308            UNTIL In_length
  2318. 2309            ENTER @In_buff USING "#,A";A$
  2319. 2310            Esc_seq_str$=Esc_seq_str$&A$
  2320. 2311            IF POS("ABCDHJKRZ=>cghlmnqrxy",A$) THEN   ! '?' is not a seq end
  2321. 2312              Esc_cmplt=1
  2322. 2313              Esc_cmplt$=A$
  2323. 2314            END IF
  2324. 2315            Esc_length=Esc_length+1
  2325. 2316          UNTIL Esc_cmplt OR Esc_length>Max_esc_length
  2326. 2317        ELSE !-------------------------------------------------------
  2327. 2318          Vt52_seq=1
  2328. 2319          REPEAT
  2329. 2320            IF POS("78ABCDEHM=><",A$) THEN        ! vt52
  2330. 2321              Esc_cmplt=1
  2331. 2322              Esc_cmplt$=A$
  2332. 2323              GOTO Gv2
  2333. 2324            END IF
  2334. 2325            REPEAT
  2335. 2326              GOSUB Get_inlength
  2336. 2327            UNTIL In_length
  2337. 2328            ENTER @In_buff USING "#,A";A$
  2338. 2329            Esc_seq_str$=Esc_seq_str$&A$
  2339. 2330            Esc_length=Esc_length+1
  2340. 2331          UNTIL Esc_cmplt OR Esc_length>Max_esc_length
  2341. 2332        END IF! vt52 or vt100
  2342. 2333  !=-----------------------------------------------------------------------------------
  2343. 2334  !
  2344. 2335  ! Esc_seq_str$ = received VT escape sequence
  2345. 2336  !
  2346. 2337        IF Debug THEN 
  2347. 2338          PRINT Esc_seq_str$;
  2348. 2339          GOTO Vt100_exit
  2349. 2340        END IF
  2350. 2341  !
  2351. 2342 Gv2:   IF Vt100_seq THEN GOSUB Parse_esc      ! hcolon, left_brak, pn1,pn2,pn3
  2352. 2343        STATUS CRT,0;Cx,Cy                ! current cursor
  2353. 2344        SELECT Esc_cmplt$
  2354. 2345  !
  2355. 2346  ! Cursor Movement
  2356. 2347  !
  2357. 2348        CASE "A","B","C","D"              ! #A
  2358. 2349        !
  2359. 2350        ! Esc_ptr points to completion char (ABCD etc)
  2360. 2351        !
  2361. 2352          IF Pn1=0 THEN Pn1=1
  2362. 2353          SELECT Esc_cmplt$
  2363. 2354          CASE "A"   !up
  2364. 2355            Cy=MAX(1,Cy-Pn1)
  2365. 2356            CONTROL CRT,1;Cy
  2366. 2357          CASE "B"   !down
  2367. 2358            Cy=MIN(Crt_lines,Cy+Pn1)
  2368. 2359            CONTROL CRT,1;Cy
  2369. 2360          CASE "C"   !fwd
  2370. 2361            Cx=MIN(Crt_width,Cx+Pn1)
  2371. 2362            CONTROL CRT,0;Cx
  2372. 2363          CASE "D"   !bkwd
  2373. 2364            Cx=MAX(1,Cx-Pn1)
  2374. 2365            CONTROL CRT,0;Cx
  2375. 2366          END SELECT
  2376. 2367        CASE "H"                 ! set cursor or !! SET TAB = Esc-H
  2377. 2368 Vt_h:  !                        ! cy;cxH
  2378. 2369                                 ! H = home cursor
  2379. 2370          Cy=Pn1
  2380. 2371          Cx=Pn2
  2381. 2372          IF Cy=0 THEN Cy=1      ! Pn1=Line
  2382. 2373          IF Cx=0 THEN Cx=1
  2383. 2374 Cursor_pos: !
  2384. 2375          CONTROL CRT,0;Cx,Cy
  2385. 2376        CASE "J"
  2386. 2377          SELECT Pn1
  2387. 2378               ! Need to know number of lines on screen
  2388. 2379          CASE 0         ! erase to end of scr
  2389. 2380          CASE 1         ! erase up to cursor
  2390. 2381          CASE 2         ! CLS
  2391. 2382            CLEAR SCREEN
  2392. 2383          END SELECT
  2393. 2384        CASE "K"
  2394. 2385          SELECT Pn1
  2395. 2386          CASE 0         ! clear to end
  2396. 2387            OUTPUT KBD;" %";                ! clr-end
  2397. 2388          CASE 1                            ! clr to cursor
  2398. 2389          CASE 2                            ! clr line
  2399. 2390            OUTPUT KBD;" #";
  2400. 2391          END SELECT
  2401. 2392        CASE "R"
  2402. 2393          OUTPUT @Out_buff;"";Cy;";";Cx;"R"
  2403. 2394        CASE "c","Z"  ! Device Attribute (DA) report
  2404. 2395          IF Pn=1 THEN 
  2405. 2396            OUTPUT @Out_buff;"?0;0c"
  2406. 2397          ELSE
  2407. 2398            OUTPUT @Out_buff;"?1;0c"
  2408. 2399          END IF
  2409. 2400        CASE "g"  ! tab stops
  2410. 2401        CASE "h"  ! set modes
  2411. 2402          SELECT Esc_seq_str$
  2412. 2403          CASE "?1h"  ! Set ANSI/Cursor Keymode (OA)
  2413. 2404            Cursor_mode$="VT52"
  2414. 2405          CASE "?2h"  ! Set ANSI Mode
  2415. 2406            Term_mode$="ANSI"
  2416. 2407          END SELECT
  2417. 2408        CASE "l"  ! clear modes
  2418. 2409          SELECT Esc_seq_str$
  2419. 2410          CASE "?1l"  ! ANSI/Cursor Keymode Reset (A)
  2420. 2411            Cursor_mode$="ANSI"
  2421. 2412          CASE "?2l"  ! Set VT52 Mode
  2422. 2413            Term_mode$="VT52"
  2423. 2414          END SELECT
  2424. 2415        CASE "m"  ! graphics rendition
  2425. 2416          SELECT Pn1
  2426. 2417          CASE 0
  2427. 2418            PRINT CHR$(128);
  2428. 2419          CASE 7
  2429. 2420            PRINT CHR$(129);
  2430. 2421          CASE ELSE
  2431. 2422          END SELECT
  2432. 2423        CASE "n"
  2433. 2424        CASE "q"
  2434. 2425        CASE "r"         ! Set Scrolling Region
  2435. 2426          Top_line=Pn1
  2436. 2427          Bot_line=Pn2
  2437. 2428          Scroll_lines=Bot_line-Top_line+1
  2438. 2429     !    ALPHA HEIGHT Scroll_lines
  2439. 2430     !
  2440. 2431     ! 24 line emulator needs work
  2441. 2432     !
  2442. 2433        CASE "x"         ! request report frame (parity,data bits etc)
  2443. 2434          !  IF Pn1=0 THEN      ! term can send unsolicited reports
  2444. 2435          !  IF Pn1=1 THEN      ! term may only respond to a "x" request
  2445. 2436          !  IF Pn1=2 THEN      ! host sending a port parm report
  2446. 2437          !  IF Pn1=3 THEN      ! AND of bits 0 and 1
  2447. 2438        CASE "n"         ! request report on terminal status
  2448. 2439          IF Pn1=5 THEN OUTPUT @Out_buff;"n"
  2449. 2440          IF Pn1=6 THEN 
  2450. 2441            STATUS CRT,0;Cx,Cy
  2451. 2442            OUTPUT @Out_buff;""&VAL$(Cx)&","&VAL$(Cy)&","&"R"
  2452. 2443          END IF
  2453. 2444        CASE "="      ! enter appl keypad mode     ! =
  2454. 2445          Kp_mode$="APPL"
  2455. 2446        CASE "<"      ! return to ANSI mode       ! <
  2456. 2447          Term_mode$="ANSI"
  2457. 2448        CASE ">"      ! exit appl keypad mode      ! >
  2458. 2449          Kp_mode$="NUMERIC"
  2459. 2450        CASE "7"      ! save cursor
  2460. 2451          Save_cx=Cx
  2461. 2452          Save_cy=Cy
  2462. 2453        CASE "8"      ! restore cursor
  2463. 2454          Cx=Save_cx
  2464. 2455          Cy=Save_cy
  2465. 2456        CASE ELSE
  2466. 2457          PRINT Esc_seq_str$;
  2467. 2458        END SELECT            ! of esc-VT100 argument
  2468. 2459 Vt100_exit:  ! ------------------------------- End ESCAPE Processing
  2469. 2460      CASE 0 TO 31       ! Control Char
  2470. 2461        IF Debug THEN 
  2471. 2462          PRINT "^"&CHR$(NUM(A$)+32);
  2472. 2463        END IF
  2473. 2464      CASE 128 TO 255
  2474. 2465        IF Debug THEN 
  2475. 2466          PRINT "^&"&CHR$(NUM(A$)-128);
  2476. 2467        ELSE
  2477. 2468          IF Display=8 THEN 
  2478. 2469            DISPLAY FUNCTIONS ON
  2479. 2470            PRINT A$;
  2480. 2471            DISPLAY FUNCTIONS OFF
  2481. 2472          END IF
  2482. 2473        END IF
  2483. 2474      CASE ELSE
  2484. 2475        IF Debug THEN PRINT A$;
  2485. 2476      END SELECT
  2486. 2477  !
  2487. 2478      GOSUB Get_inlength
  2488. 2479    END WHILE
  2489. 2480    RETURN 
  2490. 2481 Rc2: !
  2491. 2482 !-------------------------------------------
  2492. 2483 Parse_esc: !
  2493. 2484 Pe: !
  2494. 2485  !
  2495. 2486  ! POS of "[" = Lef_brak  (0=not found for vt52)
  2496. 2487  ! POS of ";" = esc_colon(0:5)      esc_colon(0)=# of colons
  2497. 2488  ! numeric parameters:  pn1,pn2,pn3
  2498. 2489  !
  2499. 2490    MAT Esc_colon= (0)
  2500. 2491    Esc_colon_done=0
  2501. 2492  !
  2502. 2493    Lef_brak=POS(Esc_seq_str$,"[")    ! find left bracket
  2503. 2494  !
  2504. 2495  ! Find all occurances of ";"
  2505. 2496  !
  2506. 2497    GOTO Skip_scolon
  2507. 2498    REPEAT
  2508. 2499      Ec=POS(Esc_seq_str$[Ec_ptr],";")
  2509. 2500      IF Ec THEN 
  2510. 2501        Esc_colon(0)=Esc_colon(0)+1
  2511. 2502        Esc_colon(Esc_colon(0))=Ec_ptr+Ec-1
  2512. 2503        Ec_ptr=Ec+1
  2513. 2504      END IF
  2514. 2505    UNTIL Ec=0
  2515. 2506 Skip_scolon: !
  2516. 2507  !
  2517. 2508  ! find values of pn1,pn2...
  2518. 2509  ! Use VAL function to parse multiple values
  2519. 2510  !
  2520. 2511  !
  2521. 2512    Pn0=0
  2522. 2513    Pn1=0
  2523. 2514    Pn2=0
  2524. 2515    Pn3=0
  2525. 2516    ON ERROR GOTO Pn_done
  2526. 2517    ENTER Esc_seq_str$;Pn1,Pn2,Pn3            ! H  << how to parse this ?
  2527. 2518    Pn0=0
  2528. 2519    ! pn0=number of parameters passed (not used)
  2529. 2520 Pn_done:OFF ERROR 
  2530. 2521    GOTO Pe_exit
  2531. 2522    ON ERROR GOSUB Term_err
  2532. 2523  !
  2533. 2524    DISPLAY FUNCTIONS ON
  2534. 2525    PRINT TABXY(1,18);
  2535. 2526    PRINT USING "#,(K,X)";Esc_seq_str$
  2536. 2527    DISP "Pn values: ";Pn1,Pn2,Pn3,"#= ";Pn0
  2537. 2528    CONTROL CRT,0;Cx,Cy
  2538. 2529    DISPLAY FUNCTIONS OFF
  2539. 2530 Pe_exit:ON ERROR GOSUB Term_err
  2540. 2531    RETURN 
  2541. 2532 !-------------------------------------------
  2542. 2533 Get_inlength: !
  2543. 2534   !  SELECT Com_card
  2544. 2535  !   CASE 98626,98644
  2545. 2536  !     STATUS @In_buff,3;Fp,In_length,Ep
  2546. 2537  !   CASE 98628
  2547. 2538  !     STATUS Com_port,5;In_length
  2548. 2539  !   END SELECT
  2549. 2540  !
  2550. 2541    IF Com_card=98628 THEN 
  2551. 2542     ! Xon/Xoff implemented in Hardware
  2552. 2543    ELSE
  2553. 2544      STATUS @In_buff,4;In_length
  2554. 2545      IF (NOT Xoff) AND (In_length>Inbuff_max) THEN 
  2555. 2546        IF Flow$="XON/XOFF" THEN 
  2556. 2547          OUTPUT @Out_buff;CHR$(19);
  2557. 2548          Xoff=1
  2558. 2549          BEEP 500,.01
  2559. 2550        END IF
  2560. 2551      END IF
  2561. 2552!
  2562. 2553      IF (Xoff) AND (In_length<Inbuff_min) THEN 
  2563. 2554        IF Flow$="XON/XOFF" THEN 
  2564. 2555          OUTPUT @Out_buff;CHR$(17)   ! XON
  2565. 2556          Xoff=0
  2566. 2557          BEEP 2000,.01
  2567. 2558        END IF
  2568. 2559      END IF
  2569. 2560!
  2570. 2561    END IF
  2571. 2562    RETURN 
  2572. 2563 !-------------------------------------------
  2573. 2564 Com_tmo:!
  2574. 2565    DISP "Serial  Port Timeout - Paused "
  2575. 2566    PAUSE
  2576. 2567    DISP 
  2577. 2568    RETURN 
  2578. 2569 !-------------------------------------------
  2579. 2570 Term_err:!
  2580. 2571    IF Debug THEN PRINT ERRM$
  2581. 2572    SELECT ERRN
  2582. 2573    CASE 59  ! End of Log File
  2583. 2574      IF S_log THEN 
  2584. 2575        ASSIGN @S_log TO *
  2585. 2576        S_log=0
  2586. 2577        GOSUB Disp_modeline
  2587. 2578      END IF
  2588. 2579    CASE 167 ! IO STATUS ERROR
  2589. 2580      GOSUB Term_intr
  2590. 2581    CASE 314  ! RECEIVE BUFFER OVERFLOW
  2591. 2582      BEEP 
  2592. 2583      DISP ERRM$," Paused in Term_err"
  2593. 2584      PAUSE
  2594. 2585      DISP 
  2595. 2586    CASE ELSE
  2596. 2587      BEEP 
  2597. 2588      DISP ERRM$,"paused"
  2598. 2589      PAUSE
  2599. 2590   !  CLEAR ERROR
  2600. 2591      ERROR RETURN
  2601. 2592      DISP 
  2602. 2593    END SELECT
  2603. 2594    RETURN 
  2604. 2595 !--------------------------------------------------------------------
  2605. 2596  SUBEND
  2606. 2597 ! ====================================================================
  2607. 2598 Kstatus:SUB Kstatus
  2608. 2599    OPTION BASE 1
  2609. 2600    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  2610. 2601    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$[3],Parity_type$[4]
  2611. 2602    COM /Frame/ Flow$,Hshake$
  2612. 2603    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  2613. 2604    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  2614. 2605    COM /Kerm/ INTEGER Maxp,Maxtry,Mypad,Mytmo,Mypchar,Myeol,Myquote
  2615. 2606    COM /Kerm/ INTEGER Size,Rpsiz,Spsiz,Pad,Capas,Send_at
  2616. 2607    COM /Kerm/ INTEGER Image,Parflg,Pktdeb
  2617. 2608    COM /Kerm/ INTEGER Filnamcnv,Blk_chk,Quote,Eol,Smark
  2618. 2609    COM /Kerm2/ State$[1],Cchksum$[1],Eof_mode$,INTEGER Eof_mode,Timer,Ptmo
  2619. 2610    COM /Term/ Term_type$[10],S_log,D_log,Filewarn,Discard,@S_log,@D_log
  2620. 2611    COM /Term/ Kerm_esc$[2],S_log$,D_log$,INTEGER Remote,Lecho,Turn,Display
  2621. 2612    COM /Term/ Term_mode$
  2622. 2613    COM /Path/ Cur_msi$,S_path$,S_msi$,D_path$,D_msi$
  2623. 2614    DIM D_log_stat$[40],S_log_stat$[40]
  2624. 2615    PRINTER IS CRT
  2625. 2616    PRINT RPT$("=",15)&" S T A T U S "&RPT$("=",15)
  2626. 2617    !
  2627. 2618    PRINT CHR$(132);"COMMUNICATIONS PORT";CHR$(128);
  2628. 2619    PRINT TAB(50);CHR$(132);"TERMINAL";CHR$(128)
  2629. 2620    !
  2630. 2621    PRINT "Baud Rate ";TAB(20);Baud;
  2631. 2622    PRINT TAB(50);"Terminal Type ";TAB(70);Term_type$
  2632. 2623    !
  2633. 2624    PRINT "COM Port ";TAB(20);Com_port;
  2634. 2625    PRINT TAB(50);"          ";TAB(70);"    "
  2635. 2626    !
  2636. 2627    PRINT "Parity ";TAB(20);Data_bits;"/";Parity_type$;"/";On_off$;
  2637. 2628    PRINT TAB(50);CHR$(132);"LOCAL TRANSFER PARAMETERS";CHR$(128)
  2638. 2629    !
  2639. 2630    Lecho$="REMOTE"
  2640. 2631    IF Lecho THEN Lecho$="LOCAL"
  2641. 2632    PRINT "ECHO       ";TAB(20);Lecho$;
  2642. 2633    PRINT TAB(50);"Packet Timeout ";TAB(70);Mytmo
  2643. 2634    !
  2644. 2635    PRINT "Flow Control";TAB(20);Flow$;
  2645. 2636    PRINT TAB(50);"Control Quote";TAB(70);CHR$(Myquote)
  2646. 2637    !
  2647. 2638    PRINT "Handshake  ";TAB(20);Hshake$;
  2648. 2639    PRINT TAB(50);"Packet Size ";TAB(70);Spsiz
  2649. 2640    !
  2650. 2641    PRINT "Source  MSI  ";TAB(20);S_path$&S_msi$;
  2651. 2642    PRINT TAB(50);"Padding Character";
  2652. 2643    DISPLAY FUNCTIONS ON
  2653. 2644    PRINT TAB(70);CHR$(Mypad);
  2654. 2645    DISPLAY FUNCTIONS OFF
  2655. 2646    PRINT 
  2656. 2647    !
  2657. 2648    PRINT "Destination  MSI ";TAB(20);D_path$&D_msi$;
  2658. 2649    PRINT TAB(50);"             ";TAB(70);"   "
  2659. 2650    !
  2660. 2651    Filewarn$="OVERWRITE"
  2661. 2652    IF Filewarn THEN Filewarn$="AVOID OVERWRITE"
  2662. 2653    PRINT "Overwrite  Warn.   ";TAB(20);Filewarn$;
  2663. 2654    PRINT TAB(50);CHR$(132);"REMOTE TRANSFER PARAMETERS";CHR$(128)
  2664. 2655    !
  2665. 2656    Discard$="KEEP     "
  2666. 2657    IF Discard THEN Discard$="DISCARD"
  2667. 2658    PRINT "Incomplete File    ";TAB(20);Discard$;
  2668. 2659    PRINT TAB(50);"Packet Timeout";TAB(70);Ptmo
  2669. 2660    !
  2670. 2661    PRINT "EOF Mode  ";TAB(20);Eof_mode$;
  2671. 2662    PRINT TAB(50);"Packet Size ";TAB(70);Rpsiz
  2672. 2663    !
  2673. 2664    S_log_stat$="OFF          "
  2674. 2665    IF S_log THEN S_log_stat$=S_log$
  2675. 2666    PRINT "Session Log  ";TAB(20);S_log_stat$;
  2676. 2667    !
  2677. 2668    PRINT TAB(50);"Padding Character";
  2678. 2669    DISPLAY FUNCTIONS ON
  2679. 2670    PRINT TAB(70);CHR$(Pad);
  2680. 2671    DISPLAY FUNCTIONS OFF
  2681. 2672    PRINT 
  2682. 2673    !
  2683. 2674    D_log_stat$="OFF"
  2684. 2675    IF D_log THEN D_log_stat$=D_log$
  2685. 2676    PRINT "Packet  Log ";TAB(20);D_log_stat$;
  2686. 2677    PRINT TAB(50);"Control Quote ";TAB(70);CHR$(Quote)
  2687. 2678    !
  2688. 2679    Timeron$="ON"
  2689. 2680    IF NOT Timer THEN Timeron$="OFF"
  2690. 2681    PRINT "Timer        ";TAB(20);Timeron$;
  2691. 2682    PRINT TAB(50);"EOL Char      ";
  2692. 2683    DISPLAY FUNCTIONS ON
  2693. 2684    PRINT TAB(70);CHR$(Eol);
  2694. 2685    DISPLAY FUNCTIONS OFF
  2695. 2686    PRINT 
  2696. 2687    !
  2697. 2688    Debug$="OFF"
  2698. 2689    IF Debug THEN Debug$="ON         "
  2699. 2690    PRINT "Debug Mode   ";TAB(20);Debug$;
  2700. 2691    PRINT TAB(50);"Pkt. Retry  Limit  ";TAB(70);Maxtry
  2701. 2692    !
  2702. 2693    PRINT "Kermit Escape ";
  2703. 2694    PRINT TAB(20);"^"&CHR$(NUM(Kerm_esc$[1,1])+64)&Kerm_esc$[2,2];
  2704. 2695    PRINT TAB(50);"Block Check Type  ";TAB(70);Blk_chk
  2705. 2696    !
  2706. 2697    Filetype$="ASCII"
  2707. 2698    IF Image THEN Filetype$="BINARY"
  2708. 2699    PRINT "File Mode    ";TAB(20);Filetype$;
  2709. 2700    DISPLAY FUNCTIONS ON
  2710. 2701    PRINT TAB(50);"Packet Mark        ";TAB(70);CHR$(Smark);
  2711. 2702    DISPLAY FUNCTIONS OFF
  2712. 2703  !
  2713. 2704    PRINT 
  2714. 2705    STATUS @In_buff,0;Valid_path
  2715. 2706    IF Valid_path=3 THEN  ! buffer
  2716. 2707      STATUS @In_buff,10;I_stat
  2717. 2708      IF (I_stat AND 14) THEN Txfer_stat$="Terminated OK"
  2718. 2709      IF (I_stat AND 48) THEN Txfer_stat$="Error/Abort"
  2719. 2710      IF (I_stat AND 64) THEN Txfer_stat$="On"
  2720. 2711      IF (I_stat=0) THEN Txfer_stat$="Off"
  2721. 2712    ELSE
  2722. 2713      Txfer_stat$="Not Assigned"
  2723. 2714    END IF
  2724. 2715    PRINT "Inbound DMA";TAB(20);Txfer_stat$;
  2725. 2716  !
  2726. 2717    STATUS @Out_buff,0;Valid_path
  2727. 2718    IF Valid_path=3 THEN  ! buffer
  2728. 2719      STATUS @Out_buff,11;O_stat
  2729. 2720      IF (O_stat AND 14) THEN Txfer_stat$="Terminated OK"
  2730. 2721      IF (O_stat AND 48) THEN Txfer_stat$="Error/Abort"
  2731. 2722      IF (O_stat AND 64) THEN Txfer_stat$="On"
  2732. 2723      IF (O_stat=0) THEN Txfer_stat$="Off"
  2733. 2724    ELSE
  2734. 2725      Txfer_stat$="Not Assigned"
  2735. 2726    END IF
  2736. 2727    PRINT TAB(50);"Outbound DMA";TAB(70);Txfer_stat$;
  2737. 2728  !
  2738. 2729    PRINT 
  2739. 2730  SUBEND
  2740. 2731  ! =======================================================================
  2741. 2732 Tochar:DEF FNTochar$(INTEGER C)
  2742. 2733    RETURN CHR$(C+32)        ! +" "
  2743. 2734  FNEND
  2744. 2735  !------------------------------------------------------------------------
  2745. 2736 Unchar:DEF FNUnchar(C$)
  2746. 2737    RETURN NUM(C$)-32
  2747. 2738  FNEND
  2748. 2739  !------------------------------------------------------------------------
  2749. 2740 Ctl:DEF FNCtl(C$)
  2750. 2741    C=NUM(C$)
  2751. 2742    C=BINEOR(C,64)  ! toggle bit 7
  2752. 2743    RETURN C
  2753. 2744  FNEND
  2754. 2745  ! ----------------------------------------------------------------------
  2755. 2746 Ksend:SUB K_send(F$,OPTIONAL INTEGER Bdat_item)
  2756. 2747  !
  2757. 2748  ! Kermit Send File Protocol
  2758. 2749  !
  2759. 2750    OPTION BASE 1
  2760. 2751    COM Version$,K$,Setup$
  2761. 2752    COM /Crt/ Crt_lines,Crt_width
  2762. 2753    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  2763. 2754    COM /Kerm/ INTEGER Maxp,Maxtry,Mypad,Mytmo,Mypchar,Myeol,Myquote
  2764. 2755    COM /Kerm/ INTEGER Size,Rpsiz,Spsiz,Pad,Capas,Send_at
  2765. 2756    COM /Kerm/ INTEGER Image,Parflg,Pktdeb
  2766. 2757    COM /Kerm/ INTEGER Filnamcnv,Blk_chk,Quote,Eol,Smark
  2767. 2758    COM /Kerm2/ State$[1],Cchksum$[1],Eof_mode$,INTEGER Eof_mode,Timer,Ptmo
  2768. 2759    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  2769. 2760    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  2770. 2761    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$[3],Parity_type$[4]
  2771. 2762    COM /Frame/ Flow$,Hshake$
  2772. 2763    COM /Term/ Term_type$[10],S_log,D_log,Filewarn,Discard,@S_log,@D_log
  2773. 2764    COM /Term/ Kerm_esc$[2],S_log$,D_log$,INTEGER Remote,Lecho,Turn,Display
  2774. 2765    COM /Term/ Term_mode$
  2775. 2766    COM /Path/ Cur_msi$,S_path$,S_msi$,D_path$,D_msi$
  2776. 2767  !
  2777. 2768    INTEGER Chksum,Rc,Plen,Dlen,Cchksum,Qbin,Rep_ch
  2778. 2769    INTEGER Ftype,Volnum,Prot,Recsize,Sec_data(1:256),Lsb,Msb
  2779. 2770    INTEGER Npak,Numtry,Oldtry,Rseq
  2780. 2771    INTEGER Com_err,User_break
  2781. 2772    INTEGER Spacks,Fpacks,Apacks,Dpacks,Zpacks,Bpacks,Epacks
  2782. 2773    INTEGER Atl
  2783. 2774    INTEGER Bdat_int
  2784. 2775    REAL File_st,F_sec,File_length,At_rec,At_recl,At_len
  2785. 2776    DIM Misc$[80],Filename$[80],F_path$[256]
  2786. 2777    DIM A$[1],File_buff$[1024],File_get$[256],Wmsg$[80],Emsg$[80]
  2787. 2778    DIM Myquote$[1],Qbin$[1]
  2788. 2779    DIM File_eol$[2],Cat$(10)[80],Cat_entry$[80],Sav_msi$[256]
  2789. 2780  !
  2790. 2781    Sav_msi$=SYSTEM$("MSI")
  2791. 2782    File_eol$=CHR$(13)&CHR$(10)
  2792. 2783    ALLOCATE Rcvpkt$[Maxp],Sndpkt$[Spsiz+2],Packet$[Spsiz+2],Rdata$[Maxp]
  2793. 2784    Com_err=0
  2794. 2785    Shutdown         ! Shut off transfers while doing ON-EVENTS
  2795. 2786    SELECT Com_card
  2796. 2787    CASE 98626,98644
  2797. 2788      CONTROL Com_port,12;128+32+16          ! ELIMINATE HANDSHAKE
  2798. 2789      CONTROL Com_port,5;1+2                 ! force dtr,rts
  2799. 2790    CASE 98628
  2800. 2791      CONTROL Com_port,13;164     ! INT MASK  4=UART  32=lost car 128=break
  2801. 2792    END SELECT
  2802. 2793    ON ERROR GOSUB Send_err
  2803. 2794    ON INTR Com_port,15 GOSUB Send_intr
  2804. 2795    Startup
  2805. 2796  !
  2806. 2797    CLEAR SCREEN
  2807. 2798    IF Display THEN 
  2808. 2799      PRINT TABXY(1,2);Version$
  2809. 2800      PRINT TABXY(15,5);"Filename: ";F$                 ! LINE 5
  2810. 2801      PRINT TAB(6);"Bytes Transferred: ";TAB(25);Kbx    ! 6
  2811. 2802      PRINT TAB(6);"    % Transferred: ";TAB(25);Kbx    ! 7
  2812. 2803      PRINT TAB(16);"SENDING: In Progress           "   ! 8
  2813. 2804      PRINT                                             ! 9
  2814. 2805      PRINT TAB(6);"Number of Packets: ";TAB(25);Npak   ! 10
  2815. 2806      PRINT TAB(6);"Number of Retries: ";TAB(25);Oldtry ! 11
  2816. 2807      PRINT TAB(13);"Last Error: "                      ! 12
  2817. 2808      PRINT TAB(11);"Last Message: "                    ! 13
  2818. 2809                                                        ! 14 blank
  2819. 2810      IF Debug THEN 
  2820. 2811        PRINT TABXY(11,15);"REC. PACKET : "                  ! 15
  2821. 2812        PRINT TABXY(11,16);"SEND PACKET : "                  ! 16
  2822. 2813      END IF
  2823. 2814      PRINT TABXY(1,Crt_lines-1);CHR$(129);"^X cancels File, ^E Quits Protocol, ^C Quits, Return retries";CHR$(128)
  2824. 2815    ELSE
  2825. 2816      DISP "Sending ";F$;" ... "
  2826. 2817    END IF
  2827. 2818    !--------------------------------------------------------------------
  2828. 2819    ! The filename in whatever form is passed in as F$
  2829. 2820    !
  2830. 2821    ! 1. If msi not specified then
  2831. 2822    !       use Source Msi
  2832. 2823    !       use source path
  2833. 2824    !
  2834. 2825    ! 2. If msi is specified dont use source path
  2835. 2826    !
  2836. 2827    IF NOT POS(F$,":") THEN 
  2837. 2828      F_msi$=S_msi$
  2838. 2829      IF NOT POS(F$,"/") THEN F_path$=S_path$
  2839. 2830      F$=F_path$&F$&F_msi$
  2840. 2831    END IF
  2841. 2832    Parse_filename(F$,F_msi$,F_path$)
  2842. 2833    Filename$=F_path$&F$&F_msi$
  2843. 2834    IF F_path$&F$="/T" THEN GOTO Test_send
  2844. 2835  !
  2845. 2836  ! Catalog File entry on F_path$ and F_msi$
  2846. 2837  ! Get File's parameters  Cat_entry$,At_length,At_type$
  2847. 2838  !
  2848. 2839    GOSUB Get_file_entry    ! F$,F_msi$,F_path$,File_found,Cat_entry$,Filetype$
  2849. 2840  !
  2850. 2841  ! If a ramdisc is required call init_ramdisc
  2851. 2842  !
  2852. 2843    IF At_type$="PROG" OR At_type$="BIN" OR At_type$="SYSTM" THEN 
  2853. 2844      Image=1
  2854. 2845  !
  2855. 2846  ! PROG Files must use a ramdisc
  2856. 2847  ! Create one now in case we need it later
  2857. 2848  !
  2858. 2849      Ram_msi$=":,0,0"
  2859. 2850      GOSUB Check_for_rdisc  ! set ramdisc flag
  2860. 2851      IF NOT Ramdisc THEN 
  2861. 2852        CALL Init_ramdisc(Kbytes)     ! Init_ramdisc sizes the Kbytes
  2862. 2853        IF Kbytes THEN Ramdisc=1
  2863. 2854      ELSE                            ! Existing one large enough ?
  2864. 2855        IF Kbytes<(File_length/1000) THEN 
  2865. 2856          Avm=VAL(SYSTEM$("AVAILABLE MEMORY"))
  2866. 2857          Avl_kbytes=(Avm-100000)/1000
  2867. 2858          IF Avl_kbytes>(File_length/1000) THEN  ! can recreate
  2868. 2859            DISP "Can I re-create the Ram Disc ?"
  2869. 2860            OUTPUT KBD;"Y";" H";
  2870. 2861            ENTER KBD;Ans$
  2871. 2862            IF POS(UPC$(Ans$),"Y") THEN 
  2872. 2863              CALL Init_ramdisc(Kbytes)
  2873. 2864            END IF
  2874. 2865          END IF
  2875. 2866        END IF
  2876. 2867      END IF
  2877. 2868  !
  2878. 2869      IF Kbytes<(File_length/1000) THEN 
  2879. 2870        BEEP 
  2880. 2871        PRINT TABXY(1,Crt_lines);"Cannot create sufficient ramdisc - aborting SEND"
  2881. 2872        SUBEXIT
  2882. 2873      END IF
  2883. 2874  !
  2884. 2875      DISP "copying image file to ramdisc... "
  2885. 2876  !
  2886. 2877  ! Try to assign to a PROG type file - if file exists error 58 will result
  2887. 2878  !
  2888. 2879      ASSIGN @Test TO F$&Ram_msi$;RETURN Rc
  2889. 2880      IF Rc=0 THEN Rc=58
  2890. 2881      SELECT Rc
  2891. 2882      CASE 0
  2892. 2883      ! File was assignable - This is probably the second time
  2893. 2884      ! trying to send this PROG file - It's already on the ram disc
  2894. 2885      ! Rc is set to 58 to prompt for purging of existing file
  2895. 2886      CASE 58             ! improper filetype error - file exists
  2896. 2887        Prompt("Overwrite File On Ramdisc ? ","Y",Ans$,Flag)
  2897. 2888        IF Flag THEN 
  2898. 2889          ASSIGN @Test TO *
  2899. 2890          PURGE F$&Ram_msi$
  2900. 2891          COPY Filename$ TO F$&Ram_msi$
  2901. 2892        END IF
  2902. 2893      CASE ELSE    ! file not found
  2903. 2894        COPY Filename$ TO F$&Ram_msi$
  2904. 2895      END SELECT  ! file is on ramdisc or not
  2905. 2896      F_path$=""
  2906. 2897      F_msi$=Ram_msi$
  2907. 2898      Convert(F$&Ram_msi$,"HP-UX",Rc)
  2908. 2899      GOSUB Get_file_entry         ! update file attributes
  2909. 2900    END IF      ! if file is un-assignable (PROG or BIN)
  2910. 2901   !-----------------------------------------------------
  2911. 2902    Filename$=F_path$&F$&F_msi$
  2912. 2903  !
  2913. 2904    SELECT Bdat_item
  2914. 2905    CASE 0
  2915. 2906      ASSIGN @File TO Filename$;FORMAT ON
  2916. 2907    CASE ELSE
  2917. 2908      ASSIGN @File TO Filename$;FORMAT OFF
  2918. 2909    END SELECT
  2919. 2910    STATUS @File,1;File_type
  2920. 2911 Test_send:   !
  2921. 2912   !-------------------------------------    send  init
  2922. 2913    Spacks=0         ! retry counters
  2923. 2914    Fpacks=0
  2924. 2915    Apacks=0
  2925. 2916    Dpacks=0
  2926. 2917    Zpacks=0
  2927. 2918    Bpacks=0
  2928. 2919    Oldtry=0
  2929. 2920    File_buff$=""    ! file buffer to be quoted
  2930. 2921    File_get$=""     ! file enter buffer
  2931. 2922    Sdata_done=0     ! sending data done
  2932. 2923    At_eof=0         ! EOF reached on file read
  2933. 2924    Max_buff=MAXLEN(File_buff$)
  2934. 2925 !------------------------------------------------------------------------
  2935. 2926 Ksends:State$="S"
  2936. 2927    REPEAT
  2937. 2928      SELECT State$
  2938. 2929      CASE "S"
  2939. 2930        GOSUB Spar                       ! Set our Init Parameters
  2940. 2931        Spack(Packet$,State$,Npak,Sndpkt$)
  2941. 2932        IF NOT Spacks THEN PRINT TABXY(25,13);"Exchanging Initialization Packets"
  2942. 2933        OUTPUT @Out_buff;Sndpkt$
  2943. 2934        IF Debug THEN PRINT TABXY(25,16);Sndpkt$&RPT$(" ",100)
  2944. 2935        IF D_log THEN OUTPUT @D_log;Sndpkt$
  2945. 2936  !
  2946. 2937        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Spacks,User_break,Emsg$)
  2947. 2938        IF Debug THEN PRINT TABXY(25,15);Rcvpkt$&"                "
  2948. 2939        IF D_log THEN OUTPUT @D_log;Rcvpkt$
  2949. 2940        SELECT Pktype$
  2950. 2941        CASE "N"
  2951. 2942        CASE "Y"
  2952. 2943          GOSUB Rpar     ! Decode remote parameters
  2953. 2944          State$="F"
  2954. 2945          Oldtry=Oldtry+Spacks
  2955. 2946        CASE "E"
  2956. 2947          Emsg$=Rdata$
  2957. 2948          State$="E"
  2958. 2949        CASE "T"
  2959. 2950          Wmsg$="Packet Timeout"
  2960. 2951        CASE "Q"
  2961. 2952          Wmsg$="Bad Checksum  or Sequence"
  2962. 2953  !
  2963. 2954  ! If Pktype$="X" then local Kermit interrupted file sending.  User_break
  2964. 2955  ! flag is set to determine which side is erroring (in case of ^E).
  2965. 2956  ! Rdata$ can be used to determine ^X or ^Z.
  2966. 2957  !
  2967. 2958        CASE "X"
  2968. 2959          State$="Z"  ! jump to end of file
  2969. 2960          Wmsg$="User abort of Send File"
  2970. 2961        CASE ELSE
  2971. 2962          Wmsg$="Unknown Packet Type: "&Pktype$
  2972. 2963        END SELECT
  2973. 2964    !
  2974. 2965        IF Pktype$="Y" THEN 
  2975. 2966          Npak=Npak+1
  2976. 2967        ELSE
  2977. 2968          Spacks=Spacks+1
  2978. 2969        END IF
  2979. 2970   !
  2980. 2971        IF Spacks>Maxtry THEN 
  2981. 2972          State$="E"
  2982. 2973          Emsg$="Can't Receive (S) Ack from Host"
  2983. 2974        END IF
  2984. 2975   !
  2985. 2976        PRINT TABXY(25,10);Npak
  2986. 2977        PRINT TABXY(25,11);Oldtry+Spacks
  2987. 2978        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  2988. 2979        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  2989. 2980        IF State$<>"S" THEN Oldtry=Oldtry+Spacks
  2990. 2981    !--------------------------------------------------------------------
  2991. 2982 Ksendf:CASE "F"      ! Send File Header  'F'
  2992. 2983      !
  2993. 2984        Packet$=F$    ! just send filename part
  2994. 2985        Spack(Packet$,State$,Npak,Sndpkt$)
  2995. 2986        PRINT TABXY(25,13);"Sending Filename"&RPT$(" ",28)
  2996. 2987        OUTPUT @Out_buff;Sndpkt$
  2997. 2988        PRINT TABXY(25,10);Npak
  2998. 2989        PRINT TABXY(25,11);Oldtry+Fpacks
  2999. 2990  !
  3000. 2991        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Fpacks,User_break,Emsg$)
  3001. 2992        IF Debug THEN 
  3002. 2993          PRINT TABXY(25,15);Rcvpkt$&"                "
  3003. 2994          PRINT TABXY(25,16);Sndpkt$&"                "
  3004. 2995        END IF
  3005. 2996        IF D_log THEN OUTPUT @D_log;Sndpkt$,Rcvpkt$
  3006. 2997  !
  3007. 2998        SELECT Pktype$
  3008. 2999        CASE "N"
  3009. 3000        CASE "Y"
  3010. 3001          Npak=Npak+1
  3011. 3002          Oldtry=Oldtry+Fpacks
  3012. 3003          IF Rcap_a THEN        ! if remote can use attribute packets
  3013. 3004            State$="A"
  3014. 3005          ELSE
  3015. 3006            State$="D"
  3016. 3007          END IF
  3017. 3008        CASE "E"
  3018. 3009          Emsg$=Rdata$
  3019. 3010          State$="E"
  3020. 3011        CASE "T"
  3021. 3012          Wmsg$="Packet Timeout"
  3022. 3013        CASE "Q"
  3023. 3014          Wmsg$="Bad Checksum or Sequence"
  3024. 3015        CASE "X"
  3025. 3016          State$="Z"  ! jump to end of file
  3026. 3017          Wmsg$="User abort of Send File"
  3027. 3018        CASE ELSE
  3028. 3019          Wmsg$="Unknown Packet Type: "&Pktype$
  3029. 3020        END SELECT
  3030. 3021  !
  3031. 3022        IF Pktype$="N" THEN 
  3032. 3023          Fpacks=Fpacks+1
  3033. 3024          IF Fpacks>Maxtry THEN 
  3034. 3025            Emsg$="Can't Receive (F) Ack from Host"
  3035. 3026            State$="E"
  3036. 3027          END IF
  3037. 3028        END IF
  3038. 3029        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  3039. 3030        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  3040. 3031        PRINT TABXY(25,5);Filename$
  3041. 3032        IF State$="D" THEN Ft_start=TIMEDATE  ! START SEND CLOCK
  3042. 3033    !------------------------------------------------------
  3043. 3034 Ksenda:CASE "A"
  3044. 3035        IF Debug THEN PRINT TABXY(47,8);State$
  3045. 3036        Packet$=""
  3046. 3037        GOSUB Set_at             ! Form  Attribute Data into Packet$
  3047. 3038        Spack(Packet$,State$,Npak,Sndpkt$)
  3048. 3039        PRINT TABXY(25,13);"Sending File Attributes"&RPT$(" ",32)
  3049. 3040        OUTPUT @Out_buff;Sndpkt$
  3050. 3041        IF D_log THEN OUTPUT @D_log;Sndpkt$
  3051. 3042  !
  3052. 3043        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Apacks,User_break,Emsg$)
  3053. 3044        PRINT TABXY(25,10);Npak
  3054. 3045        PRINT TABXY(25,11);Oldtry+Apacks
  3055. 3046        IF Debug THEN 
  3056. 3047          PRINT TABXY(25,15);Rcvpkt$&"                "
  3057. 3048          PRINT TABXY(25,16);Sndpkt$&"                "
  3058. 3049        END IF
  3059. 3050        IF D_log THEN OUTPUT @D_log;Rcvpkt$
  3060. 3051  !
  3061. 3052        SELECT Pktype$
  3062. 3053        CASE "N"
  3063. 3054        CASE "Y"
  3064. 3055          Npak=Npak+1
  3065. 3056          State$="D"
  3066. 3057        CASE "E"
  3067. 3058          Emsg$=Rdata$
  3068. 3059          State$="E"
  3069. 3060        CASE "T"
  3070. 3061          Wmsg$="Packet Timeout"
  3071. 3062        CASE "Q"
  3072. 3063          Wmsg$="Bad Checksum  or Sequence"
  3073. 3064        CASE "X"
  3074. 3065          State$="Z"  ! jump to end of file
  3075. 3066          Wmsg$="User abort of Send File"
  3076. 3067        CASE ELSE
  3077. 3068          Wmsg$="Unknown Packet Type: "&Pktype$
  3078. 3069        END SELECT
  3079. 3070  !
  3080. 3071        IF Pktype$="Y" THEN 
  3081. 3072        ELSE
  3082. 3073          Apacks=Apacks+1
  3083. 3074          IF Apacks>Maxtry THEN 
  3084. 3075            Emsg$="Can't Receive (A) Ack from Host"
  3085. 3076            State$="E"
  3086. 3077          END IF
  3087. 3078        END IF
  3088. 3079        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  3089. 3080        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  3090. 3081        IF State$<>"A" THEN Oldtry=Oldtry+Apacks
  3091. 3082        IF State$="D" THEN Ft_start=TIMEDATE  ! START SEND CLOCK
  3092. 3083    !--------------------------------------------------------------------
  3093. 3084 Ksendd:CASE "D"      ! Send File Data    'D'
  3094. 3085     !
  3095. 3086     ! The way in which characters are fed into the File_buff$ variable
  3096. 3087     ! is dependent on file type (At_type$), and the value of Image flag.
  3097. 3088     !
  3098. 3089     ! ASCII:  Image is ignored and interpreted as Image=0
  3099. 3090     ! HP-UX:  Image=1 transmits file as is.
  3100. 3091     !         Image=0 appends Cr-Lf on each text line
  3101. 3092     ! BDAT:   Image=1 transmits as-is
  3102. 3093     !  ***    Image=0 Kermit tries to read file and covert # to ascii
  3103. 3094     !
  3104. 3095        IF NOT Dstate_init THEN 
  3105. 3096          ON END @File GOTO At_eof
  3106. 3097          Dstate_init=1
  3107. 3098          PRINT TABXY(25,13);"Sending File Data"&RPT$(" ",27)
  3108. 3099        END IF
  3109. 3100    !
  3110. 3101 Fill_buff: !
  3111. 3102        Bl=LEN(File_buff$)        ! Bl Buffer Length
  3112. 3103        Fg=LEN(File_get$)         ! Fg = File Get (buffer)
  3113. 3104     !
  3114. 3105     ! First Append Residue File_get$ and refresh File_get$
  3115. 3106     !
  3116. 3107        IF (Bl<Spsiz) AND (NOT At_eof) AND (Bl+Fg<Max_buff) THEN 
  3117. 3108     !
  3118. 3109     ! If Bl<Spsiz [not enough in buffer to fill a packet] AND
  3119. 3110     ! Bl+Fg<Max_buff [if adding Fget to buffer wont overflow] THEN
  3120. 3111     ! append Fget to buffer.
  3121. 3112     !
  3122. 3113          IF Fg THEN ! Otherwise DON'T Because EOL gets stuffed Each Loop
  3123. 3114            IF Image THEN 
  3124. 3115              File_buff$=File_buff$&File_get$ ! IMAGE FILL
  3125. 3116            ELSE
  3126. 3117              File_buff$=File_buff$&File_get$&File_eol$
  3127. 3118            END IF
  3128. 3119            File_get$=""
  3129. 3120          END IF
  3130. 3121      !
  3131. 3122      ! Then refill File_get$
  3132. 3123      !
  3133. 3124      ! #,-K   Fills File_get$ to dimensioned length, or EOF
  3134. 3125      !
  3135. 3126          REPEAT             ! Until Buff_full
  3136. 3127            SELECT File_type
  3137. 3128 Bdat:      CASE 2             !bdat
  3138. 3129              IF Image THEN 
  3139. 3130                ENTER @File USING "#,-K";File_get$   ! Enter bytes
  3140. 3131              ELSE
  3141. 3132              !
  3142. 3133              ! **  Enter:   INTEGER
  3143. 3134              !              REAL
  3144. 3135              !              STRING (w/Format Off)
  3145. 3136              !
  3146. 3137              ! Bdat_item spec as OPTIONAL parameter
  3147. 3138              !
  3148. 3139                REPEAT
  3149. 3140                  Bdat_item_ok=1
  3150. 3141                  SELECT Bdat_item
  3151. 3142                  CASE 1          ! integer
  3152. 3143                !   DISP "Converting Integers to Ascii"
  3153. 3144                    ENTER @File;Bdat_int
  3154. 3145                    File_get$=VAL$(Bdat_int)
  3155. 3146                  CASE 2          ! reals
  3156. 3147                !   DISP "Converting Reals to Ascii"
  3157. 3148                    ENTER @File;Bdat_real
  3158. 3149                    File_get$=VAL$(Bdat_real)
  3159. 3150                  CASE ELSE   ! not spec - best effort
  3160. 3151                    ENTER @File;File_get$
  3161. 3152                  END SELECT
  3162. 3153                UNTIL Bdat_item_ok
  3163. 3154              END IF
  3164. 3155            CASE 4         ! hp-ux
  3165. 3156              IF Image THEN 
  3166. 3157                ENTER @File USING "#,-K";File_get$
  3167. 3158              ELSE
  3168. 3159                PAUSE
  3169. 3160              !
  3170. 3161                ENTER @File;File_get$
  3171. 3162              END IF
  3172. 3163            CASE 3             ! ascii
  3173. 3164              ENTER @File;File_get$
  3174. 3165            CASE ELSE
  3175. 3166              BEEP 
  3176. 3167              DISP "FILE TYPE = ";File_type;"  Not implemented "
  3177. 3168              PAUSE
  3178. 3169            END SELECT
  3179. 3170            DISP 
  3180. 3171            GOTO Fill_it
  3181. 3172 !-------------------------------------------------------------------
  3182. 3173 ! Enter here ON END @File ...
  3183. 3174 ! If EOF then combine last file_get$ to buffer and set buff_full
  3184. 3175 ! Prog wont return to this loop because at_eof is set.
  3185. 3176 !
  3186. 3177 At_eof:    At_eof=1
  3187. 3178            IF Debug THEN PRINT TABXY(1,Crt_lines);"AT EOF","BUFF LEN = ";LEN(File_buff$)
  3188. 3179            Buff_full=1     ! avoid looping and appending CR-LF
  3189. 3180            IF Image THEN 
  3190. 3181              File_buff$=File_buff$&File_get$
  3191. 3182            ELSE
  3192. 3183              File_buff$=File_buff$&File_get$&File_eol$
  3193. 3184            END IF
  3194. 3185            File_get$=""
  3195. 3186            GOTO Full
  3196. 3187 !-------------------------------------------------------------------
  3197. 3188 Fill_it:!
  3198. 3189            Bl=LEN(File_buff$)
  3199. 3190            Fg=LEN(File_get$)
  3200. 3191            IF Bl+Fg+2>Max_buff THEN 
  3201. 3192              Buff_full=1                 ! leave File_get$ in tact
  3202. 3193            ELSE
  3203. 3194              IF Image THEN 
  3204. 3195                File_buff$=File_buff$&File_get$
  3205. 3196              ELSE
  3206. 3197                File_buff$=File_buff$&File_get$&File_eol$    !<<<<<<<<< WILL CORRUPT A BINARY FILE
  3207. 3198              END IF
  3208. 3199              File_get$=""
  3209. 3200            END IF
  3210. 3201 Full:    UNTIL Buff_full
  3211. 3202          DISP 
  3212. 3203        END IF                  ! buffer smaller than next packet   Bl<Spsiz
  3213. 3204    !-------------------------------------------------------------------
  3214. 3205        Buff_full=0             ! allow buffer to fill next time
  3215. 3206        Bl=LEN(File_buff$)      ! file buffer length
  3216. 3207    !
  3217. 3208    ! Debug: Buffer should not get to this point unless it contains at
  3218. 3209    ! least a packet full of data (if not EOF)
  3219. 3210      ! IF (Bl<Spsiz) AND (NOT At_eof) THEN
  3220. 3211      !   BEEP
  3221. 3212      !   DISP "BUFFER IS ";Bl;"  LONG","SPSIZ = ";Spsiz
  3222. 3213      ! END IF
  3223. 3214    !----------------------------------------------------------------------
  3224. 3215        IF State$="E" THEN GOTO Ksendd_exit
  3225. 3216        B=1                              ! because buff has been truncated
  3226. 3217        P=1                              ! new packet
  3227. 3218        Packet$=""        ! flush packet
  3228. 3219        Pack_full=0
  3229. 3220 Encode_pack:  !
  3230. 3221        Bytes_a=LEN(File_buff$)
  3231. 3222        Encode_pack(File_buff$,Packet$,Myquote,Qbin,Rep_ch,Spsiz)
  3232. 3223        Bytes_b=LEN(File_buff$)
  3233. 3224        Bytes_x=Bytes_x+(Bytes_a-Bytes_b)
  3234. 3225        Bytes_old=Bytes_x
  3235. 3226        IF At_eof AND (LEN(File_buff$)=0) THEN Sdata_done=1
  3236. 3227   !
  3237. 3228        Spack(Packet$,State$,Npak,Sndpkt$)
  3238. 3229        IF Debug THEN 
  3239. 3230          PRINT TABXY(25,6);Bytes_old,INT(Bytes_x/(TIMEDATE-Ft_start));"  B/SEC"
  3240. 3231        ELSE
  3241. 3232          PRINT TABXY(25,6);Bytes_old
  3242. 3233        END IF
  3243. 3234        PRINT TABXY(25,7);INT((Bytes_x/File_length)*100)
  3244. 3235        PRINT TABXY(25,10);Npak
  3245. 3236        PRINT TABXY(25,11);Oldtry+Dpacks
  3246. 3237      !
  3247. 3238      ! Send Packet Until Ack
  3248. 3239      !
  3249. 3240        REPEAT
  3250. 3241          OUTPUT @Out_buff;Sndpkt$
  3251. 3242          Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Dpacks,User_break,Emsg$)
  3252. 3243          IF Debug THEN 
  3253. 3244            PRINT TABXY(25,15);Rcvpkt$&"                "
  3254. 3245            PRINT TABXY(25,16);Sndpkt$&"                "
  3255. 3246          END IF
  3256. 3247          IF D_log THEN OUTPUT @D_log;Sndpkt$,Rcvpkt$
  3257. 3248  !
  3258. 3249          SELECT Pktype$
  3259. 3250          CASE "N"
  3260. 3251          CASE "Y"
  3261. 3252            Npak=Npak+1
  3262. 3253            IF Sdata_done THEN 
  3263. 3254              State$="Z"
  3264. 3255              PRINT TABXY(25,13);"Sending End of File"&RPT$(" ",27)
  3265. 3256            END IF
  3266. 3257          CASE "E"
  3267. 3258            Emsg$=Rdata$
  3268. 3259            State$="E"
  3269. 3260          CASE "T"
  3270. 3261            Wmsg$="Packet Timeout"
  3271. 3262          CASE "Q"
  3272. 3263            Wmsg$="Bad Checksum or Sequence"
  3273. 3264          CASE "X"
  3274. 3265            State$="Z"! jump to end of file
  3275. 3266            Wmsg$="User abort of Send File"
  3276. 3267          CASE ELSE
  3277. 3268            Wmsg$="Unknown Packet Type  "&Pktype$
  3278. 3269          END SELECT
  3279. 3270 Ksendd_exit:  ! File access errors jump and exit here
  3280. 3271          PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  3281. 3272          PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  3282. 3273             !
  3283. 3274          IF Pktype$="Y" THEN 
  3284. 3275            Old_try=Old_try+Dpacks
  3285. 3276          ELSE
  3286. 3277            Dpacks=Dpacks+1
  3287. 3278            IF Dpacks>Maxtry THEN 
  3288. 3279              State$="E"
  3289. 3280              Emsg$="Can't Receive (D) Ack from Host"
  3290. 3281            END IF
  3291. 3282          END IF
  3292. 3283     !
  3293. 3284        UNTIL Pktype$="Y" OR State$="E"
  3294. 3285    !----------------------------------------------------------------------
  3295. 3286 Ksendz:CASE "Z"
  3296. 3287  !
  3297. 3288  ! This state might be entered from local user interrruption.
  3298. 3289  ! Check User_break to determine. Rdata$= "X" or "Z" depending on intr.
  3299. 3290  ! Packet$="D" for user break discard.
  3300. 3291  !
  3301. 3292        IF Debug THEN PRINT TABXY(47,8);State$
  3302. 3293        IF User_break THEN 
  3303. 3294          Packet$="D"
  3304. 3295        ELSE
  3305. 3296          Packet$=""
  3306. 3297        END IF
  3307. 3298        IF NOT POS(Rdata$,"^C") THEN   ! Ok to notify host
  3308. 3299          Spack(Packet$,State$,Npak,Sndpkt$)
  3309. 3300          OUTPUT @Out_buff;Sndpkt$
  3310. 3301          IF Debug THEN PRINT TABXY(25,16);Sndpkt$&"                "
  3311. 3302          Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Zpacks,User_break,Emsg$)
  3312. 3303        ELSE
  3313. 3304         ! fall thru and process State$="X" for ^C event
  3314. 3305        END IF
  3315. 3306        IF Debug THEN PRINT TABXY(25,15);Rcvpkt$&"                "
  3316. 3307        IF D_log THEN OUTPUT @D_log;Sndpkt$,Rcvpkt$
  3317. 3308        SELECT Pktype$
  3318. 3309        CASE "N"
  3319. 3310        CASE "Y"
  3320. 3311          Npak=Npak+1
  3321. 3312          State$="B"
  3322. 3313        CASE "E"
  3323. 3314          Emsg$=Rdata$
  3324. 3315          State$="E"
  3325. 3316        CASE "T"
  3326. 3317          Wmsg$="Packet Timeout"
  3327. 3318        CASE "Q"
  3328. 3319          Wmsg$="Bad Checksum"
  3329. 3320        CASE "X"
  3330. 3321          State$="B"
  3331. 3322          IF Rdata$="^C" THEN 
  3332. 3323            State$="X"  ! Dont notify host just exit
  3333. 3324          END IF
  3334. 3325        CASE ELSE
  3335. 3326          Wmsg$="Unknown  Packet Type "
  3336. 3327        END SELECT
  3337. 3328  !
  3338. 3329        IF Pktype$="Y" THEN 
  3339. 3330        ELSE
  3340. 3331          Zpacks=Zpacks+1
  3341. 3332          IF Zpacks>Maxtry THEN 
  3342. 3333            State$="E"
  3343. 3334            Emsg$="Can't receive (Z) Acknowledge from host"
  3344. 3335          END IF
  3345. 3336        END IF
  3346. 3337        PRINT TABXY(25,10);Npak
  3347. 3338        PRINT TABXY(25,11);Oldtry+Zpacks
  3348. 3339        IF State$<>"Z" THEN Oldtry=Oldtry+Zpacks
  3349. 3340  !---------------------------------------------------------------------
  3350. 3341 Ksendb:CASE "B"
  3351. 3342        IF Debug THEN PRINT TABXY(47,8);State$
  3352. 3343        Packet$=""
  3353. 3344        Spack(Packet$,State$,Npak,Sndpkt$)
  3354. 3345        PRINT TABXY(25,10);Npak
  3355. 3346        PRINT TABXY(25,11);Oldtry
  3356. 3347        PRINT TABXY(25,13);RPT$(" ",55)
  3357. 3348        OUTPUT @Out_buff;Sndpkt$
  3358. 3349        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Bpacks,User_break,Emsg$)
  3359. 3350        IF Debug THEN 
  3360. 3351          PRINT TABXY(25,16);Sndpkt$&"                "
  3361. 3352          PRINT TABXY(25,15);Rcvpkt$&"                "
  3362. 3353        END IF
  3363. 3354        IF D_log THEN OUTPUT @D_log;Sndpkt$
  3364. 3355        IF D_log THEN OUTPUT @D_log;Rcvpkt$
  3365. 3356  !
  3366. 3357        SELECT Pktype$
  3367. 3358        CASE "N"
  3368. 3359        CASE "Y"
  3369. 3360          Oldtry=Oldtry+Bpacks
  3370. 3361          Npak=Npak+1
  3371. 3362          State$="C"
  3372. 3363        CASE "E"
  3373. 3364          Emsg$=Rdata$
  3374. 3365          State$="E"
  3375. 3366        CASE "T"
  3376. 3367          Wmsg$="Packet Timeout"
  3377. 3368        CASE "Q"
  3378. 3369          Wmsg$="Bad Checksum or Sequence"
  3379. 3370        CASE "X"
  3380. 3371        CASE ELSE
  3381. 3372          Wmsg$="Unknown Packet Type"
  3382. 3373        END SELECT
  3383. 3374  !
  3384. 3375        IF Pktype$="Y" THEN 
  3385. 3376        ELSE
  3386. 3377          Bpacks=Bpacks+1
  3387. 3378          IF Bpacks>Maxtry THEN 
  3388. 3379            State$="E"
  3389. 3380            Emsg$="Can't receive (B) Acknowledge from host"
  3390. 3381          END IF
  3391. 3382        END IF
  3392. 3383        PRINT TABXY(25,10);Npak
  3393. 3384        PRINT TABXY(25,11);Oldtry+Bpacks
  3394. 3385        IF State$<>"B" THEN Oldtry=Oldtry+Bpacks
  3395. 3386  !------------------------------------------------------------------------
  3396. 3387 Ksende:CASE "E"    !
  3397. 3388   !
  3398. 3389   ! Need to know if this is a local error or host error
  3399. 3390   ! User_break=Local Error
  3400. 3391   !
  3401. 3392        IF User_break THEN 
  3402. 3393          Packet$=Emsg$
  3403. 3394          Spack(Packet$,State$,Npak,Sndpkt$)
  3404. 3395          OUTPUT @Out_buff;Sndpkt$
  3405. 3396          IF D_log THEN OUTPUT @D_log;Sndpkt$
  3406. 3397          IF Debug THEN PRINT TABXY(25,16);Sndpkt$&"                "
  3407. 3398        ELSE! host error
  3408. 3399        END IF
  3409. 3400   !
  3410. 3401        PRINT TABXY(25,10);Npak
  3411. 3402        PRINT TABXY(25,11);Oldtry
  3412. 3403        State$="X"
  3413. 3404      END SELECT
  3414. 3405  !---------------------------------------------------------------------
  3415. 3406    UNTIL State$="C" OR State$="X"      ! Complete or Abort
  3416. 3407    PRINT TABXY(1,Crt_lines);RPT$(" ",80)
  3417. 3408    IF State$="C" THEN 
  3418. 3409      PRINT "SEND FILE COMPLETE"
  3419. 3410    ELSE
  3420. 3411      IF State$="X" THEN 
  3421. 3412        PRINT "User Abort"
  3422. 3413      ELSE
  3423. 3414        PRINT "SEND FILE FAILED - Host Error";Emsg$
  3424. 3415      END IF
  3425. 3416    END IF
  3426. 3417    MASS STORAGE IS Sav_msi$
  3427. 3418    SUBEXIT
  3428. 3419  !========================================================================
  3429. 3420 Check_for_rdisc:!
  3430. 3421    Ramdisc=1
  3431. 3422 Check_rdisc:MASS STORAGE IS ":,0,0"     ! err 76 incorrect unit code ?
  3432. 3423    RETURN 
  3433. 3424 !--------------------------------------------------------------------------
  3434. 3425 Get_file_entry: !
  3435. 3426    REPEAT
  3436. 3427      Get_cat_entry(F$,F_msi$,F_path$,Filename$,File_found,Cat_entry$)
  3437. 3428      IF NOT File_found THEN 
  3438. 3429        DISP "File not Found - reenter file spec - blank to abort "
  3439. 3430        OUTPUT KBD;Filename$;" H";
  3440. 3431        ENTER KBD;Misc$
  3441. 3432        DISP 
  3442. 3433        IF NOT LEN(Misc$) THEN SUBEXIT
  3443. 3434        Parse_filename(Misc$,F_msi$,F_path$)
  3444. 3435        F$=Misc$
  3445. 3436        Filename$=F_path$&F$&F_msi$
  3446. 3437      END IF
  3447. 3438    UNTIL File_found
  3448. 3439    IF NOT File_found THEN SUBEXIT
  3449. 3440    At_file$=TRIM$(Cat_entry$[1,21])
  3450. 3441    At_type$=TRIM$(Cat_entry$[32,36])
  3451. 3442    At_rec=VAL(Cat_entry$[37,45])
  3452. 3443    At_recl=VAL(Cat_entry$[46,54])
  3453. 3444    At_time$=TRIM$(Cat_entry$[56,71])
  3454. 3445    File_length=At_rec*At_recl*1.00
  3455. 3446    RETURN 
  3456. 3447  !------------------------------------------------------------------------
  3457. 3448 Set_at: !   FORM FILE ATTRIBUTES PACKET DATA
  3458. 3449   !
  3459. 3450   ! Put File Attributes for F$ into Packet$
  3460. 3451   ! Packet$ is in form:  ATTRIBUTE(char), LENGTH(unchar), DATA(char)
  3461. 3452     !
  3462. 3453     ! ! or 1    File length (Bytes)
  3463. 3454     ! "         Data Type
  3464. 3455     ! #         Creation Date
  3465. 3456     ! .         Machine and OS
  3466. 3457     ! /         Format Of Data          File_format$,File_type,File_delim$
  3467. 3458     !
  3468. 3459  ! CAT F_path$&F_msi$ TO Cat$(*);SELECT F$  ! FILE IS ELMENT 8
  3469. 3460   !
  3470. 3461   ! LIF:    TYPE  32-36  [5]
  3471. 3462   !         REC   37-45  [9]
  3472. 3463   !         RECL  46-54  [9]
  3473. 3464   !         TIME  56-71  [22]
  3474. 3465   !
  3475. 3466    At_length$=VAL$(File_length)        ! BYTES
  3476. 3467    At_os$="H4"                         !  Machine and OS !  H4=hp9000 RMB
  3477. 3468    SELECT At_type$
  3478. 3469    CASE "HP-UX"    ! w/ format on
  3479. 3470      At_fmt$="A"
  3480. 3471    CASE "ASCII"
  3481. 3472      At_fmt$="D"
  3482. 3473    CASE "BDAT"      ! w/ format off       ! M=recl  status reg 4
  3483. 3474      At_fmt$="F"
  3484. 3475      STATUS @File,4;At_recl
  3485. 3476    END SELECT
  3486. 3477   !------------  start attribute packet
  3487. 3478    Next_at=1
  3488. 3479    Packet$[Next_at;1]="1"                !1  file length (bytes)
  3489. 3480    Atl=LEN(At_length$)
  3490. 3481    Packet$[Next_at+1;1]=FNTochar$(Atl)
  3491. 3482    Packet$[Next_at+2;Atl]=At_length$
  3492. 3483    Next_at=Next_at+2+Atl
  3493. 3484   !
  3494. 3485   ! Data Format  (use file type)
  3495. 3486   !
  3496. 3487    Packet$[Next_at;1]=""""               !"    file (data) type
  3497. 3488    Atl=LEN(At_type$)
  3498. 3489    Packet$[Next_at+1;1]=FNTochar$(Atl)
  3499. 3490    Packet$[Next_at+2;Atl]=At_type$
  3500. 3491    Next_at=Next_at+2+Atl
  3501. 3492   !
  3502. 3493    Packet$[Next_at;1]="/"                !/    data format  on/off
  3503. 3494    Atl=LEN(At_fmt$)
  3504. 3495    Packet$[Next_at+1;1]=FNTochar$(Atl)
  3505. 3496    Packet$[Next_at+2;Atl]=At_fmt$
  3506. 3497    Next_at=Next_at+2+Atl
  3507. 3498  !
  3508. 3499                                  ! Creation Date [yy]yymmdd[  hh:mm[ :ss]
  3509. 3500    Packet$[Next_at;1]="#"        !#    timedate
  3510. 3501    Atl=LEN(At_time$)
  3511. 3502    Packet$[Next_at+1;1]=FNTochar$(Atl)
  3512. 3503    Packet$[Next_at+2;Atl]=At_time$
  3513. 3504    Next_at=Next_at+2+Atl
  3514. 3505   !
  3515. 3506    Packet$[Next_at;1]="."        !.    Machine and Operating System
  3516. 3507    Atl=LEN(At_os$)
  3517. 3508    Packet$[Next_at+1;1]=FNTochar$(Atl)
  3518. 3509    Packet$[Next_at+2;Atl]=At_os$
  3519. 3510    Next_at=Next_at+2+Atl
  3520. 3511   !
  3521. 3512    RETURN 
  3522. 3513   !-----------------------------------------------------------------------
  3523. 3514 Send_intr: !      ! COMM PORT INTERRUPT HANDLER
  3524. 3515    CALL Com_interrupt
  3525. 3516    Shutdown
  3526. 3517    ON INTR Com_port,15 GOSUB Send_intr
  3527. 3518    SELECT Com_card
  3528. 3519    CASE 98628
  3529. 3520      CONTROL Com_port,13;164      ! MASK  4=UART  32=lost carr 128=break
  3530. 3521    CASE 98626,98644
  3531. 3522      ENABLE INTR Com_port;4
  3532. 3523    END SELECT
  3533. 3524    ON ERROR GOSUB Send_err
  3534. 3525    Startup
  3535. 3526    RETURN 
  3536. 3527  !-----------------------------------------------
  3537. 3528 Send_err:  !
  3538. 3529    SELECT ERRN
  3539. 3530    CASE 29   ! illegal floating point number
  3540. 3531      Wmsg$="Illegal Floating Point Number"
  3541. 3532      Emsg$="File I/O Error - cannot continue"
  3542. 3533      State$="E"
  3543. 3534      User_break=1
  3544. 3535      ERROR RETURN
  3545. 3536    CASE 52,73,76 ! Improper MSVS,device type,Unit Number
  3546. 3537    !
  3547. 3538    ! Checking for existance of Ramdisc
  3548. 3539    !
  3549. 3540      IF ERRL(Check_rdisc) THEN 
  3550. 3541        Ramdisc=0
  3551. 3542        ERROR RETURN
  3552. 3543      ELSE
  3553. 3544        DISP ERRM$
  3554. 3545      END IF
  3555. 3546    CASE 53        ! improper filename
  3556. 3547      DISP "Improper filename, please correct "
  3557. 3548      OUTPUT KBD;Filename$;" H";
  3558. 3549      ENTER KBD;F$
  3559. 3550      Parse_filename(F$,F_msi$,F_path$)
  3560. 3551      Filename$=F_path$&F$&F_msi$
  3561. 3552      DISP 
  3562. 3553    CASE 54   ! Duplicate File Name
  3563. 3554      ASSIGN @Test TO *
  3564. 3555      PRINT TABXY(25,13);"Purged and Overwrite ";F$&Ram_msi$
  3565. 3556      PURGE F$&Ram_msi$
  3566. 3557    CASE 56   ! Filename Undefined
  3567. 3558      DISP "Cannot Access FILE  -  blank Filename will exit"
  3568. 3559      OUTPUT KBD;Filename$;
  3569. 3560      ENTER KBD;F$
  3570. 3561      Parse_filename(F$,F_msi$,F_path$)
  3571. 3562      DISP 
  3572. 3563      IF NOT LEN(F$) THEN SUBEXIT
  3573. 3564      Filename$=F_path$&F$&F_msi$
  3574. 3565    CASE 58   ! Improper File Type
  3575. 3566      DISP "Improper filename, please correct "
  3576. 3567      OUTPUT KBD;Filename$;" H";
  3577. 3568      ENTER KBD;Misc$
  3578. 3569      Parse_filename(Misc$,F_msi$,F_path$)
  3579. 3570      F_path$=F_path$&Misc$
  3580. 3571      DISP 
  3581. 3572    CASE 90   ! Mass Storage System Error
  3582. 3573      RESET 7
  3583. 3574    CASE 157  ! No ENTER Terminator found
  3584. 3575    !
  3585. 3576    ! If sending BDAT files, exit
  3586. 3577    ! if the ascii terminator not found
  3587. 3578    !
  3588. 3579      IF NOT Image THEN 
  3589. 3580        Wmsg$="File contents not ASCII"
  3590. 3581        Emsg$="File I/O Error - cannot continue"
  3591. 3582        State$="E"
  3592. 3583        User_break=1
  3593. 3584        ERROR RETURN
  3594. 3585      END IF
  3595. 3586    CASE 167,168
  3596. 3587      CALL Com_interrupt              ! Trap previous activity at com port
  3597. 3588    CASE ELSE
  3598. 3589      BEEP 
  3599. 3590      DISP ERRM$&"  PAUSED"
  3600. 3591      PAUSE
  3601. 3592    END SELECT
  3602. 3593   !
  3603. 3594    DISP 
  3604. 3595    RETURN 
  3605. 3596 !-------------------------------------------------------------------------
  3606. 3597 Spar:  !  Form Initialization Packet
  3607. 3598  !
  3608. 3599  ! Packet$="^A, S~(  *#&1 *"
  3609. 3600  !
  3610. 3601    Packet$=""                         !^A   PACKET MARK
  3611. 3602                                       ! ,   44-32=12   PKT LENGTH
  3612. 3603                                       ! sp  32-32=0    SEQUENCE
  3613. 3604                                       ! S   PACKET TYPE (INIT)
  3614. 3605    Packet$[1,1]=FNTochar$(Maxp)       ! ~   126-32=94
  3615. 3606    Packet$[2,2]=FNTochar$(Mytmo)      ! (    40-32=8
  3616. 3607    Packet$[3,3]=FNTochar$(Mypad)      ! sp   32-32=0
  3617. 3608    Packet$[4,4]=FNTochar$(Mypchar)    ! sp   32-32=0
  3618. 3609    Packet$[5,5]=FNTochar$(Myeol)      ! *    42-32=10
  3619. 3610    Packet$[6,6]=CHR$(Myquote)         ! #    CONTROL QUOTE (0-31)
  3620. 3611    Packet$[7,7]="&"                   ! &    8TH BIT PREFIX
  3621. 3612    Packet$[8,8]="1"                   ! 1    CHECK TYPE
  3622. 3613    Packet$[9,9]=" "                   ! sp   NO REPEAT COUNT PROCESS
  3623. 3614    IF Send_at THEN 
  3624. 3615      Packet$[10,10]="("               ! USE ATTRIBUTE PACKETS
  3625. 3616    END IF
  3626. 3617   !-----------------------------------!------------------------------
  3627. 3618  ! EXTENDED PACKET SIZE               ! sp sp ~
  3628. 3619    RETURN 
  3629. 3620  !------------------------------------------------------------------------
  3630. 3621 Rpar:  ! Receive Packet Initialization FROM REMOTE
  3631. 3622        ! Rdata$[] DATA STRIPPED FROM INCOMING PACKET
  3632. 3623    Rpsiz=FNUnchar(Rdata$[1])
  3633. 3624    Ptmo=FNUnchar(Rdata$[2])
  3634. 3625    Pad=FNUnchar(Rdata$[3])
  3635. 3626    Padchar=FNUnchar(Rdata$[4])
  3636. 3627    Eol=FNUnchar(Rdata$[5])
  3637. 3628    IF Eol=0 THEN Eol=Myeol
  3638. 3629    Myquote=NUM(Rdata$[6,6])
  3639. 3630    Myquote$=CHR$(Myquote)
  3640. 3631    IF LEN(Rdata$)>6 THEN Qbin=NUM(Rdata$[7,7])
  3641. 3632    Qbin$=CHR$(Qbin)
  3642. 3633    IF Qbin=89 THEN Qbin=38     ! 89=Y , 38=&
  3643. 3634    IF Qbin=0 THEN Qbin=38
  3644. 3635    IF LEN(Rdata$)>7 THEN R_bchk=VAL(Rdata$[8,8])
  3645. 3636    IF LEN(Rdata$)>8 THEN Rep_char=NUM(Rdata$[9,9])
  3646. 3637    IF LEN(Rdata$)>9 THEN R_capas=FNUnchar(Rdata$[10,10])
  3647. 3638    IF BIT(R_capas,1) THEN    ! extended length packets
  3648. 3639      Rcap_lp=1
  3649. 3640      R_windo=FNUnchar(Rdata$[11,11])
  3650. 3641      R_maxl1=FNUnchar(Rdata$[12,12])
  3651. 3642      R_maxl2=FNUnchar(Rdata$[13,13])
  3652. 3643      R_maxl=R_maxl1*95+R_maxl2
  3653. 3644    END IF
  3654. 3645    IF BIT(R_capas,3) THEN Rcap_a=1
  3655. 3646    RETURN 
  3656. 3647  !-----------------------------------------------------------------
  3657. 3648  SUBEND                          ! END OF KERMIT SEND
  3658. 3649  ! =======================================================================
  3659. 3650 Set_frame:SUB Set_frame(Req_baud)
  3660. 3651  !
  3661. 3652  ! Resets HW and SW Handshake registers, does not reset INT MASK
  3662. 3653  !
  3663. 3654    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  3664. 3655    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$[3],Parity_type$[4]
  3665. 3656    COM /Frame/ Flow$,Hshake$
  3666. 3657    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  3667. 3658    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  3668. 3659    INTEGER Transfer_on,P,Pt,B,S
  3669. 3660  !
  3670. 3661    SELECT Req_baud
  3671. 3662    CASE <301
  3672. 3663      Baud=300
  3673. 3664    CASE <1201
  3674. 3665      Baud=1200
  3675. 3666    CASE <2401
  3676. 3667      Baud=2400
  3677. 3668    CASE <4801
  3678. 3669      Baud=4800
  3679. 3670    CASE <9601
  3680. 3671      Baud=9600
  3681. 3672    CASE ELSE
  3682. 3673      Baud=19200
  3683. 3674    END SELECT
  3684. 3675    IF Active THEN 
  3685. 3676      Shutdown(Transfer_on)
  3686. 3677    END IF
  3687. 3678    SELECT Com_card
  3688. 3679    CASE 98626,98644
  3689. 3680      GOSUB Sf26
  3690. 3681    CASE 98628
  3691. 3682      GOSUB Sf28
  3692. 3683    CASE ELSE
  3693. 3684      BEEP 
  3694. 3685      DISP "com card = ";Com_card,"unknown (paused)"
  3695. 3686      PAUSE
  3696. 3687    END SELECT
  3697. 3688    IF Transfer_on THEN 
  3698. 3689      Startup
  3699. 3690    END IF
  3700. 3691    SUBEXIT
  3701. 3692  !----------------------
  3702. 3693 Sf28:  !  SET FRAME ON 98628 DATACOMM CARD
  3703. 3694    SELECT Baud
  3704. 3695    CASE 300
  3705. 3696      Bd=7
  3706. 3697    CASE 1200
  3707. 3698      Bd=9
  3708. 3699    CASE 2400
  3709. 3700      Bd=11
  3710. 3701    CASE 4800
  3711. 3702      Bd=13
  3712. 3703    CASE 9600
  3713. 3704      Bd=14
  3714. 3705    CASE 19200
  3715. 3706      Bd=15
  3716. 3707    CASE ELSE
  3717. 3708      BEEP 
  3718. 3709      DISP "BAUD RATE: ";Baud;"  NOT IMPLEMENTED "
  3719. 3710      PAUSE
  3720. 3711    END SELECT
  3721. 3712    SELECT Data_bits
  3722. 3713    CASE 7
  3723. 3714      B=2
  3724. 3715    CASE 8
  3725. 3716      B=3
  3726. 3717    END SELECT
  3727. 3718    SELECT Stop_bits
  3728. 3719    CASE 1
  3729. 3720      S=0
  3730. 3721    CASE 2
  3731. 3722      S=2
  3732. 3723    END SELECT
  3733. 3724    SELECT TRIM$(UPC$(On_off$))
  3734. 3725    CASE "ON"
  3735. 3726      Pt=5
  3736. 3727    CASE "OFF"
  3737. 3728      Pt=0
  3738. 3729    END SELECT
  3739. 3730 Set_pt: !
  3740. 3731    IF Pt THEN                ! IF PARITY IS ON THEN
  3741. 3732      SELECT UPC$(Parity_type$)
  3742. 3733      CASE "NONE","OFF"
  3743. 3734        Pt=0
  3744. 3735      CASE "ODD"
  3745. 3736        Pt=1
  3746. 3737      CASE "EVEN"
  3747. 3738        Pt=2
  3748. 3739      CASE "MARK","1"
  3749. 3740        Pt=4
  3750. 3741      CASE "SPACE","0"
  3751. 3742        Pt=3
  3752. 3743      END SELECT
  3753. 3744    END IF
  3754. 3745    IF Pt>4 THEN 
  3755. 3746      BEEP 
  3756. 3747      INPUT "WHAT PARITY TYPE ? [NONE,ODD,EVEN,1,0] ",Parity_type$
  3757. 3748      IF TRIM$(UPC$(Parity_type$))="NONE" THEN Pt=0
  3758. 3749      GOTO Set_pt
  3759. 3750    END IF
  3760. 3751    CONTROL Com_port,20;Bd       ! SET BAUD RATE
  3761. 3752    CONTROL Com_port,21;Bd       ! SET Rec  RATE
  3762. 3753    CONTROL Com_port,34;B,S,Pt   ! SET DATA BITS, STOP, PARITY
  3763. 3754    CONTROL Com_port,8;1+2       ! RTS  DTR  Set Active
  3764. 3755    SELECT Flow$
  3765. 3756    CASE "XON/XOFF"
  3766. 3757      CONTROL Com_port,22;5  ! Protocol (sw) off  2:enq/ack  5/XON-XOFF
  3767. 3758    CASE "ENQ/ACK"
  3768. 3759      CONTROL Com_port,22;2  ! Protocol (sw) off  2:enq/ack  5/XON-XOFF
  3769. 3760    CASE ELSE
  3770. 3761      CONTROL Com_port,22;0  ! Protocol (sw) off  2:enq/ack  5/XON-XOFF
  3771. 3762    END SELECT
  3772. 3763    IF Hshake$="ON" THEN 
  3773. 3764      CONTROL Com_port,23;1  ! Handshake On
  3774. 3765    ELSE
  3775. 3766      CONTROL Com_port,23;0  ! Handshake Off
  3776. 3767    END IF
  3777. 3768    RETURN 
  3778. 3769    !----------------------------------
  3779. 3770 Sf26:   !     SET FRAME FOR 98626/98644
  3780. 3771    SELECT Data_bits
  3781. 3772    CASE 7
  3782. 3773      B=2
  3783. 3774    CASE 8
  3784. 3775      B=3
  3785. 3776    END SELECT
  3786. 3777    SELECT Stop_bits
  3787. 3778    CASE 1
  3788. 3779      S=0
  3789. 3780    CASE 2
  3790. 3781      S=4
  3791. 3782    END SELECT
  3792. 3783    SELECT TRIM$(UPC$(On_off$))
  3793. 3784    CASE "ON"
  3794. 3785      P=8
  3795. 3786    CASE "OFF"
  3796. 3787      P=0
  3797. 3788    END SELECT
  3798. 3789    SELECT UPC$(Parity_type$)
  3799. 3790    CASE "ODD"
  3800. 3791      Pt=0
  3801. 3792    CASE "EVEN"
  3802. 3793      Pt=16
  3803. 3794    CASE "MARK","1"
  3804. 3795      Pt=32
  3805. 3796    CASE "SPACE","0"
  3806. 3797      Pt=48
  3807. 3798    END SELECT
  3808. 3799    CONTROL Com_port,3;Baud,B+S+P+Pt   ! set reg 3 and 4
  3809. 3800    CONTROL Com_port,5;1+2             ! set RTS and DTR Active
  3810. 3801    IF Hshake$="ON" THEN 
  3811. 3802      CONTROL Com_port,12;0  ! Handshake On
  3812. 3803    ELSE
  3813. 3804      CONTROL Com_port,12;128+32+16    ! Ignore CTS,DSR,CD
  3814. 3805    END IF
  3815. 3806    RETURN 
  3816. 3807 !--------------------------
  3817. 3808  SUBEND
  3818. 3809 ! ========================================================================
  3819. 3810 Ci:SUB Com_interrupt         ! transfers may be running
  3820. 3811   !
  3821. 3812    OPTION BASE 1
  3822. 3813    DISP CHR$(129);"CI"
  3823. 3814  ! uses:
  3824. 3815  ! Com_card, Com_port, Debug
  3825. 3816  !
  3826. 3817    COM /Crt/ Crt_lines,Crt_width
  3827. 3818    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  3828. 3819  ! COM /Frame/ Baud,Data_bits,Stop_bits,On_off$,Parity_type$
  3829. 3820  ! COM /Frame/ Flow$,Hshake$
  3830. 3821    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  3831. 3822    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  3832. 3823  !
  3833. 3824    ON ERROR GOSUB Local_err
  3834. 3825    Errno=ERRN
  3835. 3826    IF Errno=0 THEN 
  3836. 3827      Errno=167                 ! INCASE THIS IS A REAL INTERRUPT NOT ERROR
  3837. 3828    END IF
  3838. 3829    GOSUB Local_err             ! PROCESS ERROR 167 - UART
  3839. 3830    DISP CHR$(128)
  3840. 3831    SUBEXIT
  3841. 3832  !-------------------------------------
  3842. 3833 Local_err: !
  3843. 3834    SELECT Errno
  3844. 3835    CASE 167                    ! process interrupt as error 167
  3845. 3836      SELECT Com_card
  3846. 3837      CASE 98644,98626
  3847. 3838        GOSUB Com_intr_26
  3848. 3839      CASE 98628
  3849. 3840        GOSUB Com_intr_28
  3850. 3841      CASE ELSE
  3851. 3842      END SELECT
  3852. 3843    CASE 163     ! io interace driver not present
  3853. 3844      DISP ERRM$
  3854. 3845      PAUSE
  3855. 3846    CASE 59        ! end of buffer found
  3856. 3847    ! do nothing -
  3857. 3848      CLEAR ERROR
  3858. 3849    CASE ELSE
  3859. 3850      DISP ERRM$;" Com_interrupt  "
  3860. 3851      PAUSE
  3861. 3852    END SELECT
  3862. 3853  !-----------------------------------------------------------------------
  3863. 3854 Com_intr_26: !
  3864. 3855   !
  3865. 3856   ! Reg. 9:  Bit 0      Set when all conditions are clear
  3866. 3857   !          Bit 1,2    Interrupt Cuase
  3867. 3858   !
  3868. 3859    STATUS Com_port,9;Int_cause,Uart_err    ! and clear int
  3869. 3860    REPEAT
  3870. 3861      Ic=BINAND(Int_cause,7)   ! Look at bits 0-1-2
  3871. 3862      SELECT Ic
  3872. 3863      CASE 0                      ! change in modem status lines
  3873. 3864        STATUS Com_port,11;Mc     ! Modem Change
  3874. 3865        IF (BIT(Mc,4)) OR (BIT(Mc,5)) OR (BIT(Mc,6)) OR (BIT(Mc,7)) THEN 
  3875. 3866          IF Debug THEN PRINT TABXY(1,Crt_lines);"Serial Interrupt: Modem Line Disconnect"
  3876. 3867        ELSE
  3877. 3868          IF Debug THEN PRINT TABXY(1,Crt_lines);"Serial Interrupt: Modem Line Change "
  3878. 3869        END IF
  3879. 3870      CASE 2
  3880. 3871      CASE 4
  3881. 3872        IF Debug THEN PRINT "RECEIVE BUFFER FULL"
  3882. 3873        STATUS Com_port,6;Rec     ! Clear Interrupt
  3883. 3874      CASE 6                      ! UART Error
  3884. 3875        STATUS Com_port,6;Rec     ! Clear Interrupt
  3885. 3876        IF Debug THEN 
  3886. 3877          PRINT "UART ERROR: ";Uart_err
  3887. 3878          IF BIT(Uart_err,0) THEN PRINT "Rec. Buffer Full";   ! (1)
  3888. 3879    !     IF BIT(Uart_err,1) THEN PRINT "Rec. Buffer Overrun";     ! (2)
  3889. 3880          IF BIT(Uart_err,2) THEN PRINT "Parity Error";          ! (4)
  3890. 3881          IF BIT(Uart_err,3) THEN PRINT "Framing Error";    ! (8)
  3891. 3882          IF BIT(Uart_err,4) THEN PRINT "Break Received ";  ! (16)
  3892. 3883    !     IF BIT(Uart_err,5) THEN PRINT "Trans. Hold. Reg ";! (32)
  3893. 3884    !     IF BIT(Uart_err,6) THEN PRINT "Trans. Shift Reg ";! (64)
  3894. 3885          PRINT 
  3895. 3886        END IF
  3896. 3887      END SELECT
  3897. 3888      STATUS Com_port,9;Int_cause,Uart_err    ! BIT 0= SET when all intr are clear
  3898. 3889    UNTIL Int_cause=1
  3899. 3890    RETURN 
  3900. 3891 !======================================================================
  3901. 3892 Com_intr_28: !
  3902. 3893 Rc28: !
  3903. 3894 !
  3904. 3895    STATUS Com_port,4;Int_bits      ! RESET INTERRUPT
  3905. 3896    IF Debug THEN 
  3906. 3897      PRINT "INTERRUPT CAUSE:  "
  3907. 3898      IF BIT(Int_bits,0) THEN PRINT "DATA";
  3908. 3899      IF BIT(Int_bits,1) THEN PRINT "PROMPT REC.";
  3909. 3900      IF BIT(Int_bits,2) THEN PRINT "PARITY ERROR ";
  3910. 3901      IF BIT(Int_bits,3) THEN PRINT "MODEM LINE CHANGE ";
  3911. 3902      IF BIT(Int_bits,4) THEN PRINT "NO ACTIVITY TIMEOUT ";
  3912. 3903      IF BIT(Int_bits,5) THEN PRINT "LOST CARRIER ";
  3913. 3904      IF BIT(Int_bits,6) THEN PRINT "EOL RECEIVED ";
  3914. 3905      IF BIT(Int_bits,7) THEN PRINT "BREAK RECEIVED ";
  3915. 3906      PRINT 
  3916. 3907    END IF
  3917. 3908    RETURN 
  3918. 3909  SUBEND          ! Comm Interrupt-98628
  3919. 3910  ! ======================================================================
  3920. 3911 Krec:SUB K_receive(Filename$,F_msi$,F_path$,Ftype$,Recl,File_length,Get_cmd,OPTIONAL Localname$)
  3921. 3912  !
  3922. 3913  ! Kermit Receive  File Protocol
  3923. 3914  !
  3924. 3915  ! File_length:     Bytes    if Filetype HPUX
  3925. 3916  !                  Records  if Filetype BDAT
  3926. 3917  !                  Sectors  if Filetype ASCII,SYSTM,BIN,PROG
  3927. 3918  !
  3928. 3919  ! Recl             Record length (BDAT ONLY)
  3929. 3920  !
  3930. 3921    OPTION BASE 1
  3931. 3922    COM Version$,K$,Setup$
  3932. 3923    COM /Crt/ Crt_lines,Crt_width
  3933. 3924    COM /Flags/ Kermit_exit,INTEGER Active,Debug,In_term
  3934. 3925    COM /Kerm/ INTEGER Maxp,Maxtry,Mypad,Mytmo,Mypchar,Myeol,Myquote
  3935. 3926    COM /Kerm/ INTEGER Size,Rpsiz,Spsiz,Pad,Capas,Send_at
  3936. 3927    COM /Kerm/ INTEGER Image,Parflg,Pktdeb
  3937. 3928    COM /Kerm/ INTEGER Filnamcnv,Blk_chk,Quote,Eol,Smark
  3938. 3929    COM /Kerm2/ State$[1],Cchksum$[1],Eof_mode$,INTEGER Eof_mode,Timer,Ptmo
  3939. 3930    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  3940. 3931    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  3941. 3932    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$[3],Parity_type$[4]
  3942. 3933    COM /Frame/ Flow$,Hshake$
  3943. 3934    COM /Term/ Term_type$[10],S_log,D_log,Filewarn,Discard,@S_log,@D_log
  3944. 3935    COM /Term/ Kerm_esc$[2],S_log$,D_log$,INTEGER Remote,Lecho,Turn,Display
  3945. 3936    COM /Term/ Term_mode$
  3946. 3937    COM /Path/ Cur_msi$,S_path$,S_msi$,D_path$,D_msi$
  3947. 3938  !
  3948. 3939  ! Local Vars
  3949. 3940  !
  3950. 3941    INTEGER Qbin,Rep_ch   ! not in kermit COM
  3951. 3942    INTEGER Chksum,Rc,Plen,Dlen,Cchksum,Rseq
  3952. 3943    INTEGER Ftype,Volnum,Prot,Recsize,Sec_data(1:256),Sectors
  3953. 3944    INTEGER File_open
  3954. 3945    INTEGER Npak,Oldtry,Spacks,Fpacks,Apacks,Dpacks,Zpacks,Bpacks,Epacks
  3955. 3946    INTEGER R_maxl1,R_maxl2,R_maxl
  3956. 3947    INTEGER User_break,Spillfile,Use_ram
  3957. 3948    REAL File_st,F_sec
  3958. 3949    ALLOCATE Rcvpkt$[1024],Sndpkt$[Spsiz],Rdata$[1024],A$[1],Packet$[Spsiz]
  3959. 3950    ALLOCATE File_buff$[4096],Sector$[256]
  3960. 3951    DIM Emsg$[100],Wmsg$[100],Pkt$[1]                 !,Cat$(10)[80]
  3961. 3952    DIM Asc_eol$[2]
  3962. 3953    DIM F$[80],Sav_msi$[256]
  3963. 3954  !--------------------------------------------
  3964. 3955    ON ERROR GOSUB Rec_err
  3965. 3956    Spillfile=0      ! indicates that a spillfile was needed
  3966. 3957    Use_ram=0
  3967. 3958    Asc_eol$=CHR$(13)&CHR$(10)
  3968. 3959    Buff_len=MAXLEN(File_buff$)
  3969. 3960    Sav_msi$=SYSTEM$("MSI")
  3970. 3961 !-------------------------------
  3971. 3962    IF POS(F_msi$,":MEMORY") OR POS(F_msi$,":,0") OR POS(F_msi$,":, 0") THEN Use_ram=1
  3972. 3963    IF Ftype$="PROG" OR Ftype$="BIN" OR Ftype$="SYSTM" THEN Use_ram=1
  3973. 3964    IF Use_ram THEN 
  3974. 3965      Ramdisc=0
  3975. 3966 Check_ramdisc:MASS STORAGE IS ":,0,0"   ! check in rec_err
  3976. 3967      MASS STORAGE IS Sav_msi$
  3977. 3968      IF Kbytes=0 THEN 
  3978. 3969        Disc_space(":,0,0",Total,Largest_hole,Hole_sum,Format$)
  3979. 3970        IF Largest_hole>0 THEN Ramdisc=1
  3980. 3971        Kbytes=Largest_hole*256
  3981. 3972      END IF
  3982. 3973    END IF
  3983. 3974  !------------------------------
  3984. 3975    CALL Shutdown
  3985. 3976   !
  3986. 3977   ! 98626 overrun error cannot be trapped during transfers - therefore
  3987. 3978   ! they only show up as error 167 IO status error
  3988. 3979   !
  3989. 3980    SELECT Com_card
  3990. 3981    CASE 98626,98644
  3991. 3982  !   CALL Reset_port             ! Accidentally  Disconnects Modem
  3992. 3983      ENABLE INTR Com_port;8+4               ! 8=modem   4=UART or Overrun
  3993. 3984    CASE 98628                               ! 2=tx reg  1=rec buff full
  3994. 3985  !   CALL Reset_port
  3995. 3986      CONTROL Com_port,13;164     ! INT MASK  4=UART  32=lost car 128=break
  3996. 3987    END SELECT
  3997. 3988  !
  3998. 3989    ON INTR Com_port,5 GOSUB Rec_intr
  3999. 3990    ON TIMEOUT 7,.5 GOSUB No_printer
  4000. 3991    ON KBD,3 GOSUB Kbr_int
  4001. 3992    CLEAR SCREEN
  4002. 3993    IF Display THEN 
  4003. 3994      PRINT TABXY(1,2);Version$
  4004. 3995      PRINT TABXY(15,5);"Filename: "                    ! LINE 5
  4005. 3996      PRINT TAB(6);"Bytes Transferred: ";TAB(25);Kbx   ! 6
  4006. 3997      PRINT 
  4007. 3998      PRINT TAB(16);"RECEIVE: In Progress"              ! 8
  4008. 3999      PRINT                                             ! 9
  4009. 4000      PRINT TAB(6);"Number of Packets: ";TAB(25);Npak   ! 10
  4010. 4001      PRINT TAB(6);"Number of Retries: ";TAB(25);Oldtry ! 11
  4011. 4002      PRINT TAB(13);"Last Error: "                      ! 12
  4012. 4003      PRINT TAB(11);"Last Warning: "                    ! 13
  4013. 4004                                                        ! 14
  4014. 4005      IF Debug THEN 
  4015. 4006        PRINT TABXY(11,15);"SPACK:        "             ! 15
  4016. 4007        PRINT TABXY(11,16);"RPACK:        "             ! 16
  4017. 4008      END IF
  4018. 4009    END IF
  4019. 4010    PRINT TABXY(1,Crt_lines-1);CHR$(129);"^X cancels File, ^E Quits Protocol, ^C Quits, Return retries";CHR$(128)
  4020. 4011    CALL Startup     ! re-activate transfers
  4021. 4012 Krecs:    !-------------------------------------  Receive
  4022. 4013    Input_buffer$=""
  4023. 4014    Npak=0
  4024. 4015    State$="S"
  4025. 4016  !------------------------ GET R Packet --------------------------------
  4026. 4017    IF Get_cmd THEN 
  4027. 4018 Krecr:State$="R"
  4028. 4019      Packet$=Filename$
  4029. 4020      Spack(Packet$,State$,Npak,Sndpkt$)
  4030. 4021      PRINT TABXY(25,13);"Requesting File Send"
  4031. 4022      OUTPUT @Out_buff;Sndpkt$
  4032. 4023      IF Debug THEN PRINT TABXY(25,15);Sndpkt$&RPT$(" ",100)
  4033. 4024      IF D_log THEN OUTPUT @D_log;Sndpkt$
  4034. 4025      State$="S"
  4035. 4026    !
  4036. 4027      IF NPAR>7 THEN 
  4037. 4028        Filename$=Localname$
  4038. 4029      ELSE
  4039. 4030    ! Need to check here for a "DOS" type illegal filename
  4040. 4031      END IF
  4041. 4032    END IF
  4042. 4033  !
  4043. 4034  !------------------------  Receive  Sequence  --------------------------
  4044. 4035  !
  4045. 4036    REPEAT   ! Until State$="X","C"   receive done
  4046. 4037      SELECT State$         ! state switcher
  4047. 4038      CASE "S"
  4048. 4039 Sinit:  !
  4049. 4040        Packet$=""   ! Packet Data
  4050. 4041        Pkt$="N"     ! Nak unless expected packet arives
  4051. 4042        PRINT TABXY(25,13);"Exchanging Initialization Packets"
  4052. 4043        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Spacks,User_break,Emsg$)
  4053. 4044        IF (Debug) THEN PRINT TABXY(20,16);Rcvpkt$&RPT$(" ",20)
  4054. 4045        IF D_log THEN OUTPUT @D_log;"rpack: ";Rcvpkt$
  4055. 4046        SELECT Pktype$
  4056. 4047        CASE "S"
  4057. 4048          GOSUB Rrpar         ! Get remote Parameters
  4058. 4049          GOSUB Rspar         ! Form Packet$ with our parameters
  4059. 4050          Pkt$="Y"
  4060. 4051          State$="F"
  4061. 4052        CASE "E"            ! Either received or user abort E
  4062. 4053          IF NOT User_break THEN Emsg$=Rdata$
  4063. 4054          State$="E"
  4064. 4055        CASE "T"
  4065. 4056          Wmsg$="Packet Timeout"
  4066. 4057        CASE "Q"
  4067. 4058          Wmsg$="Bad Checksum"
  4068. 4059        CASE "F","A","D"
  4069. 4060          ! just Nak the expected packet number
  4070. 4061        CASE "Z","B"
  4071. 4062          State$=Pktype$         ! jump to eof or break state
  4072. 4063        CASE "X"            ! User Quit
  4073. 4064          Pkt$="Y"
  4074. 4065          Packet$=Rdata$    ! X or Z in ack packet will abort sender
  4075. 4066          State$="Z"        ! let Z state process closure
  4076. 4067        CASE "N"
  4077. 4068          IF Get_cmd THEN 
  4078. 4069            OUTPUT @Out_buff;Sndpkt$  ! Re-send "R" Packet
  4079. 4070          END IF
  4080. 4071        END SELECT
  4081. 4072      !
  4082. 4073        Spack(Packet$,Pkt$,Npak,Sndpkt$)
  4083. 4074        OUTPUT @Out_buff;Sndpkt$
  4084. 4075      !
  4085. 4076        IF Spacks>Maxtry THEN 
  4086. 4077          State$="E"
  4087. 4078          User_break=1
  4088. 4079          Emsg$="Unable to receive initiate"
  4089. 4080          Packet$=Emsg$
  4090. 4081        END IF
  4091. 4082        IF Pkt$="Y" THEN 
  4092. 4083     !    State$="F"            ! could  be X if aborting
  4093. 4084          Npak=Npak+1
  4094. 4085          Oldtry=Oldtry+Spacks
  4095. 4086        ELSE
  4096. 4087          Spacks=Spacks+1
  4097. 4088        END IF
  4098. 4089      !
  4099. 4090        PRINT TABXY(25,10);Npak
  4100. 4091        PRINT TABXY(25,11);Oldtry+Spacks
  4101. 4092        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4102. 4093        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4103. 4094        IF Debug THEN PRINT TABXY(20,15);Sndpkt$&RPT$(" ",60-(LEN(Sndpkt$)))
  4104. 4095        IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4105. 4096    !-----------------------------------     Receive File Header (F)
  4106. 4097 Krecf:CASE "F"      ! Enter Npak=1
  4107. 4098        Packet$=""
  4108. 4099        IF Debug THEN PRINT TABXY(25,4);State$
  4109. 4100        Pkt$="N"
  4110. 4101        PRINT TABXY(25,13);"Receiving Filename"&RPT$(" ",26)
  4111. 4102        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Fpacks,User_break,Emsg$)
  4112. 4103        IF Debug THEN PRINT TABXY(20,16);Rcvpkt$&RPT$(" ",80-LEN(Rcvpkt$))
  4113. 4104        IF D_log THEN OUTPUT @D_log;"rpack: ";Rcvpkt$
  4114. 4105        SELECT Pktype$
  4115. 4106        CASE "S"
  4116. 4107          OUTPUT @Out_buff;Sndpkt$   !  S Packet Sndpkt$ still in tact
  4117. 4108          IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4118. 4109        CASE "E"
  4119. 4110          Emsg$=Rdata$
  4120. 4111          State$="E"
  4121. 4112        CASE "T"
  4122. 4113          Wmsg$="Packet Timeout"
  4123. 4114        CASE "Q"
  4124. 4115          Wmsg$="Bad Checksum"
  4125. 4116        CASE "A","D"
  4126. 4117        ! Just Nak               ! probably should abort here
  4127. 4118        CASE "Z","B"
  4128. 4119          State$=Pktype$
  4129. 4120        CASE "X"
  4130. 4121          Pkt$="Y"
  4131. 4122          Packet$=Rdata$
  4132. 4123          State$="Z"
  4133. 4124        CASE "F"
  4134. 4125          Pkt$="Y"
  4135. 4126          Oldtry=Oldtry+Spacks
  4136. 4127          IF Rcap_a THEN            ! Attribute Packets in use
  4137. 4128            State$="A"
  4138. 4129          ELSE
  4139. 4130            State$="D"
  4140. 4131          END IF
  4141. 4132          GOSUB Verify_fname        ! Create F_path$, F_msi$, Filename$
  4142. 4133        END SELECT
  4143. 4134        Spack(Packet$,Pkt$,Npak,Sndpkt$)
  4144. 4135        OUTPUT @Out_buff;Sndpkt$
  4145. 4136      !
  4146. 4137        IF Debug THEN PRINT TABXY(20,15);Sndpkt$&RPT$(" ",60-LEN(Sndpkt$))
  4147. 4138        IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4148. 4139        IF Fpacks>Maxtry THEN 
  4149. 4140          State$="E"
  4150. 4141          User_break=1
  4151. 4142          Packet$="Unable to receive filename"
  4152. 4143        END IF
  4153. 4144        PRINT TABXY(25,10);Npak
  4154. 4145        PRINT TABXY(25,11);Oldtry+Fpacks
  4155. 4146        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4156. 4147        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4157. 4148      !
  4158. 4149        IF Pkt$="Y" THEN 
  4159. 4150          Npak=Npak+1
  4160. 4151        ELSE
  4161. 4152          Fpacks=Fpacks+1
  4162. 4153        END IF
  4163. 4154    !--------------------------------------  File Attributes
  4164. 4155      CASE "A"   ! F-path$ corrupted before here
  4165. 4156 Kreca:  !
  4166. 4157        Packet$=""
  4167. 4158        IF Debug THEN PRINT TABXY(25,4);State$
  4168. 4159        Pkt$="N"
  4169. 4160        PRINT TABXY(25,13);"Receiving File Attributes"&RPT$(" ",19)
  4170. 4161        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Apacks,User_break,Emsg$)
  4171. 4162        IF Debug THEN PRINT TABXY(20,16);Rcvpkt$&RPT$(" ",60-LEN(Rcvpkt$))
  4172. 4163        IF D_log THEN OUTPUT @D_log;"rpack: ";Rcvpkt$
  4173. 4164        SELECT Pktype$
  4174. 4165        CASE "A"
  4175. 4166          GOSUB Get_at
  4176. 4167          Pkt$="Y"
  4177. 4168          IF File_length THEN 
  4178. 4169            PRINT TABXY(10,7);"% Transferred:"
  4179. 4170          END IF
  4180. 4171          State$="D"
  4181. 4172        CASE "Z","B"
  4182. 4173          State$=Pktype$
  4183. 4174        CASE "E"
  4184. 4175          Emsg$=Rdata$
  4185. 4176          State$="E"
  4186. 4177        CASE "T"
  4187. 4178          Wmsg$="Packet Timeout"
  4188. 4179        CASE "Q"
  4189. 4180          Wmsg$="Bad Checksum"
  4190. 4181        CASE "X"
  4191. 4182          Pkt$="Y"
  4192. 4183          Packet$=Rdata$
  4193. 4184          State$="Z"
  4194. 4185        END SELECT
  4195. 4186      !
  4196. 4187        Spack(Packet$,Pkt$,Npak,Sndpkt$)
  4197. 4188        OUTPUT @Out_buff;Sndpkt$
  4198. 4189        IF Debug THEN PRINT TABXY(20,15);Sndpkt$&RPT$(" ",60-LEN(Sndpkt$))
  4199. 4190        IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4200. 4191        PRINT TABXY(25,10);Npak
  4201. 4192        PRINT TABXY(25,11);Oldtry+Apacks
  4202. 4193        IF Apacks>Maxtry THEN 
  4203. 4194          State$="E"
  4204. 4195          User_break=1
  4205. 4196          Packet$="Unable to receive attribute packet"
  4206. 4197        END IF
  4207. 4198        IF Pkt$="Y" THEN 
  4208. 4199          Npak=Npak+1
  4209. 4200          Oldtry=Oldtry+Spacks
  4210. 4201        ELSE
  4211. 4202          Apacks=Apacks+1
  4212. 4203        END IF
  4213. 4204        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4214. 4205        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4215. 4206    !--------------------------------------  Receive File Data  "D"
  4216. 4207      CASE "D"
  4217. 4208 Krecd: !
  4218. 4209        Packet$=""
  4219. 4210        Rdata$=""
  4220. 4211        Pkt$="N"
  4221. 4212     !
  4222. 4213        IF NOT Dinit THEN 
  4223. 4214          PRINT TABXY(25,13);"Receiving File Data"&RPT$(" ",25)
  4224. 4215          Dinit=1
  4225. 4216        END IF
  4226. 4217        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Dpacks,User_break,Emsg$)
  4227. 4218        IF Debug THEN PRINT TABXY(20,16);Rcvpkt$&RPT$(" ",20)
  4228. 4219        IF D_log THEN OUTPUT @D_log;"rpack: ";Rcvpkt$
  4229. 4220        SELECT Pktype$
  4230. 4221        CASE "F","S","A"
  4231. 4222          Emsg$="Packets out of sequence"
  4232. 4223          State$="E"
  4233. 4224          User_break=1
  4234. 4225        CASE "Z","B"         ! Process State Z here
  4235. 4226          PRINT TABXY(25,13);"Receiving End of File"&RPT$(" ",25)
  4236. 4227       !
  4237. 4228       ! Write Remaining File Lines
  4238. 4229       !
  4239. 4230          IF File_open THEN 
  4240. 4231            SELECT Filetype$
  4241. 4232            CASE "ASCII"
  4242. 4233              OUTPUT @File;File_buff$
  4243. 4234            CASE "HPUX","BDAT"
  4244. 4235              OUTPUT @File USING "#,K";File_buff$
  4245. 4236            CASE ELSE
  4246. 4237              OUTPUT @File;File_buff$;
  4247. 4238            END SELECT
  4248. 4239            OUTPUT @File;END
  4249. 4240            ASSIGN @File TO *
  4250. 4241            File_open=0
  4251. 4242          END IF! file open
  4252. 4243          Pkt$="Y"
  4253. 4244          State$="B"              ! Skip over Z state (done here )
  4254. 4245          Oldtry=Oldtry+Spacks
  4255. 4246        CASE "E"
  4256. 4247          Emsg$=Rdata$
  4257. 4248          State$="E"
  4258. 4249        CASE "T"
  4259. 4250          Wmsg$="Packet Timeout"
  4260. 4251        CASE "Q"
  4261. 4252          Wmsg$="Bad Checksum or Sequence"
  4262. 4253        CASE "X"
  4263. 4254          Pkt$="Y"
  4264. 4255          Packet$=Rdata$
  4265. 4256          State$="Z"
  4266. 4257          User_break=1
  4267. 4258     !---------------------------------------  File Data Received
  4268. 4259        CASE "D"
  4269. 4260          Pkt$="Y"
  4270. 4261        CASE ELSE
  4271. 4262        END SELECT
  4272. 4263    !
  4273. 4264        Spack(Packet$,Pkt$,Npak,Sndpkt$)
  4274. 4265        OUTPUT @Out_buff;Sndpkt$
  4275. 4266        IF Debug THEN PRINT TABXY(20,15);Sndpkt$&RPT$(" ",60-LEN(Sndpkt$))
  4276. 4267        IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4277. 4268        PRINT TABXY(25,10);Npak
  4278. 4269        PRINT TABXY(25,11);Oldtry+Dpacks
  4279. 4270        IF Dpacks>Maxtry THEN 
  4280. 4271          State$="E"
  4281. 4272          User_break=1
  4282. 4273          Packet$="Unable to receive file data packet"
  4283. 4274        END IF
  4284. 4275      !
  4285. 4276        IF Pkt$="Y" THEN 
  4286. 4277          Npak=Npak+1
  4287. 4278        ELSE
  4288. 4279          Dpacks=Dpacks+1
  4289. 4280        END IF
  4290. 4281        IF Display THEN 
  4291. 4282          PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4292. 4283          PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4293. 4284        END IF
  4294. 4285        IF (User_break) OR (State$<>"D") THEN GOTO Krecd_exit
  4295. 4286     !
  4296. 4287        IF Pkt$="Y" THEN            !- PACKET IS "Y" - RECEIVE DATA
  4297. 4288          IF User_break THEN GOTO Krecd_exit   ! Avoid Data Packet
  4298. 4289          DISABLE 
  4299. 4290 Of: ! ---- Create and Open File
  4300. 4291          IF NOT File_open THEN 
  4301. 4292          !
  4302. 4293            IF NOT (LEN(Ftype$)) THEN Ftype$="HPUX"
  4303. 4294       !
  4304. 4295       ! Process Filelength
  4305. 4296       !
  4306. 4297            IF File_length=0 THEN   ! Attribute Packet Not Used
  4307. 4298              SELECT Ftype$
  4308. 4299              CASE "HPUX","PROG"
  4309. 4300                IF Hfs_disc THEN 
  4310. 4301                  File_length=1
  4311. 4302                ELSE
  4312. 4303                  IF Ramfile THEN File_length=Kbytes
  4313. 4304                  IF NOT Ramfile THEN File_length=50000  ! bytes
  4314. 4305                END IF
  4315. 4306              CASE ELSE
  4316. 4307                IF Hfs_disc THEN 
  4317. 4308                  File_length=1
  4318. 4309                ELSE
  4319. 4310                  IF Ramfile THEN File_length=Kbytes
  4320. 4311                  IF NOT Ramfile THEN File_length=50000
  4321. 4312                END IF
  4322. 4313              END SELECT
  4323. 4314            ELSE           ! file length spec in attribute packet
  4324. 4315              IF Ramdisc THEN 
  4325. 4316                IF File_length>(Kbytes*1000) THEN  ! ramdisc too small
  4326. 4317                  Wmsg$="File larger than Mass Storage"
  4327. 4318                  Emsg$="Mass Storage Overflow"
  4328. 4319                  State$="E"
  4329. 4320                  User_break=1
  4330. 4321                  GOTO Krecd_exit
  4331. 4322                END IF
  4332. 4323              END IF
  4333. 4324            END IF        ! File Length = 0
  4334. 4325        !
  4335. 4326        ! Code to check for residual file not working add an extra sector
  4336. 4327        !
  4337. 4328        !   Res=File_length MOD 256
  4338. 4329        !   IF NOT Res THEN
  4339. 4330        !   Sectors=MAX(1,INT(File_length/256))
  4340. 4331        !   ELSE
  4341. 4332            Sectors=MAX(1,INT(File_length/256)+1)
  4342. 4333        !   END IF
  4343. 4334        !
  4344. 4335            SELECT Ftype$
  4345. 4336            CASE "HP-UX","HPUX"
  4346. 4337              CREATE F_path$&Filename$&F_msi$,File_length+1
  4347. 4338            CASE "BDAT"
  4348. 4339              IF Recl>0 THEN 
  4349. 4340                CREATE BDAT F_path$&Filename$&F_msi$,Sectors,Recl
  4350. 4341              ELSE
  4351. 4342                CREATE BDAT F_path$&Filename$&F_msi$,Sectors
  4352. 4343              END IF
  4353. 4344            CASE "ASCII"
  4354. 4345              CREATE ASCII F_path$&Filename$&F_msi$,Sectors
  4355. 4346            CASE ELSE    ! "SYSTM","BIN","PROG"
  4356. 4347              CREATE F_path$&Filename$&F_msi$,File_length   ! Use HP-UX then convert later
  4357. 4348            END SELECT
  4358. 4349          !
  4359. 4350            IF State$="E" THEN               ! Mass Storage Overflow ?
  4360. 4351              User_break=1
  4361. 4352              GOTO Krecd_exit
  4362. 4353            END IF
  4363. 4354            ASSIGN @File TO F_path$&Filename$&F_msi$;FORMAT OFF
  4364. 4355            File_open=1
  4365. 4356          ! ---------------------------------  Init Process Rdata$
  4366. 4357            P=1         ! packet contents pointer
  4367. 4358            Qon=0       ! quoting on flag
  4368. 4359            Biton=0     ! 8 bit prefixing flag
  4369. 4360            Rept=0      ! repeat prefix flag
  4370. 4361          END IF  ! file not open
  4371. 4362        END IF    !   D Packet and File Not open
  4372. 4363     !---------------------------------------------  Pack File_buff$(*)
  4373. 4364 Decode: !
  4374. 4365        IF Pktype$="D" THEN 
  4375. 4366                                    ! strip parity bits here  ????????????
  4376. 4367          CALL Decode_pack(Rdata$,Quote,Qbin,Rep_ch)
  4377. 4368          File_buff$=File_buff$&Rdata$
  4378. 4369          Pl=LEN(Rdata$)            ! Pl = Packet Length
  4379. 4370          P=P+Pl                    ! P  = Buffer Pointer (File_buff$)
  4380. 4371        END IF   ! D Packet
  4381. 4372      !
  4382. 4373        Kbx=Kbx+Pl                  ! Kbx = Bytes Transferred
  4383. 4374        PRINT TABXY(25,6);Kbx           !INT(Kbx/1000)
  4384. 4375        IF At_filelength THEN 
  4385. 4376          PRINT TABXY(25,7);MIN(100,INT((Kbx*100)/File_length));"%"
  4386. 4377        END IF
  4387. 4378      !
  4388. 4379      ! Check Buffer Length and write File
  4389. 4380      !
  4390. 4381        IF P>Buff_len-100 THEN               !write file
  4391. 4382          IF Debug THEN DISP "Writing File ";F_path$&Filename$&F_msi$
  4392. 4383          SELECT Ftype$
  4393. 4384          CASE "ASCII"
  4394. 4385        !
  4395. 4386        ! The File_buff$ is parsed for CR-LF (Ascii_eol$)
  4396. 4387        ! The Eol$ is removed, and each line is written to the Ascii
  4397. 4388        ! File creating Length-header delimited data.
  4398. 4389        !
  4399. 4390            Ascii_eol$="
  4400. "
  4401. 4391            Eol_l=LEN(Ascii_eol$)
  4402. 4392            REPEAT
  4403. 4393              Eolpos=POS(File_buff$,Ascii_eol$)
  4404. 4394              IF Eolpos THEN 
  4405. 4395                Sector$=File_buff$[1,Eolpos]
  4406. 4396              ELSE    ! the last fragment has no eol in the packet
  4407. 4397                Sector$=File_buff$
  4408. 4398              END IF
  4409. 4399              OUTPUT @File;Sector$;
  4410. 4400              File_buff$=File_buff$[Eolpos+Eol_l]  ! truncate and remove eol
  4411. 4401            UNTIL Eolpos=0
  4412. 4402          CASE ELSE
  4413. 4403            OUTPUT @File USING "#,K";File_buff$      ! supress <null> eol
  4414. 4404          END SELECT
  4415. 4405          File_buff$=""
  4416. 4406          P=0
  4417. 4407        END IF
  4418. 4408 Krecd_exit: !ENABLE
  4419. 4409    !----------------------------------------------------------------------
  4420. 4410 Krecz:CASE "Z"
  4421. 4411     !
  4422. 4412     !  State Z is normally processed in D State Handling -
  4423. 4413     !  Rdata$ in tact
  4424. 4414     !---------------------------------------------------------------------
  4425. 4415     !  This state is entered in 2 situations -
  4426. 4416     !
  4427. 4417     ! 1. Sender sends a Z packet prematurely
  4428. 4418     ! 2. User (receiver) abort
  4429. 4419     !  This state may be entered forom a user-abort sequence ^X  ^Z
  4430. 4420     !  If so, then the user_break flag will be set, and Rdata$ will be
  4431. 4421     !  X if ^X was invoked, or Z if ^Z was invoked.
  4432. 4422     !--------------------------------------------------------------------
  4433. 4423     ! Variables set after user break conditions
  4434. 4424  !
  4435. 4425  !          Pktype$     Rdata$    State$
  4436. 4426  !   ^X       X           X        --
  4437. 4427  !   ^Z       X           Z        --
  4438. 4428  !   ^E       E          --        E
  4439. 4429  !   ^C       X          ^C        X   (unless changed in other states)
  4440. 4430  !
  4441. 4431  !
  4442. 4432        IF User_break THEN 
  4443. 4433          IF NOT POS(Rdata$,"^C") THEN             ! Ok to notify host
  4444. 4434          !
  4445. 4435          ! ^X and ^Z:  send ack with X or Z in data field
  4446. 4436          !
  4447. 4437            Packet$=Rdata$
  4448. 4438            Spack(Packet$,State$,Npak,Sndpkt$)
  4449. 4439            OUTPUT @Out_buff;Sndpkt$
  4450. 4440            IF Debug THEN PRINT TABXY(25,16);Sndpkt$&"                "
  4451. 4441            Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Zpacks,User_break,Emsg$)
  4452. 4442          ELSE   ! ^C processing just abort
  4453. 4443           ! fall thru to check pktype
  4454. 4444          END IF
  4455. 4445        ELSE
  4456. 4446          Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Bpacks,User_break,Emsg$)
  4457. 4447        END IF
  4458. 4448        IF Debug THEN PRINT TABXY(20,16);Rcvpkt$&RPT$(" ",60-LEN(Rcvpkt$))
  4459. 4449        IF D_log THEN OUTPUT @D_log;"rpack: ";Rcvpkt$
  4460. 4450        Pkt$="N"
  4461. 4451 Check_z:!
  4462. 4452        SELECT Pktype$
  4463. 4453        CASE "Z"
  4464. 4454       ! ** Should inspect Rdata$ for a "D)iscard" instruction"
  4465. 4455       ! if Rdata$="D" then discard file.
  4466. 4456       !
  4467. 4457       ! Write Remaining File Lines **
  4468. 4458       !
  4469. 4459          IF Rdata$="D" THEN 
  4470. 4460       ! discard file here
  4471. 4461            DISP "Received Abort from Sender and signal to discard file - purge file ? "
  4472. 4462            OUTPUT KBD;"Y";" H";
  4473. 4463            ENTER KBD;Ans$
  4474. 4464            DISP 
  4475. 4465            IF UPC$(Ans$)="Y" THEN 
  4476. 4466              DISP "Purging File: ";Filename$
  4477. 4467              PURGE Filename$
  4478. 4468            END IF
  4479. 4469          ELSE     ! close file normally
  4480. 4470            IF File_open THEN 
  4481. 4471              Bl=LEN(File_buff$)
  4482. 4472              SELECT Filetype$
  4483. 4473              CASE "HPUX","BDAT"
  4484. 4474                OUTPUT @File;File_buff$;END
  4485. 4475                PRINT File_buff$
  4486. 4476              CASE "ASCII"
  4487. 4477                OUTPUT @File;File_buff$;END
  4488. 4478              END SELECT
  4489. 4479              ASSIGN @File TO *
  4490. 4480              File_open=0
  4491. 4481              DISP 
  4492. 4482            ELSE
  4493. 4483              Wmsg$="(Z) File not Open "
  4494. 4484            END IF! file open
  4495. 4485          END IF
  4496. 4486          Pkt$="Y"
  4497. 4487          State$="B"
  4498. 4488          Oldtry=Oldtry+Zpacks
  4499. 4489        CASE "B"
  4500. 4490          State$="C"              ! File Transfer Complete
  4501. 4491          Pkt$="Y"
  4502. 4492        CASE "E"
  4503. 4493          Emsg$=Rdata$
  4504. 4494          State$="E"
  4505. 4495        CASE "T"
  4506. 4496          Wmsg$="Packet Timeout"
  4507. 4497        CASE "Q"
  4508. 4498          Wmsg$="Bad Checksum"
  4509. 4499        CASE "X"
  4510. 4500          State$="X"    ! abort
  4511. 4501        END SELECT
  4512. 4502    !
  4513. 4503        Spack(Packet$,Pkt$,Npak,Sndpkt$)   !?????????????????????
  4514. 4504        OUTPUT @Out_buff;Sndpkt$
  4515. 4505        IF Debug THEN PRINT TABXY(20,15);Sndpkt$&RPT$(" ",60-LEN(Sndpkt$))
  4516. 4506        IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4517. 4507      !
  4518. 4508        IF Zpacks>Maxtry THEN 
  4519. 4509          State$="E"
  4520. 4510          User_break=1
  4521. 4511          Packet$="Unable to receive EOF (Z)  packet"
  4522. 4512          Emsg$="Unable to receive EOF (Z)  packet"
  4523. 4513        END IF
  4524. 4514      !
  4525. 4515        IF Pkt$="Y" THEN 
  4526. 4516          Npak=Npak+1
  4527. 4517        ELSE
  4528. 4518          Zpacks=Zpacks+1
  4529. 4519        END IF
  4530. 4520      !
  4531. 4521 Krecz_exit:!
  4532. 4522        PRINT TABXY(25,10);Npak
  4533. 4523        PRINT TABXY(25,11);Oldtry+Bpacks
  4534. 4524        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4535. 4525        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4536. 4526  !---------------------------------------------------------------------
  4537. 4527 Krecb:CASE "B"
  4538. 4528     !
  4539. 4529        Packet$=""
  4540. 4530        IF Debug THEN PRINT TABXY(25,4);State$
  4541. 4531        Pkt$="N"
  4542. 4532        PRINT TABXY(25,13);RPT$(" ",55)
  4543. 4533        Rpack(Pktype$,Rdata$,Rseq,Rcvpkt$,Sndpkt$,Npak,Bpacks,User_break,Emsg$)
  4544. 4534        IF Debug THEN PRINT TABXY(20,16);Rcvpkt$&RPT$(" ",60-LEN(Rcvpkt$))
  4545. 4535        IF D_log THEN OUTPUT @D_log;"rpack: ";Rcvpkt$
  4546. 4536        SELECT Pktype$
  4547. 4537        CASE "Z"
  4548. 4538          Pkt$="Y"
  4549. 4539          State$="B"              ! Skip over Z state (done here )
  4550. 4540          Oldtry=Oldtry+Zpacks
  4551. 4541        CASE "B"
  4552. 4542          State$="C"              ! File Transfer Complete
  4553. 4543          Pkt$="Y"
  4554. 4544        CASE "E"
  4555. 4545          Emsg$=Rdata$
  4556. 4546          State$="E"
  4557. 4547        CASE "T"
  4558. 4548          Wmsg$="Packet Timeout"
  4559. 4549        CASE "Q"
  4560. 4550          Wmsg$="Bad Checksum"
  4561. 4551        CASE "X"
  4562. 4552        END SELECT
  4563. 4553    !
  4564. 4554        Spack(Packet$,Pkt$,Npak,Sndpkt$)
  4565. 4555        OUTPUT @Out_buff;Sndpkt$
  4566. 4556        IF Debug THEN PRINT TABXY(20,15);Sndpkt$&RPT$(" ",60-LEN(Sndpkt$))
  4567. 4557        IF D_log THEN OUTPUT @D_log;"Spack: ";Sndpkt$
  4568. 4558        PRINT TABXY(25,10);Npak
  4569. 4559        PRINT TABXY(25,11);Oldtry+Bpacks
  4570. 4560      !
  4571. 4561        IF Bpacks>Maxtry THEN 
  4572. 4562          State$="E"
  4573. 4563          User_break=1
  4574. 4564          Packet$="Unable to receive break packet"
  4575. 4565          Emsg$="Unable to receive break packet"
  4576. 4566        END IF
  4577. 4567      !
  4578. 4568        IF Pkt$="Y" THEN 
  4579. 4569          IF User_break THEN 
  4580. 4570            State$="X"
  4581. 4571          ELSE
  4582. 4572            State$="C"
  4583. 4573          END IF
  4584. 4574          Npak=Npak+1
  4585. 4575        ELSE ! pkt$="N"
  4586. 4576          Bpacks=Bpacks+1
  4587. 4577        END IF
  4588. 4578      !
  4589. 4579        PRINT TABXY(25,10);Npak
  4590. 4580        PRINT TABXY(25,11);Oldtry+Bpacks
  4591. 4581        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4592. 4582        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4593. 4583  !
  4594. 4584        IF Ftype$="PROG" THEN 
  4595. 4585          CALL Convert(F_path$&Filename$&F_msi$,"PROG",Rc)
  4596. 4586          PRINT TABXY(1,18);"PROG File exists on Ram Disc - Copy file to disc before leaving Kermit"
  4597. 4587        END IF
  4598. 4588  !------------------------------------------------------------------------
  4599. 4589 Krece:CASE "E"    !
  4600. 4590   !
  4601. 4591   !  Enter E state on:
  4602. 4592   !
  4603. 4593   ! 1. Received E  Packet from Host    (User_break=0)
  4604. 4594   !    Erm$ (and Rdata$) contains the host error message
  4605. 4595   ! 2. User Abort - User_break=1
  4606. 4596   ! Packet$ (rdata$  ? )contains the error message being sent
  4607. 4597   !
  4608. 4598   ! Emsg$ must contain data mesage for packet
  4609. 4599   !
  4610. 4600        BEEP 
  4611. 4601        IF User_break THEN      ! User abort
  4612. 4602          Pkt$="E"   ! Nak unless expected packet arives
  4613. 4603          Packet$=Emsg$
  4614. 4604          Spack(Packet$,Pkt$,Npak,Sndpkt$)
  4615. 4605          OUTPUT @Out_buff;Sndpkt$
  4616. 4606          IF D_log THEN OUTPUT @D_log;"SPACK: ";Sndpkt$
  4617. 4607          State$="X"              ! indicate User Abort
  4618. 4608        ELSE   ! Host Error - E packet  Received
  4619. 4609          State$="X"
  4620. 4610        END IF
  4621. 4611        PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4622. 4612        PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4623. 4613        PRINT TABXY(1,Crt_lines);
  4624. 4614       !----------------------------------------------------------------
  4625. 4615      END SELECT    ! Receive State Switch
  4626. 4616    UNTIL (State$="X") OR (State$="C")     ! Don't put "E" here !
  4627. 4617   !========================================================================
  4628. 4618    IF D_log THEN ASSIGN @D_log TO *
  4629. 4619    ASSIGN @File TO *
  4630. 4620   !
  4631. 4621    IF Com_card=98628 THEN 
  4632. 4622     ! Do Nothing
  4633. 4623    ELSE  ! 98626
  4634. 4624      REPEAT
  4635. 4625        STATUS @Out_buff,4;Bl     ! Finish sending last packet
  4636. 4626      UNTIL Bl=0
  4637. 4627    !
  4638. 4628      STATUS @In_buff,4;Bl
  4639. 4629      WHILE Bl
  4640. 4630        OUTPUT @Out_buff;"
  4641. "
  4642. 4631        IF Bl THEN ENTER @In_buff;Misc$
  4643. 4632        IF Debug THEN PRINT Misc$
  4644. 4633        STATUS @In_buff,4;Bl     ! Finish sending last packet
  4645. 4634      END WHILE
  4646. 4635   !  CALL Shutdown      ! << this could be screwing things
  4647. 4636    END IF
  4648. 4637   !
  4649. 4638 Krec_exit:  !
  4650. 4639   !
  4651. 4640    PRINTER IS CRT
  4652. 4641    PRINT TABXY(1,16);
  4653. 4642    SELECT State$
  4654. 4643    CASE "C"
  4655. 4644      PRINT TABXY(16,8);"RECEIVE: Completed  "              ! 8
  4656. 4645    CASE "X"
  4657. 4646      IF NOT User_break THEN 
  4658. 4647        PRINT TABXY(16,8);"RECEIVE: Aborted by host "       ! 8
  4659. 4648      ELSE
  4660. 4649        PRINT TABXY(16,8);"RECEIVE: Aborted by user "       ! 8
  4661. 4650     !  PRINT Emsg$
  4662. 4651      END IF
  4663. 4652   ! process incomplete file here - save or discard
  4664. 4653      IF Discard THEN 
  4665. 4654        DISP "Discard File: ";F_path$&Filename$&F_msi$;"  ?"
  4666. 4655        OUTPUT KBD;"Yes";
  4667. 4656        ENTER KBD;Ans$
  4668. 4657        DISP 
  4669. 4658        ON ERROR GOTO No_discard
  4670. 4659        IF POS(UPC$(Ans$),"Y") THEN PURGE F_path$&Filename$&F_msi$
  4671. 4660 No_discard:DISP ERRM$
  4672. 4661        OFF ERROR 
  4673. 4662      END IF
  4674. 4663    END SELECT
  4675. 4664    PRINT TABXY(1,Crt_lines);
  4676. 4665    MASS STORAGE IS Sav_msi$
  4677. 4666    SUBEXIT
  4678. 4667 !-----------------------------------------------------------------------
  4679. 4668 Verify_fname: !   called from State "F"
  4680. 4669 Vf: !
  4681. 4670      ! 1. If filename was not specified locally, then use the incomming
  4682. 4671      !    filename. Make sure name is legal and < 10 chars
  4683. 4672      ! 2. Check for :MSI. If none specified, then append the
  4684. 4673      !    local default_msi$. If Ramdisc make sure it exists.
  4685. 4674      ! 3. Parse filename and create F_path$, F_msi$, Filename$
  4686. 4675      ! 4. If PROG Filetype then make F_msi$=ram disc
  4687. 4676      !
  4688. 4677    IF NOT LEN(Filename$) OR Filename$="," THEN    !use incomming file name.
  4689. 4678      IF Debug THEN DISP "Using the incomming filename"
  4690. 4679      Filename$=TRIM$(Rdata$)
  4691. 4680      Sav_filename$=Filename$
  4692. 4681      CALL Parse_filename(Filename$,F_msi$,F_path$)
  4693. 4682      IF NOT LEN(Filename$) THEN Filename$="K_DEFAULT"
  4694. 4683      IF Filnamcnv THEN Filename$=UPC$(Filename$)
  4695. 4684    END IF
  4696. 4685      !
  4697. 4686      ! Check Filename Length =  10 characters or less
  4698. 4687      !
  4699. 4688    WHILE LEN(Filename$)>10
  4700. 4689      DISP "filename too long - shorten "
  4701. 4690      OUTPUT KBD;Filename$;" H";
  4702. 4691      ENTER KBD;Filename$
  4703. 4692      DISP 
  4704. 4693    END WHILE
  4705. 4694     !
  4706. 4695     !   Check if ramdisc msi and if ramdisc is available. If not
  4707. 4696     !   Change :MSI to a physical disc.
  4708. 4697     !
  4709. 4698    IF Filetype$="PROG" THEN F_msi$=":,0,0"
  4710. 4699    IF (POS(F_msi$,":,0") OR POS(F_msi$,":MEMORY")) AND (Ramdisc=1) THEN 
  4711. 4700      Ramfile=1
  4712. 4701      IF Debug THEN PRINT "using ramdisc"
  4713. 4702    ELSE
  4714. 4703      IF POS(F_msi$,":,0") AND (Ramdisc=0) THEN 
  4715. 4704        BEEP 
  4716. 4705        DISP "Change MSI - Ramdisc not available"
  4717. 4706        OUTPUT KBD;F_path$&Filename$&F_msi$;
  4718. 4707        ENTER KBD;Filename$
  4719. 4708        CALL Parse_filename(Filename$,F_msi$,F_path$)
  4720. 4709      END IF
  4721. 4710    END IF
  4722. 4711    PRINT TABXY(25,5);" As  ";F_path$&Filename$&F_msi$
  4723. 4712    RETURN 
  4724. 4713  !------------------------------------------------------------------------
  4725. 4714 Create_unique: !    ! Filewarn=1 Don't Purge File - create a unique name
  4726. 4715    F$=Filename$
  4727. 4716    Unq_made=0
  4728. 4717  !
  4729. 4718  ! Get a catalog of a duplicate filenames upto "_" character
  4730. 4719  !
  4731. 4720  !
  4732. 4721    IF LEN(F$)<9 THEN 
  4733. 4722      Find$=F$&"_"
  4734. 4723    ELSE
  4735. 4724      Find$=F$[1,8]&"_"
  4736. 4725    END IF
  4737. 4726    ALLOCATE Cat$(30)[80]
  4738. 4727    CAT F_msi$ TO Cat$(*);SELECT Find$,COUNT Dupnames,NO HEADER
  4739. 4728  !---------------------------------------------
  4740. 4729  ! Find the next unique suffix
  4741. 4730  ! Find$ = The base filename without sufix
  4742. 4731  !
  4743. 4732    IF Dupnames THEN       ! INCR NEXT_UNIQUE UNTIL UNIQUE
  4744. 4733      Next_unique=47       ! STARTING PLACE IN ASCII TABLE "0"
  4745. 4734      REPEAT
  4746. 4735        Next_unique=Next_unique+1
  4747. 4736        IF (Next_unique>57) AND (Next_unique<65) THEN Next_unique=65
  4748. 4737        IF (Next_unique>90) AND (Next_unique<97) THEN Next_unique=97
  4749. 4738        IF Next_unique>126 THEN 
  4750. 4739          DISP "Can't Create a unique name - all ascii chars used"
  4751. 4740          PAUSE
  4752. 4741        END IF
  4753. 4742      !
  4754. 4743        Nu_found=1
  4755. 4744        FOR Df=1 TO Dupnames
  4756. 4745          IF POS(Cat$(Df),Find$&CHR$(Next_unique)) THEN     ! UNIQUE
  4757. 4746            Nu_found=0
  4758. 4747          END IF
  4759. 4748        NEXT Df
  4760. 4749      UNTIL Nu_found
  4761. 4750    ELSE
  4762. 4751      Next_unique=48    ! IF NO DUPES THEN - DEFAULT TO 48   "_0"
  4763. 4752    END IF
  4764. 4753    DEALLOCATE Cat$(*)
  4765. 4754  !---------------------------------------------
  4766. 4755    REPEAT                    ! until a unique name is made
  4767. 4756    !
  4768. 4757    ! Make sure filename is unique
  4769. 4758    !
  4770. 4759      Ftest$=Find$&CHR$(Next_unique)
  4771. 4760      ASSIGN @Test TO F_path$&Ftest$&F_msi$;RETURN Rc
  4772. 4761      IF Rc THEN     ! assume filename is unique
  4773. 4762        Unq_made=1
  4774. 4763        Next_unique=(Next_unique+1) MOD 10
  4775. 4764        F$=Ftest$
  4776. 4765      ELSE
  4777. 4766        Next_unique=Next_unique+1
  4778. 4767      END IF
  4779. 4768    UNTIL Unq_made
  4780. 4769  !
  4781. 4770    Filename$=F$
  4782. 4771    Wmsg$="Changed filename to "&Filename$
  4783. 4772    PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4784. 4773    PRINT TABXY(25,5);" As  ";F_path$&Filename$&F_msi$
  4785. 4774    RETURN 
  4786. 4775 !----------------------------------------------
  4787. 4776 Get_at:  !   Decode File Attribute Packet
  4788. 4777     !
  4789. 4778     ! Rdata$ is in form:  ATTRIBUTE(char), LENGTH(unchar), DATA(char)
  4790. 4779     ! Returns:
  4791. 4780     !
  4792. 4781     ! ! or 1    File length (Bytes)     File_length
  4793. 4782     ! "
  4794. 4783     ! #         Creation Date           File_date$
  4795. 4784     ! .         Machine and OS          File_os$
  4796. 4785     ! /         Format Of Data          File_format$,File_type,File_delim$
  4797. 4786     !
  4798. 4787    I=1   ! data pointer
  4799. 4788    REPEAT
  4800. 4789      Attrib$=Rdata$[I,I]
  4801. 4790      Dl=FNUnchar(Rdata$[I+1,I+1])
  4802. 4791      SELECT Attrib$
  4803. 4792      CASE "!"  ! Length (Kb)
  4804. 4793        IF NOT At_filelength THEN 
  4805. 4794          File_length=VAL(Rdata$[I+2;Dl])
  4806. 4795          IF Attrib$="!" THEN File_length=(File_length+1)*1000
  4807. 4796          At_filelength=1
  4808. 4797        END IF
  4809. 4798      CASE "1" ! Exact File Length
  4810. 4799        File_length=VAL(Rdata$[I+2;Dl])
  4811. 4800        IF Attrib$="!" THEN File_length=(File_length+1)*1000
  4812. 4801        At_filelength=1
  4813. 4802      CASE """"       ! Data Type
  4814. 4803      CASE "#"        ! Creation Date [yy]yymmdd[  hh:mm[ :ss]
  4815. 4804        File_date$=Rdata$[I+2;Dl]
  4816. 4805      CASE "."        ! Machine and OS !  H4=hp9000 RMB
  4817. 4806        File_os$=Rdata$[I+2;Dl]        !  U8=DOS
  4818. 4807      CASE "/"        ! Format of data
  4819. 4808        File_format$=Rdata$[I+2;Dl]
  4820. 4809        SELECT File_format$[1,1]
  4821. 4810        CASE "A"     ! Var Length Delim Records - HP-UX FORMAT ON
  4822. 4811          File_delim$=File_format$[2;Dl-1]
  4823. 4812          File_type=4
  4824. 4813        CASE "D"     ! Var Len Undelim Records - ASCII File $
  4825. 4814          File_type=3
  4826. 4815        CASE "F"     ! Fix Len Undelim Records - BDAT FORMAT OFF
  4827. 4816          File_type=2
  4828. 4817        CASE "R"     ! Record Oriented Placement of record
  4829. 4818        CASE "M"     ! Maximum Rec Length for above record
  4830. 4819        END SELECT
  4831. 4820      END SELECT
  4832. 4821      I=I+Dl+2
  4833. 4822      IF Debug THEN PRINT "file_attribute ";Attrib$
  4834. 4823    UNTIL I>LEN(Rdata$)
  4835. 4824    RETURN 
  4836. 4825  !-----------------------------------------------------------------------
  4837. 4826 Kbr_int: !(k receive)
  4838. 4827    ! Cancels:  ^X (file)  ^Z (Batch) ^E (Protocol) ^C(Quit) <ent> Retry
  4839. 4828    !
  4840. 4829   ! To Interrupt File Receive:
  4841. 4830   !
  4842. 4831   !  ACK Packet with:   X in data field to abort single file
  4843. 4832   !                     Z in data field to abort entire batch
  4844. 4833   !  E   Packet with    Error Msg if Sender doesn't recognize file interruption.
  4845. 4834   !
  4846. 4835    User_break=1
  4847. 4836    K$=KBD$
  4848. 4837    SELECT K$[1,1]
  4849. 4838    CASE "",""    ! ?
  4850. 4839      PRINT TABXY(1,Crt_lines);
  4851. 4840      PRINT "Cancels:  ^X (file)  ^Z (Batch) ^E (Protocol) ^C(Quit) <Ent> Retry"
  4852. 4841    CASE "" ! ^X   ! Cancel File
  4853. 4842      Pktype$="X"
  4854. 4843      Rdata$="X"    ! discard file
  4855. 4844      Emsg$="Single File Cancelled by Client"
  4856. 4845      RETURN 
  4857. 4846    CASE CHR$(26)  !^Z   ! No Batch Process Yet (wildcard send/rec ?)
  4858. 4847      Pktype$="X"
  4859. 4848      Rdata$="Z"
  4860. 4849      Emsg$="Batch Receive  Cancelled by Client"
  4861. 4850      RETURN 
  4862. 4851    CASE ""  ! ^E   ! Goto Error (Abort)  State
  4863. 4852      State$="E"
  4864. 4853      Pktype$="E"
  4865. 4854      Emsg$="File Aborted by Client (E Packet)"
  4866. 4855      RETURN 
  4867. 4856    CASE "" ! ^C   ! Quit without Notifying Remote Kermit
  4868. 4857      State$="X"
  4869. 4858      Pktype$="X"
  4870. 4859      Rdata$=""
  4871. 4860      Emsg$="Transfer Aborted by Client - Host Not Notified"
  4872. 4861      RETURN 
  4873. 4862    CASE " "          ! CTRL-ENTER  resend - no abort
  4874. 4863      User_break=0
  4875. 4864      SELECT K$[2,2]
  4876. 4865      CASE "E"
  4877. 4866        OUTPUT @Out_buff;Sndpkt$
  4878. 4867        Retry_count=Retry_count+1
  4879. 4868        PRINT TABXY(25,11);Retry_count
  4880. 4869      END SELECT
  4881. 4870    CASE ELSE
  4882. 4871      User_break=0
  4883. 4872    END SELECT
  4884. 4873    ON KBD,2 GOSUB Kbr_int
  4885. 4874    RETURN 
  4886. 4875  !----------------------------------------------------------------------
  4887. 4876 Rec_err:  !             Error Handling for Kermit Receive
  4888. 4877    IF Debug THEN DISP ERRM$
  4889. 4878    SELECT ERRN
  4890. 4879    CASE 53   ! improper filename - probably a . in the name
  4891. 4880      Xd=POS(Filename$,".")
  4892. 4881      IF Xd THEN Filename$[Xd,Xd]="_"
  4893. 4882      IF LEN(Filename$)>10 THEN Filename$=Filename$[1,10]
  4894. 4883    CASE 76,52  ! INVALID DRIVE
  4895. 4884      IF ERRL(Check_ramdisc) THEN 
  4896. 4885        Init_ramdisc(Kbytes)
  4897. 4886        IF NOT Kbytes THEN 
  4898. 4887          DISP "Not enough memory for ramdisc"
  4899. 4888          WAIT 1
  4900. 4889          DISP 
  4901. 4890          ERROR RETURN
  4902. 4891        ELSE
  4903. 4892          Ramdisc=1
  4904. 4893        END IF
  4905. 4894      ELSE
  4906. 4895        DISP ERRM$&"  - Change MSI "
  4907. 4896        OUTPUT KBD;F_msi$;" H";
  4908. 4897        ENTER KBD;F_msi$
  4909. 4898        DISP 
  4910. 4899      END IF
  4911. 4900    CASE 64       ! Mass Storage Medium Overflow
  4912. 4901      Emsg$="Err 64: Mass Storage Medium Overflow"
  4913. 4902      State$="E"
  4914. 4903      ERROR RETURN
  4915. 4904    CASE 54       ! Duplicate File Name
  4916. 4905      IF Filewarn THEN                   ! create a unique filename
  4917. 4906        GOSUB Create_unique
  4918. 4907      ELSE       ! filewarn=0   - overwrite file
  4919. 4908        ASSIGN @File TO *
  4920. 4909        PURGE Filename$
  4921. 4910        Wmsg$="Overwriting file "&Filename$
  4922. 4911      END IF
  4923. 4912      CLEAR ERROR
  4924. 4913    CASE 167,168
  4925. 4914      CALL Com_interrupt         ! Serial Port Erro
  4926. 4915    CASE 59   ! END OF FILE FOUND  @FILE - Filename$
  4927. 4916      ASSIGN @File TO *
  4928. 4917      Spillfile=Spillfile+1
  4929. 4918      Filename$="SPILLFILE"&VAL$(Spillfile)
  4930. 4919      F$=F_path$&Filename$&F_msi$
  4931. 4920      ASSIGN @File TO F$;FORMAT ON,RETURN Rc
  4932. 4921      IF Rc THEN 
  4933. 4922        SELECT Filetype$
  4934. 4923        CASE "ASCII"
  4935. 4924          CREATE ASCII F$,200        ! 51 Kb
  4936. 4925          ASSIGN @File TO F$;FORMAT OFF
  4937. 4926        CASE "HPUX"
  4938. 4927          CREATE F$,50000
  4939. 4928          ASSIGN @File TO F$;FORMAT OFF
  4940. 4929        CASE ELSE
  4941. 4930          CREATE BDAT F$,200
  4942. 4931          ASSIGN @File TO F$;FORMAT OFF
  4943. 4932        END SELECT
  4944. 4933      END IF
  4945. 4934      Wmsg$="File Overflow - Spillfile Created"
  4946. 4935    CASE ELSE
  4947. 4936      DISP ERRM$&"  Paused in  Rec_err"
  4948. 4937      PAUSE
  4949. 4938    END SELECT
  4950. 4939   !
  4951. 4940    DISP 
  4952. 4941    ON ERROR GOSUB Rec_err
  4953. 4942    PRINT TABXY(25,12);Emsg$&RPT$(" ",55-LEN(Emsg$))
  4954. 4943    PRINT TABXY(25,13);Wmsg$&RPT$(" ",55-LEN(Wmsg$))
  4955. 4944    RETURN 
  4956. 4945  !----------------------------------------------
  4957. 4946 Rec_intr: !      ! COMM PORT INTERRUPT HANDLER
  4958. 4947    CALL Com_interrupt
  4959. 4948    Shutdown
  4960. 4949    ON INTR Com_port,15 GOSUB Rec_intr
  4961. 4950    SELECT Com_card
  4962. 4951    CASE 98628
  4963. 4952      CONTROL Com_port,13;164      ! MASK  4=UART  32=lost carr 128=break
  4964. 4953    CASE 98626,98644
  4965. 4954      ENABLE INTR Com_port;4
  4966. 4955    END SELECT
  4967. 4956    ON ERROR GOSUB Rec_err
  4968. 4957    Startup
  4969. 4958    RETURN 
  4970. 4959  !-----------------------------------------------
  4971. 4960 No_printer:RETURN 
  4972. 4961 Flush_buff: !
  4973. 4962    RETURN 
  4974. 4963  !---------------------------------------------
  4975. 4964 Rspar:  !  Form Receive Initialization Packet
  4976. 4965    Packet$=""
  4977. 4966    Packet$[1]=FNTochar$(Maxp)
  4978. 4967    Packet$[2]=FNTochar$(Mytmo)
  4979. 4968    Packet$[3]=FNTochar$(Mypad)
  4980. 4969    Packet$[4]=FNTochar$(Mypchar)
  4981. 4970    Packet$[5]=FNTochar$(Myeol)
  4982. 4971    Packet$[6]=CHR$(Myquote)
  4983. 4972    Packet$[7]="&"                    ! 8TH BIT PREFIX
  4984. 4973    Packet$[8]="1"                    ! CHECK TYPE
  4985. 4974    Packet$[9]=" "                    ! NO REPEAT COUNT PROCESS
  4986. 4975    IF Rptflag THEN 
  4987. 4976      Packet$[9,9]=CHR$(Rep_char)
  4988. 4977    END IF
  4989. 4978   !
  4990. 4979    IF Rcap_a THEN 
  4991. 4980      Capas=IVAL("001000",2)          ! File attributes = (8)
  4992. 4981      Packet$[10,10]=FNTochar$(Capas)    ! CAPAS MASK
  4993. 4982    ELSE
  4994. 4983      Packet$[10,10]=" "
  4995. 4984    END IF
  4996. 4985    !
  4997. 4986    ! Extended Length Packets  (m=desired length - <= 9024)
  4998. 4987    ! If bit 1 of capas is set:  000010
  4999. 4988    !
  5000. 4989    GOTO Skip_rcaplp   ! not implemented
  5001. 4990    IF Rcap_lp THEN 
  5002. 4991      Packet$[11,11]=FNTochar$(0)       ! Windo - not used
  5003. 4992      Packet$[12,12]=FNTochar$(R_maxl1)
  5004. 4993      Packet$[13,13]=FNTochar$(R_maxl2)
  5005. 4994    END IF
  5006. 4995 Skip_rcaplp:   !
  5007. 4996  !
  5008. 4997    RETURN 
  5009. 4998  !================================
  5010. 4999 Rrpar:  ! Receive Packet Initialization
  5011. 5000        ! Rdata$[] =DATA STRIPPED FROM INCOMING PACKET
  5012. 5001    IF Debug THEN DISP "INIT REc len = ";LEN(Rdata$)
  5013. 5002    FOR S=1 TO LEN(Rdata$)
  5014. 5003      SELECT S
  5015. 5004      CASE 1
  5016. 5005        Rpsiz=FNUnchar(Rdata$[1])       ! remote  packet size
  5017. 5006      CASE 2
  5018. 5007        Ptmo=FNUnchar(Rdata$[2])        ! remote packet timeout
  5019. 5008      CASE 3
  5020. 5009        Pad=FNUnchar(Rdata$[3])         ! remote    padding
  5021. 5010      CASE 4
  5022. 5011        Padchar=FNUnchar(Rdata$[4])     ! padding char to use
  5023. 5012      CASE 5
  5024. 5013        Eol=FNUnchar(Rdata$[5])
  5025. 5014        IF Eol=0 THEN Eol=Myeol         ! eol to use
  5026. 5015      CASE 6
  5027. 5016        Quote=NUM(Rdata$[6,6])          ! remote quote char
  5028. 5017      CASE 7
  5029. 5018        Qbin=NUM(Rdata$[7,7])
  5030. 5019        IF Qbin=89 THEN Qbin=38 ! 89=Y , 38=&  ! Y= Yes I do it
  5031. 5020      CASE 8
  5032. 5021        R_bchk=NUM(Rdata$[8,8])         ! remote block check type
  5033. 5022        R_bchk=R_bchk-48                ! 1=49 2=50 3=51
  5034. 5023        IF R_bchk<1 OR R_bchk>3 THEN 
  5035. 5024          R_bchk=1
  5036. 5025        END IF
  5037. 5026      CASE 9
  5038. 5027        Rep_char=NUM(Rdata$[9,9])
  5039. 5028      CASE 10
  5040. 5029        R_capas=FNUnchar(Rdata$[10,10])
  5041. 5030        IF BIT(R_capas,1) THEN ! extended length packets
  5042. 5031          Rcap_lp=1
  5043. 5032          R_windo=FNUnchar(Rdata$[11,11])
  5044. 5033          R_maxl1=FNUnchar(Rdata$[12,12])
  5045. 5034          R_maxl2=FNUnchar(Rdata$[13,13])
  5046. 5035          R_maxl=R_maxl1*95+R_maxl2
  5047. 5036        END IF
  5048. 5037   !
  5049. 5038        IF BIT(R_capas,3) THEN Rcap_a=1
  5050. 5039      END SELECT
  5051. 5040    NEXT S
  5052. 5041    RETURN 
  5053. 5042  SUBEND
  5054. 5043  !======================================================================
  5055. 5044  SUB Rpack(Pktype$,Rdata$,INTEGER Rseq,Rcvpkt$,Sndpkt$,INTEGER Npak,Retry_count,User_break,Emsg$)
  5056. 5045 Rpack: !
  5057. 5046  ! Pktype$    Packet Type  S,A,F,D,Z,B   N,Y
  5058. 5047  ! Rdata$     Packet Data Area. or User Abort Message
  5059. 5048  ! Rseq       Incomming Packet Sequence Number
  5060. 5049  ! Rcvpkt$    Raw Packet Received
  5061. 5050  ! Sndpkt$    Previous Packet Sent - required for resend on kbd interrupt
  5062. 5051  ! Npak       Expected packet sequence number
  5063. 5052  ! Retry_count
  5064. 5053  ! user_break=1 if user client interrupts file transfer
  5065. 5054  ! Emsg$      Error Msg created by receive packet, or client interrupt
  5066. 5055  !
  5067. 5056    OPTION BASE 1
  5068. 5057    COM /Crt/ Crt_lines,Crt_width
  5069. 5058    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  5070. 5059    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  5071. 5060    COM /Kerm/ INTEGER Maxp,Maxtry,Mypad,Mytmo,Mypchar,Myeol,Myquote
  5072. 5061    COM /Kerm/ INTEGER Size,Rpsiz,Spsiz,Pad,Capas,Send_at
  5073. 5062    COM /Kerm/ INTEGER Image,Parflg,Pktdeb
  5074. 5063    COM /Kerm/ INTEGER Filnamcnv,Blk_chk,Quote,Eol,Smark
  5075. 5064    COM /Kerm2/ State$,Cchksum$,Eof_mode$,INTEGER Eof_mode,Timer,Ptmo
  5076. 5065  !
  5077. 5066    DIM A$[1],K$[256],Rcvchksum$[20],Misc$[80]
  5078. 5067    INTEGER Chksum,Rc,Plen,Dlen,Cchksum
  5079. 5068    INTEGER Endl,Chkpos,Chk
  5080. 5069  !------------------------------------------------------------------------
  5081. 5070    ON ERROR GOSUB Rp_err
  5082. 5071    K$="" ! flush packet
  5083. 5072    ENABLE 
  5084. 5073    ON KBD,2 GOSUB Kbd_int   ! Kbd Escape
  5085. 5074 Get_packet: !
  5086. 5075    IF Timer THEN ON DELAY Ptmo,10 GOTO R_tmo     ! pkt tmo interrupt level 10
  5087. 5076    Rdata$=""
  5088. 5077    Rcvpkt$=""
  5089. 5078   !
  5090. 5079    REPEAT                       ! Until a Packet Header (mark) is found
  5091. 5080      IF Com_card=98628 THEN 
  5092. 5081        STATUS Com_port,5;B_len
  5093. 5082      ELSE
  5094. 5083        STATUS @In_buff,4;B_len
  5095. 5084      END IF
  5096. 5085      IF B_len THEN ENTER @In_buff USING "#,K";A$
  5097. 5086      IF LEN(A$) THEN A$=CHR$(BINAND(NUM(A$),127))    ! strip parity
  5098. 5087    UNTIL A$=CHR$(Smark)
  5099. 5088    Rcvpkt$[1,1]=A$            ! store packet mark
  5100. 5089  !
  5101. 5090  ! MARK FOUND - ENTER THE REST OF THE PACKET
  5102. 5091  !
  5103. 5092  ! ## If Comm Interrupt Occurs and buffer is flushed, an end of buffer occurs here
  5104. 5093  !
  5105. 5094    I=2
  5106. 5095    LOOP
  5107. 5096      ENTER @In_buff USING "#,K";A$
  5108. 5097      Rcvpkt$[I,I]=A$
  5109. 5098      IF I=2 THEN 
  5110. 5099        Plen=FNUnchar(Rcvpkt$[2,2])! Packet Length
  5111. 5100      END IF
  5112. 5101      I=I+1
  5113. 5102    EXIT IF I>Plen+3             ! mark+len+plen+eol = plen+3
  5114. 5103    END LOOP
  5115. 5104    OFF DELAY
  5116. 5105   !
  5117. 5106   ! Kermit Packet Received ----------------------
  5118. 5107   !
  5119. 5108    Beginl=POS(Rcvpkt$,CHR$(Smark))
  5120. 5109    Rcvpkt$=Rcvpkt$[Beginl]
  5121. 5110    Endl=POS(Rcvpkt$,"")
  5122. 5111    IF (Endl=0) THEN Endl=POS(Rcvpkt$,"
  5123. ")     ! if no CR then use LF
  5124. 5112    IF NOT Endl THEN 
  5125. 5113      Endl=LEN(Rcvpkt$)
  5126. 5114    END IF
  5127. 5115    Rcvpkt$=Rcvpkt$[Beginl,Endl]
  5128. 5116  ! Plen=FNUnchar(Rcvpkt$[2,2]) ! Packet Length
  5129. 5117    Plen=NUM(Rcvpkt$[2,2])-32   ! Packet Length
  5130. 5118  ! FNUnchar ==> RETURN NUM(C$)-32
  5131. 5119    Dlen=Plen-3                 ! Data Length
  5132. 5120    Chkpos=Plen+2               ! Position of checksum char
  5133. 5121  ! Rseq=FNUnchar(Rcvpkt$[3,3]) ! Rec Sequence Number
  5134. 5122    Rseq=NUM(Rcvpkt$[3,3])-32   ! Packet Length
  5135. 5123    Pktype$=Rcvpkt$[4,4]        ! Packet Type
  5136. 5124   !
  5137. 5125   ! Check Sequence
  5138. 5126   ! If Local Kermit was paused, there could be multiple packets
  5139. 5127   ! buffered with a sequence number < the current Npak.
  5140. 5128   !
  5141. 5129   ! Check buffer - if there is a packet, go get it, else ack this packet
  5142. 5130   ! and force the next packet to be sent.
  5143. 5131   !
  5144. 5132    IF (Rseq<Npak MOD 64) THEN   ! loop back and receive next packet
  5145. 5133   !
  5146. 5134   !  PRINT TABXY(1,Crt_lines);"Rseq<Npak:  Loop to get another packet "
  5147. 5135      IF Com_card=98628 THEN 
  5148. 5136        STATUS Com_port,5;B_len
  5149. 5137      ELSE
  5150. 5138        STATUS @In_buff,4;B_len
  5151. 5139      END IF
  5152. 5140   !
  5153. 5141      IF B_len THEN 
  5154. 5142        GOTO Get_packet
  5155. 5143      ELSE
  5156. 5144   !    PRINT TABXY(1,Crt_lines);"Acking packet=Rseq (rseq<npak) to force next packet: rseq=npak"
  5157. 5145        Spack("","Y",Rseq,Sndpkt$)    ! ack current (Rseq) packet
  5158. 5146        OUTPUT @Out_buff;Sndpkt$
  5159. 5147        GOTO Get_packet               ! Go get expected (Npak) packet
  5160. 5148      END IF
  5161. 5149    END IF
  5162. 5150  !
  5163. 5151    PRINT TABXY(1,Crt_lines);RPT$(" ",80)
  5164. 5152    IF Rseq>Npak THEN   ! exit rpack with a "Q" pktype$
  5165. 5153      Pktype$="Q"
  5166. 5154      PRINT TABXY(1,Crt_lines);"Packet out of sequence - ahead of expected packet ";Rseq,Npak,"subexit"
  5167. 5155      SUBEXIT
  5168. 5156    END IF
  5169. 5157   !-------------------------------------------------------------------
  5170. 5158   ! A good packet in the required sequence has been received
  5171. 5159   ! Flush the input buffer
  5172. 5160   !
  5173. 5161    IF Com_card=98628 THEN 
  5174. 5162      STATUS Com_port,5;B_len
  5175. 5163      WHILE B_len
  5176. 5164        ENTER @In_buff;Misc$
  5177. 5165        STATUS Com_port,5;B_len
  5178. 5166      END WHILE
  5179. 5167    ELSE
  5180. 5168      STATUS @In_buff,3;Fp
  5181. 5169   !  CONTROL @In_buff,5;Fp   ! Set empty pointer to fill pointer
  5182. 5170    END IF
  5183. 5171   !
  5184. 5172   ! Extract Data from Packet into Rdata$
  5185. 5173   !
  5186. 5174    IF Dlen THEN                   ! If Packet Has Data
  5187. 5175      ON ERROR GOTO Nodl
  5188. 5176      Rdata$[1,Dlen]=Rcvpkt$[5,Plen+1]
  5189. 5177      GOTO Dldone
  5190. 5178 Nodl:OFF ERROR 
  5191. 5179      FOR I=1 TO Dlen
  5192. 5180        Rdata$[I,I]=Rcvpkt$[4+I]
  5193. 5181      NEXT I
  5194. 5182    END IF
  5195. 5183 Dldone:OFF ERROR 
  5196. 5184    !
  5197. 5185    ! Check for Good Packet Checksum
  5198. 5186    !
  5199. 5187    Chk=0
  5200. 5188    FOR I=2 TO Plen+1
  5201. 5189      Chk=Chk+NUM(Rcvpkt$[I,I])
  5202. 5190    NEXT I
  5203. 5191    Cchksum=BINAND(Chk+(BINAND(Chk,192)/64),63)   ! Computed Checksum
  5204. 5192    Cchksum$=FNTochar$(Cchksum)
  5205. 5193    Rcvchksum$=Rcvpkt$[Chkpos;1]
  5206. 5194    IF Rcvchksum$<>Cchksum$ THEN Pktype$="Q"
  5207. 5195    SUBEXIT
  5208. 5196  !---------------------------------
  5209. 5197 R_tmo: !
  5210. 5198    BEEP 2000,.01
  5211. 5199    OFF DELAY
  5212. 5200    OFF TIMEOUT 
  5213. 5201    Pktype$="T"
  5214. 5202    DISP 
  5215. 5203    SUBEXIT
  5216. 5204  !---------------------------------
  5217. 5205 Kbd_int: !(rpack)
  5218. 5206    ! Cancels:  ^X (file)  ^Z (Batch) ^E (Err Quit) ^C(Quit) <ent> Retry
  5219. 5207   !
  5220. 5208   ! To Interrupt File Receive:
  5221. 5209   !
  5222. 5210   !  ACK Packet with:   X in data field to abort single file
  5223. 5211   !                     Z in data field to abort entire batch
  5224. 5212   !  E   Packet with    Error Msg if Sender doesn't recognize file interruption.
  5225. 5213   !
  5226. 5214    BEEP 300,.02
  5227. 5215    User_break=1
  5228. 5216    K$=KBD$
  5229. 5217    SELECT K$[1,1]
  5230. 5218    CASE "",""    ! ^?
  5231. 5219      PRINT TABXY(1,Crt_lines);
  5232. 5220      PRINT "Cancels:  ^X (file)  ^Z (Batch) ^E (Protocol) ^C(Quit) <Ent> Retry"
  5233. 5221    CASE "" ! ^X   ! Cancel File
  5234. 5222      Pktype$="X"
  5235. 5223      Rdata$="X"    ! discard file
  5236. 5224      Emsg$="Single File Cancelled by Client"
  5237. 5225      SUBEXIT
  5238. 5226    CASE CHR$(26)  ! ^Z   ! No Batch Process Yet (wildcard send/rec ?)
  5239. 5227      Pktype$="X"
  5240. 5228      Rdata$="Z"
  5241. 5229      Emsg$="Batch Receive  Cancelled by Client"
  5242. 5230      SUBEXIT
  5243. 5231    CASE ""  ! ^E   ! Goto Error (Abort)  State
  5244. 5232      State$="E"
  5245. 5233      Pktype$="E"
  5246. 5234      Emsg$="File Aborted by Client (E Packet)"
  5247. 5235      SUBEXIT
  5248. 5236    CASE "" ! ^C   ! Quit without Notifying Remote Kermit
  5249. 5237      State$="X"
  5250. 5238      Pktype$="X"
  5251. 5239      Rdata$="^C"   ! Notify sendz not to notify host
  5252. 5240      Emsg$="Transfer Aborted by Client - Host Not Notified"
  5253. 5241      SUBEXIT
  5254. 5242    CASE " "          ! CTRL-ENTER  resend - no abort
  5255. 5243      User_break=0
  5256. 5244      SELECT K$[2,2]
  5257. 5245      CASE "E"
  5258. 5246        OUTPUT @Out_buff;Sndpkt$
  5259. 5247      ! Retry_count=Retry_count+1   ! gets incr if SUBEXIT is used
  5260. 5248        PRINT TABXY(25,11);Retry_count
  5261. 5249        SUBEXIT
  5262. 5250      CASE ELSE
  5263. 5251      END SELECT
  5264. 5252    CASE ELSE
  5265. 5253      User_break=0
  5266. 5254    END SELECT
  5267. 5255    RETURN 
  5268. 5256  !--------------------------------------
  5269. 5257 Rp_err: !
  5270. 5258    SELECT ERRN
  5271. 5259    CASE 59    ! end of buffer found
  5272. 5260      Pktype$="T"
  5273. 5261      SUBEXIT
  5274. 5262    CASE 33    ! Null Char in Packet$
  5275. 5263      Emsg$="Short Packet"
  5276. 5264      Pktype$="Q"
  5277. 5265      SUBEXIT
  5278. 5266    CASE ELSE
  5279. 5267      DISP ERRM$
  5280. 5268      Pktype$="Q"  ! Checksum error
  5281. 5269      SUBEXIT      ! any error abort packet
  5282. 5270    END SELECT
  5283. 5271    RETURN 
  5284. 5272  !------------------------------------------
  5285. 5273  SUBEND
  5286. 5274  !=======================================================================
  5287. 5275 Init_ramdisc:SUB Init_ramdisc(Kbytes,OPTIONAL Clear$,Sectors)
  5288. 5276  !
  5289. 5277  ! This routine cannot check for existance of a RAM Disc before
  5290. 5278  ! initializing because of nested ON ERROR conflicts. If this routine
  5291. 5279  ! is called from an ON ERROR routine,then an error in this routine
  5292. 5280  ! cannot be trapped.
  5293. 5281  !
  5294. 5282! Initialize Ram Disc
  5295. 5283!
  5296. 5284    DIM Sav_msi$[256]
  5297. 5285    Cat_msi$=":,0,0"
  5298. 5286    INTEGER Sector(1:128)
  5299. 5287    Sav_msi$=SYSTEM$("MSI")
  5300. 5288    INITIALIZE ":,0,0",0                 ! destroy any existing ram disc
  5301. 5289    DISP "Creating RAM Volume - please wait"
  5302. 5290    Avm=VAL(SYSTEM$("AVAILABLE MEMORY"))
  5303. 5291    Bytes=Avm-100000                      ! SAVE 100 KB
  5304. 5292    Kbytes=Bytes/1000
  5305. 5293    Kbytes=MAX(Kbytes,0)
  5306. 5294    Kbytes=MIN(Kbytes,3000)               ! 3 Mb Max
  5307. 5295    IF Kbytes>0 THEN 
  5308. 5296      Size=INT(Kbytes*4)                       ! 4 sectors PER kB
  5309. 5297      INITIALIZE ":,0,0",Size
  5310. 5298 !------------------------------------------
  5311. 5299      IF NPAR>1 THEN 
  5312. 5300        IF Clear$="CLEAR" THEN 
  5313. 5301          MASS STORAGE IS ":,0,0"
  5314. 5302          Get_volinfo(Dir_st,Dir_len,Vol_lbl$)
  5315. 5303          Cl_sect=Size
  5316. 5304          IF NPAR>2 THEN Cl_sect=MIN(Sectors,500)
  5317. 5305          DISP "Clearing";Cl_sect;" Disc Sectors"
  5318. 5306          FOR Sect=Dir_st+Dir_len-1 TO Cl_sect
  5319. 5307            Phywrite(Sect,Sector(*))
  5320. 5308          NEXT Sect
  5321. 5309        END IF
  5322. 5310      END IF
  5323. 5311    END IF
  5324. 5312    MASS STORAGE IS Sav_msi$
  5325. 5313    DISP 
  5326. 5314  SUBEND
  5327. 5315  !-----------------------------------------------------------------------
  5328. 5316 Shutdown:SUB Shutdown(OPTIONAL INTEGER Transfer_on)       ! Shutdown Serial Transfers
  5329. 5317  !
  5330. 5318    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  5331. 5319    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  5332. 5320  !
  5333. 5321    IF Com_card=98628 THEN SUBEXIT
  5334. 5322  !
  5335. 5323    STATUS Com_port,10;Uart    !       clear frame errors
  5336. 5324  !
  5337. 5325  ! Check if transfer is running
  5338. 5326  !
  5339. 5327    STATUS @Out_buff,0;O_stat     ! IS PATH VALID ?
  5340. 5328    IF O_stat<3 THEN 
  5341. 5329      IF NPAR THEN Transfer_on=0
  5342. 5330      SUBEXIT
  5343. 5331    END IF
  5344. 5332  !
  5345. 5333    STATUS @Out_buff,11;O_stat
  5346. 5334    IF BIT(O_stat,6) THEN 
  5347. 5335      IF NPAR THEN Transfer_on=1
  5348. 5336      CONTROL @Out_buff,9;0     ! non-continuous
  5349. 5337      WAIT FOR EOT @Com_out     ! normal transfer shutoff
  5350. 5338    END IF
  5351. 5339  !
  5352. 5340    STATUS @In_buff,10;I_stat
  5353. 5341    IF BIT(I_stat,6) THEN 
  5354. 5342      CONTROL @In_buff,8;0      ! non-continuous
  5355. 5343      ABORTIO @Com_in           ! shutoff
  5356. 5344    END IF
  5357. 5345    STATUS Com_port,10;Uart    ! clear any frame errors
  5358. 5346  SUBEND
  5359. 5347  !-----------------------------------------------------------------------
  5360. 5348  SUB Startup
  5361. 5349 Startup: !    Shuts Down Transfers if Active
  5362. 5350          !    Perform ASSIGN for Transfer Buffer and COM Port
  5363. 5351  !
  5364. 5352  !
  5365. 5353    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  5366. 5354    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  5367. 5355    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$,Parity_type$
  5368. 5356    COM /Frame/ Flow$,Hshake$
  5369. 5357  !
  5370. 5358    ON ERROR GOSUB Startup_err
  5371. 5359    ON TIMEOUT Com_port,.5 GOSUB Startup_err
  5372. 5360  !
  5373. 5361  ! CHECK IF TRANSFERS RUNNING
  5374. 5362  !
  5375. 5363 Retry_xfer: !
  5376. 5364    STATUS @In_buff,0;Valid_path
  5377. 5365    IF Valid_path=3 THEN  ! buffer
  5378. 5366      STATUS @In_buff,10;I_stat
  5379. 5367      IF BIT(I_stat,6) THEN 
  5380. 5368        CALL Shutdown
  5381. 5369      END IF
  5382. 5370    END IF
  5383. 5371  !
  5384. 5372  !
  5385. 5373    IF Com_card=98628 THEN 
  5386. 5374      IF On_off$="OFF" THEN 
  5387. 5375        ASSIGN @Out_buff TO Com_port;PARITY OFF
  5388. 5376        ASSIGN @In_buff TO Com_port;PARITY OFF
  5389. 5377      ELSE
  5390. 5378        ASSIGN @Out_buff TO Com_port
  5391. 5379        ASSIGN @In_buff TO Com_port
  5392. 5380      END IF
  5393. 5381      SUBEXIT
  5394. 5382    ELSE
  5395. 5383      STATUS Com_port,10;Dummy          ! CLEAR ERRORS
  5396. 5384      IF On_off$="OFF" THEN 
  5397. 5385        ASSIGN @Com_in TO Com_port;PARITY OFF
  5398. 5386        ASSIGN @Com_out TO Com_port;PARITY OFF
  5399. 5387      ELSE
  5400. 5388        ASSIGN @Com_out TO Com_port
  5401. 5389        ASSIGN @Com_in TO Com_port
  5402. 5390      END IF
  5403. 5391      ASSIGN @In_buff TO BUFFER Input_buffer$
  5404. 5392      ASSIGN @Out_buff TO BUFFER Output_buffer$
  5405. 5393    END IF
  5406. 5394    !
  5407. 5395    ! START OUTBOUND TRANSFER FIRST
  5408. 5396    !
  5409. 5397    OFF ERROR 
  5410. 5398    STATUS Com_port,10;Uart    ! clear errors - prevent error 167
  5411. 5399    TRANSFER @Out_buff TO @Com_out;CONT
  5412. 5400    REPEAT
  5413. 5401      STATUS @Out_buff,11;Out_status
  5414. 5402    UNTIL BIT(Out_status,6)=1
  5415. 5403    !
  5416. 5404    OUTPUT @Out_buff;" ";    ! kickstart transfer
  5417. 5405    !
  5418. 5406    ! Inbound may receive buffer overrun error 167 - io status error
  5419. 5407    ! due to an abortive interrupt (ie buff overrun) in the interface.
  5420. 5408    ! An abortive interrupt will shut off a transfer.
  5421. 5409    !
  5422. 5410    STATUS Com_port,10;Uart    ! clear errors - prevent error 167
  5423. 5411    TRANSFER @Com_in TO @In_buff;CONT
  5424. 5412    REPEAT
  5425. 5413      STATUS @In_buff,10;Inb_status
  5426. 5414    UNTIL BIT(Inb_status,6)=1
  5427. 5415  !
  5428. 5416  ! CHECK FOR ANY TRANSFER ERROR
  5429. 5417  !
  5430. 5418    STATUS @In_buff,10;I_stat
  5431. 5419    STATUS @Out_buff,11;O_stat
  5432. 5420  !
  5433. 5421    IF (BIT(I_stat,4)) OR (BIT(O_sta,4)) THEN 
  5434. 5422      GOTO Retry_xfer
  5435. 5423    END IF
  5436. 5424    SUBEXIT
  5437. 5425  !=-------------------------------
  5438. 5426 Startup_err: !
  5439. 5427    SELECT ERRN
  5440. 5428    CASE 167,168,0            ! IO Status Error
  5441. 5429      CALL Com_interrupt
  5442. 5430      STATUS Com_port,10;Uart  ! clear errors - prevent error 167
  5443. 5431   !  DISP "UART: ";Uart,"startup"
  5444. 5432      ON ERROR GOSUB Startup_err
  5445. 5433      ON TIMEOUT Com_port,.5 GOSUB Startup_err
  5446. 5434    CASE ELSE
  5447. 5435      BEEP 
  5448. 5436      DISP ERRM$
  5449. 5437      PAUSE
  5450. 5438    END SELECT
  5451. 5439    RETURN 
  5452. 5440  SUBEND
  5453. 5441  !-----------------------------------------------------------------------
  5454. 5442  SUB Reset_port
  5455. 5443 Reset_port: !
  5456. 5444  !
  5457. 5445    COM /Port/ @Out_buff,@Com_out,Output_buffer$ BUFFER
  5458. 5446    COM /Port/ Com_port,@In_buff,@Com_in,Input_buffer$ BUFFER,Com_card
  5459. 5447    COM /Frame/ Baud,Data_bits,Stop_bits,On_off$,Parity_type$
  5460. 5448    COM /Frame/ Flow$,Hshake$
  5461. 5449  !
  5462. 5450    SELECT Com_card
  5463. 5451    CASE 98626
  5464. 5452      STATUS Com_port,10;Uart         ! clear any frame errors
  5465. 5453      CONTROL Com_port,0;1       ! RESET PORT - DISCONNECT MODEM
  5466. 5454      CONTROL Com_port,5;1+2          ! force dtr,rts active
  5467. 5455      CONTROL Com_port,12;128+32+16   ! Disable modem handshake
  5468. 5456    CASE 98628
  5469. 5457      CONTROL Com_port,0;1  ! Reset and read config switches
  5470. 5458      CONTROL Com_port,3;1  ! async protocol after next reset
  5471. 5459 ! control Com_port,5;0     ! terminate trans and turnaround if half-duplex
  5472. 5460 ! control Com_port,6;1     ! BREAK
  5473. 5461      CONTROL Com_port,8;1+2! RTS  DTR  Set Active
  5474. 5462 ! CONTROL Com_port,12;2    ! 2 = start autodial  1=connect (dtr,rts)
  5475. 5463      CONTROL Com_port,13;164     ! INT MASK  4=UART  32=lost car 128=break
  5476. 5464      CONTROL Com_port,14;0 ! Control Blocks Disabled  (queued with data)
  5477. 5465      CONTROL Com_port,15;0 ! MODEM INT MASK
  5478. 5466 ! CONTROL Com_port,16;25   ! Connect Timeout (reset=25 sec)
  5479. 5467 ! CONTROL Com_port,17;10   ! No activity Timeout (reset=10 min )
  5480. 5468 ! CONTROL Com_port,18;40   ! Lost Carrier Timeout 10xMS (reset=40)
  5481. 5469 ! CONTROL Com_port,19;10   ! CTS (send)   Timeout (reset=10 sec)
  5482. 5470 !    CONTROL Com_port,20;9 ! BAUD RATE  9=1200 11=2400 14=9600
  5483. 5471 !    CONTROL Com_port,21;9 ! REC  RATE  9=1200 11=2400 14=9600
  5484. 5472 !
  5485. 5473      SELECT Flow$
  5486. 5474      CASE "NONE"              ! Protocol (SW) Handshake
  5487. 5475        CONTROL Com_port,22;0  ! 0:none 1:enq-host 2:enq-term
  5488. 5476      CASE "XON/XOFF"          ! 3-5: xon/off host/term/both
  5489. 5477        CONTROL Com_port,22;5
  5490. 5478      CASE "ENQ/ACK"
  5491. 5479        CONTROL Com_port,22;2
  5492. 5480      CASE ELSE
  5493. 5481        CONTROL Com_port,22;0
  5494. 5482      END SELECT
  5495. 5483  !
  5496. 5484      IF Hshake$="ON" THEN 
  5497. 5485        CONTROL Com_port,23;3! HDWR HNDSHK:  0=off/non-modem 1:full
  5498. 5486      ELSE                  !               2=hlf dup mod 3=CTS/DCD
  5499. 5487        CONTROL Com_port,23;0
  5500. 5488      END IF
  5501. 5489      CONTROL Com_port,24;127! Control Char Mask: pass null,eol,proto,del,rub
  5502. 5490                            ! change uart err to underscore (127-pass all)
  5503. 5491      CONTROL Com_port,26;17! First Protocol Hndshk  6=ack  (17=dc1/XON)
  5504. 5492      CONTROL Com_port,27;19! First Protocol Hndshk  5=enq  (19=dc3/XOFF)
  5505. 5493      CONTROL Com_port,28;1 ! length of inbound EOL  (reset=2)
  5506. 5494      CONTROL Com_port,29;13! first EOL (13=Cr)
  5507. 5495      CONTROL Com_port,30;10! second EOL (10=Lf)
  5508. 5496 ! CONTROL Com_port,31;1    ! prompt$ length (1)
  5509. 5497 ! CONTROL Com_port,32;17   ! first prompt$ char (17=dc1)
  5510. 5498 ! CONTROL Com_port,33;0    ! second prompt$ char (0=null)
  5511. 5499  !
  5512. 5500  !   CONTROL Com_port,34;3 ! frame length (databits=card dip switch)
  5513. 5501                            ! 2=7  3=8 (parity must be none,even,odd)
  5514. 5502  !   CONTROL Com_port,35;0 ! Stop Bits: (0=1) 1=1.5  2=2
  5515. 5503  !   CONTROL Com_port,36;0 ! Parity 0=none  1=odd 2=even 3="0" 4="1"
  5516. 5504      CONTROL Com_port,37;0 ! Inter-char time gap (0=none)  <255 char times
  5517. 5505      CONTROL Com_port,39;4 ! Set BREAK char time (4)  2-255
  5518. 5506      CALL Set_frame(Baud)
  5519. 5507    END SELECT
  5520. 5508  !-------------------------
  5521. 5509  SUBEND
  5522. 5510  !========================================================================
  5523. 5511  SUB Parse_filename(F$,F_msi$,F_path$)
  5524. 5512 Parse_filename: !
  5525. 5513  ! F$ is consumed and filename is returned in its place
  5526. 5514  !
  5527. 5515    DIM Misc$[256]
  5528. 5516    INTEGER Sl_pos
  5529. 5517  !
  5530. 5518    IF LEN(F_msi$) THEN 
  5531. 5519      IF NOT POS(F$,":") THEN F$=F$&F_msi$
  5532. 5520    END IF
  5533. 5521  !
  5534. 5522    Filename$=""
  5535. 5523    F_msi$=""
  5536. 5524  ! F_path$=""     ! corrupts f_path$ if not passed in F$
  5537. 5525  !
  5538. 5526  ! If MSI exists strip it off of F$
  5539. 5527  !
  5540. 5528    IF POS(F$,":") THEN              ! MSI SPECIFIED
  5541. 5529      F_msi$=F$[POS(F$,":")]
  5542. 5530      F$=F$[1,POS(F$,":")-1]         ! Strip MSI
  5543. 5531    END IF
  5544. 5532  !
  5545. 5533  !  Strip PATH from F$,     keep last slash on pathname
  5546. 5534  !
  5547. 5535    IF POS(F$,"/") THEN 
  5548. 5536      Misc$=REV$(F$)
  5549. 5537      Sl_pos=POS(Misc$,"/")          ! SLASH POSITION
  5550. 5538      F$=REV$(Misc$[1,Sl_pos-1])
  5551. 5539      F_path$=REV$(Misc$[Sl_pos])
  5552. 5540    END IF
  5553. 5541  SUBEND
  5554. 5542 !=========================================================================
  5555. 5543  SUB Get_volinfo(Dir_st,Dir_len,Vol_lbl$)
  5556. 5544 Gvi: !
  5557. 5545 ! Returns the starting sector of the volume directory, its length
  5558. 5546 !
  5559. 5547    INTEGER I,Msb,Lsb,X
  5560. 5548    Dir_st=0
  5561. 5549    Dir_len=0
  5562. 5550    Vol_lbl$=""
  5563. 5551    COM /Sctr/ INTEGER Sctr(0:127)
  5564. 5552    Phyread(0,Sctr(*))                   ! read LIF Volume Header
  5565. 5553    Dir_st=(Sctr(4)*2^16)+Sctr(5)
  5566. 5554    Dir_len=(Sctr(8)*2^16)+Sctr(9)
  5567. 5555  ! DISP "DIR START: ";Dir_st,"DIR LENGTH :  ";Dir_len
  5568. 5556    FOR I=1 TO 3
  5569. 5557      Temp=Sctr(I)
  5570. 5558      IF Sctr(I)<0 THEN Temp=Sctr(I)+65536
  5571. 5559      Msb=Temp DIV 256
  5572. 5560      Lsb=Temp MOD 256
  5573. 5561      Vol_lbl$=Vol_lbl$&CHR$(Msb)&CHR$(Lsb)
  5574. 5562    NEXT I
  5575. 5563 Done:!
  5576. 5564  SUBEND
  5577. 5565 !-------------------------------------------------------------------------
  5578. 5566  SUB Get_fileinfo(Filename$,REAL Fs,Fl,Dir_entry_sec,Dir_entry,OPTIONAL INTEGER T,V,P,R)
  5579. 5567 Gfi: !
  5580. 5568  ! Pass-in Parameters:
  5581. 5569  ! Filename$            File Name Only - no msi
  5582. 5570  !
  5583. 5571  ! Return Parameters
  5584. 5572  !
  5585. 5573  ! Fs              Start Sector of File
  5586. 5574  ! Fl              Number of sectors in file
  5587. 5575  ! Dir_entry_sec   Directory Sector Containing File Entry
  5588. 5576  ! Dir_entry       Dir Entry Number in that Sector (0-7 per sector)
  5589. 5577  ! T               File Type Number
  5590. 5578  ! V               Volume number
  5591. 5579  ! P,R             Protection Numbers
  5592. 5580  !----------------------------------------------
  5593. 5581    INTEGER I,Fword,Msb,Lsb,X
  5594. 5582    COM /Sctr/ INTEGER Sctr(0:127)
  5595. 5583    DIM Entryname$[10],Vol_lbl$[6]
  5596. 5584    Get_volinfo(Ds,Dl,Lbl$)          ! Get  Dir Start, Dir Length, Vol Label
  5597. 5585    !
  5598. 5586    IF POS(Filename$,":") THEN CALL Parse_filename(Filename$,F_msi$,F_path$)
  5599. 5587    FOR Sector=Ds TO Ds+Dl-1         ! Search Directory for File Match
  5600. 5588      Phyread(Sector,Sctr(*))
  5601. 5589      FOR Entry=0 TO 7               ! 8 File entries per sector
  5602. 5590        Entryname$=""
  5603. 5591        Fword=Entry*16
  5604. 5592        IF Sctr(Fword+5)=-1 THEN 
  5605. 5593          Next_open_entry=Entry     ! Gives Next open Dir entry
  5606. 5594          Next_open_sec=Sector
  5607. 5595          GOTO Done_find
  5608. 5596        END IF
  5609. 5597        IF Sctr(Fword+5)=0 THEN Nexte         !  0 = null entry
  5610. 5598        FOR I=0 TO 4                 ! 5 words = 10 Char Name
  5611. 5599          Word_2char(Sctr(Fword+I),Msb,Lsb)
  5612. 5600          Entryname$=Entryname$&CHR$(Msb)&CHR$(Lsb)
  5613. 5601        NEXT I
  5614. 5602        IF TRIM$(Entryname$)=TRIM$(Filename$) THEN 
  5615. 5603          Dir_entry_sec=Sector                       ! dir entry position
  5616. 5604          Dir_entry=Entry
  5617. 5605      !   PRINT Dir_entry_sec,Dir_entry,Fword,Filename$
  5618. 5606          GOTO Found_it
  5619. 5607        END IF
  5620. 5608 Nexte:NEXT Entry
  5621. 5609    NEXT Sector
  5622. 5610 Done_find:S=-1
  5623. 5611    GOTO Done
  5624. 5612    !
  5625. 5613 Found_it:  !
  5626. 5614  ! PRINT USING "8(K,X),/";Sctr(*)
  5627. 5615    Fs=(Sctr(Fword+6)*2^16)+Sctr(Fword+7)    ! S=Start sector of file
  5628. 5616    Fl=(Sctr(Fword+8)*2^16)+Sctr(Fword+9)    ! L=Number of sectors
  5629. 5617 !
  5630. 5618    IF NPAR>5 THEN T=Sctr(Fword+5)  ! File Type
  5631. 5619    IF NPAR>8 THEN V=Sctr(Fword+13) ! Volume Number
  5632. 5620    IF NPAR>9 THEN P=Sctr(Fword+14) ! Protect Code for file
  5633. 5621    IF NPAR>10 THEN R=Sctr(Fword+15)!
  5634. 5622 Done:!
  5635. 5623  SUBEND
  5636. 5624  !------------------------------------------------------------------------
  5637. 5625  SUB Word_2char(INTEGER N,Msb,Lsb)
  5638. 5626  !
  5639. 5627  ! Extracts 2 Character Bytes from an integer (word)
  5640. 5628  ! Returns the characters as Msb and Lsb integers
  5641. 5629  !
  5642. 5630  !
  5643. 5631    Temp=N
  5644. 5632    IF N<0 THEN Temp=N+65536
  5645. 5633    Msb=Temp DIV 256
  5646. 5634    Lsb=Temp MOD 256
  5647. 5635  SUBEND
  5648. 5636  !----------------------------------------------------------------------
  5649. 5637 Convert:SUB Convert(Sf$,Type$,INTEGER Rc,OPTIONAL Flen,Df$)
  5650. 5638  !
  5651. 5639  ! Sf$:  complete filespec for source file to change
  5652. 5640  ! Df$:  Filespec or destination msi$ for converted file
  5653. 5641  ! Convert Sf$ to the Type$ specified and copy result to D_msi$
  5654. 5642  !
  5655. 5643    COM /Crt/ Crt_lines,Crt_width
  5656. 5644    Debug=1
  5657. 5645    ON ERROR GOSUB Cnvt_err
  5658. 5646    REAL S,L,Dir_entry_sec
  5659. 5647    INTEGER T,V,R,P,Asector(0:127)
  5660. 5648    DIM Filename$[80],Sav_msi$[256],S_msi$[256]
  5661. 5649  !
  5662. 5650    Sav_msi$=SYSTEM$("MSI")
  5663. 5651    Parse_filename(Sf$,S_msi$,S_path$)
  5664. 5652    Filename$=S_path$&Sf$&S_msi$
  5665. 5653    IF FNHfs_disc(S_msi$) THEN          ! HFS - must copy to ramdisc
  5666. 5654      S_path$=""
  5667. 5655      IF S_msi$=":,0,0" THEN 
  5668. 5656        ! file already on ramdisc
  5669. 5657      ELSE
  5670. 5658        Init_ramdisc(Kbytes)
  5671. 5659        S_msi$=":,0,0"
  5672. 5660        DISP "Copying ";Filename$;" TO ";Sf$&S_msi$
  5673. 5661        COPY Filename$ TO Sf$&S_msi$
  5674. 5662      END IF
  5675. 5663    END IF
  5676. 5664  !
  5677. 5665    Filename$=S_path$&Sf$&S_msi$
  5678. 5666    MASS STORAGE IS S_msi$
  5679. 5667    Pcode=32*256+32          ! protect code for non-ascii files
  5680. 5668    Get_fileinfo(Sf$,S,L,Dir_entry_sec,Dir_entry,T,V,P,R)
  5681. 5669    IF Dir_entry_sec=0 THEN 
  5682. 5670      DISP "Cant find ";Sf$;"  In Disc Directory "
  5683. 5671      SUBEXIT
  5684. 5672    END IF
  5685. 5673  !
  5686. 5674    Phyread(Dir_entry_sec,Asector(*))
  5687. 5675    Fword=Dir_entry*16
  5688. 5676    Cur_type=Asector(Fword+5)          ! File Type
  5689. 5677   !
  5690. 5678    SELECT Cur_type
  5691. 5679    CASE 1
  5692. 5680      Cur_type$="ASCII"
  5693. 5681    CASE -5791
  5694. 5682      Cur_type$="BDAT"
  5695. 5683    CASE -5808
  5696. 5684      Cur_type$="PROG"
  5697. 5685    CASE -5813
  5698. 5686      Cur_type$="HP-UX"
  5699. 5687    CASE -5775
  5700. 5688      Cur_type$="BIN"
  5701. 5689    CASE -5822
  5702. 5690      Cur_type$="SYSTM"
  5703. 5691    CASE ELSE       ! Pascal ?
  5704. 5692      Cur_type$="FOREIGN"
  5705. 5693    END SELECT
  5706. 5694  ! DISP "Current file type is ";Cur_type$
  5707. 5695    New_type$=Type$
  5708. 5696 Get_type_num: !
  5709. 5697    SELECT New_type$
  5710. 5698    CASE "ASCII"
  5711. 5699      New_type=1
  5712. 5700    CASE "BDAT"
  5713. 5701      New_type=-5791
  5714. 5702    CASE "PROG"
  5715. 5703      New_type=-5808
  5716. 5704    CASE "HP-UX","HPUX"
  5717. 5705      New_type=-5813
  5718. 5706    CASE "BIN"
  5719. 5707      New_type=-5775
  5720. 5708    CASE "SYSTM","SYSTEM"
  5721. 5709      New_type=-5822
  5722. 5710    CASE ELSE
  5723. 5711      New_type=VAL(New_type$)
  5724. 5712      DISP "Change Type to ";New_type
  5725. 5713      OUTPUT KBD;"Y";" H";
  5726. 5714      ENTER KBD;Ans$
  5727. 5715      IF UPC$(Ans$[1,1])="Y" THEN 
  5728. 5716      ELSE
  5729. 5717        SUBEXIT
  5730. 5718      END IF
  5731. 5719    END SELECT
  5732. 5720   !
  5733. 5721    DISP "Changing File Type to ";New_type$,New_type
  5734. 5722    WAIT .5
  5735. 5723    Asector(Fword+5)=New_type
  5736. 5724  !
  5737. 5725    IF New_type$<>"ASCII" THEN Asector(Fword+14)=Pcode
  5738. 5726    IF New_type$="BDAT" THEN Asector(Fword+15)=128   ! 128=256 Bytes per rec
  5739. 5727    IF New_type$="PROG" THEN 
  5740. 5728      GOTO Skip_adj_prog
  5741. 5729   !
  5742. 5730   ! Make sure EOF is on a sector boundary (256 byte)
  5743. 5731   ! Therefore the low-byte should always be 00x
  5744. 5732   !
  5745. 5733      Hibyte=Asector(Fword+6)
  5746. 5734      Lobyte=Asector(Fword+7)
  5747. 5735      IF Lobyte>0 THEN 
  5748. 5736        DISP "Adjusting EOF to a sector boundary"
  5749. 5737        PAUSE
  5750. 5738        Asector(Fword+6)=Hibyte+1
  5751. 5739        Asector(Fword+7)=0
  5752. 5740      END IF
  5753. 5741 Skip_adj_prog:   !
  5754. 5742   !
  5755. 5743   ! Set Record size to 0080x for PROG Files
  5756. 5744   !
  5757. 5745      Asector(Fword+15)=128                               ! x0080
  5758. 5746    END IF
  5759. 5747 !
  5760. 5748    IF NPAR>3 THEN   ! File-length Flen was specified
  5761. 5749      IF New_type$="PROG" THEN 
  5762. 5750        Asector(Fword+8)=INT(Flen/256)
  5763. 5751        Asector(Fword+9)=Flen MOD 256
  5764. 5752      END IF
  5765. 5753    END IF
  5766. 5754    Phywrite(Dir_entry_sec,Asector(*))
  5767. 5755    Rc=1
  5768. 5756  !
  5769. 5757    IF New_type$="HP-UX" THEN      ! Reset EOF pointer
  5770. 5758      ASSIGN @T TO Filename$
  5771. 5759      STATUS @T,3;Defr
  5772. 5760      CONTROL @T,7;Defr
  5773. 5761    END IF
  5774. 5762  !
  5775. 5763    IF Napr>4 THEN 
  5776. 5764      Df$=D_msi$
  5777. 5765      Parse_filename(Df$,D_msi$,D_path$)
  5778. 5766      IF NOT LEN(Df$) THEN Df$=Sf$
  5779. 5767      COPY Filename$ TO D_path$&Df$&D_msi$
  5780. 5768    END IF
  5781. 5769    MASS STORAGE IS Sav_msi$
  5782. 5770    DISP 
  5783. 5771    SUBEXIT  !-------------------------------------------------------------
  5784. 5772 Cnvt_err: !
  5785. 5773    DISP ERRM$
  5786. 5774    SELECT ERRN
  5787. 5775    CASE 54          ! duplicate filename
  5788. 5776      DISP "Purging: ";Sf$&S_msi$
  5789. 5777      PURGE Sf$&S_msi$
  5790. 5778      WAIT 1
  5791. 5779      DISP 
  5792. 5780    CASE ELSE
  5793. 5781      DISP ERRM$;"  in Convert"
  5794. 5782    END SELECT
  5795. 5783    RETURN 
  5796. 5784  SUBEND
  5797. 5785  !========================================================================
  5798. 5786  DEF FNHfs_disc(Msi$)
  5799. 5787    ALLOCATE Cat$(0:3)[80] ! 0:MSI  1:LABEL  2:FORMAT  3:SPACE
  5800. 5788    IF NOT LEN(Msi$) THEN Msi$=SYSTEM$("MSI")
  5801. 5789    CAT Msi$ TO Cat$(*)
  5802. 5790    IF POS(Cat$(2),"HFS") THEN 
  5803. 5791      RETURN 1
  5804. 5792    ELSE
  5805. 5793      RETURN 0
  5806. 5794    END IF
  5807. 5795  FNEND
  5808. 5796  !------------------------------------------------------------------------
  5809. 5797 Disc_space:SUB Disc_space(Msi$,Total,Largest_hole,Hole_sum,Format$)
  5810. 5798  !
  5811. 5799  ! Format$  HFS,LIF
  5812. 5800  ! All amounts in Sectors
  5813. 5801  !
  5814. 5802    INTEGER Recsz,Num_files,Cat_size
  5815. 5803    REAL Flen
  5816. 5804  !
  5817. 5805    Cat_size=150
  5818. 5806    ALLOCATE Cat$(1:Cat_size)[80] ! 1:MSI  2:LABEL  3:FORMAT  4:SPACE
  5819. 5807    ON ERROR GOSUB Space_err
  5820. 5808    CAT Msi$ TO Cat$(*);COUNT Num_files ! 7 LINE HEADER
  5821. 5809    REDIM Cat$(1:Num_files)
  5822. 5810    Num_files=Num_files-7
  5823. 5811    ENTER Cat$(4);Total                          ! SECTORS
  5824. 5812    Format$=TRIM$(Cat$(3)[POS(Cat$(3),":")+1])
  5825. 5813    Hole_sum=0
  5826. 5814    Hole=0
  5827. 5815    Largest_hole=0
  5828. 5816  !
  5829. 5817    DEALLOCATE Cat$(*)
  5830. 5818    IF Num_files>=Cat_size THEN GOSUB Get_count
  5831. 5819    IF Num_files=0 THEN 
  5832. 5820      Largest_hole=Total
  5833. 5821      SUBEXIT
  5834. 5822    END IF
  5835. 5823    IF NOT POS(Format$,"HFS") THEN 
  5836. 5824      ALLOCATE Cat$(1:Num_files)[80]
  5837. 5825      CAT Msi$ TO Cat$(*);NO HEADER,EXTEND
  5838. 5826      FOR I=1 TO Num_files-1
  5839. 5827        Start_sec=VAL(Cat$(I)[40,47])
  5840. 5828        Flen=VAL(Cat$(I)[20,28])
  5841. 5829        Recsz=VAL(Cat$(I)[33,39])
  5842. 5830        IF Recsz=1 THEN Flen=Flen/256
  5843. 5831        Next_sec=VAL(Cat$(I+1)[40,47])
  5844. 5832        Del_sec=Next_sec-Start_sec
  5845. 5833        Hole=Del_sec-Flen
  5846. 5834        Hole_sum=Hole_sum+Hole
  5847. 5835        IF Hole>Largest_hole THEN 
  5848. 5836          Largest_hole=Hole
  5849. 5837        END IF
  5850. 5838      NEXT I
  5851. 5839      Last_contig=Total-Hole_sum
  5852. 5840      IF Last_contig>Largest_hole THEN Largest_hole=Last_contig
  5853. 5841    ELSE
  5854. 5842      Largest_hole=Total
  5855. 5843    END IF
  5856. 5844    SUBEXIT !---------------------------------------------------
  5857. 5845 Get_count:   !
  5858. 5846    Num_try=100
  5859. 5847    REPEAT
  5860. 5848      Num_try=Num_try+25
  5861. 5849      ALLOCATE Cat$(1:Num_try)[80]
  5862. 5850      CAT Msi$ TO Cat$(*);NAMES,COUNT Num_files,NO HEADER   ! HEADER NOT INC
  5863. 5851      DEALLOCATE Cat$(*)
  5864. 5852    UNTIL Num_files<Num_try
  5865. 5853    RETURN 
  5866. 5854   !---------------------------
  5867. 5855 Space_err: !
  5868. 5856    SELECT ERRN
  5869. 5857    CASE 76      ! INCORRECT UNIT CODE
  5870. 5858      SUBEXIT
  5871. 5859    CASE ELSE
  5872. 5860      DISP ERRM$
  5873. 5861      PAUSE
  5874. 5862    END SELECT
  5875. 5863    RETURN 
  5876. 5864  SUBEND
  5877. 5865  !------------------------------------------------------------------------
  5878. 5866  SUB Get_cat_entry(F$,F_msi$,F_path$,Filename$,File_found,Cat_entry$)
  5879. 5867 Get_cat_entry: !
  5880. 5868    ON ERROR GOSUB Gce_err
  5881. 5869    ALLOCATE Cat$(1:50)[80],Misc$[256]
  5882. 5870    File_found=0
  5883. 5871    REPEAT
  5884. 5872      DISP "Checking File Access"
  5885. 5873    !
  5886. 5874    ! Warning, CAT;SELECT may  find more than one file
  5887. 5875    !
  5888. 5876      CAT F_path$&F_msi$ TO Cat$(*);SELECT F$,COUNT Num_files        !FILE IS ELMENT 8
  5889. 5877      FOR I=8 TO Num_files
  5890. 5878        IF POS(Cat$(I),F$) THEN 
  5891. 5879          Cat_entry$=Cat$(I)
  5892. 5880          Misc$=TRIM$(Cat_entry$[1,21])
  5893. 5881          IF Misc$=F$ THEN 
  5894. 5882            File_found=1
  5895. 5883            I=Num_files
  5896. 5884          END IF
  5897. 5885        END IF
  5898. 5886      NEXT I
  5899. 5887      IF NOT File_found THEN 
  5900. 5888        GOSUB Get_filename
  5901. 5889      END IF
  5902. 5890    UNTIL File_found>0
  5903. 5891    DISP 
  5904. 5892    SUBEXIT
  5905. 5893 Get_filename:!
  5906. 5894    DISP "File not found in catalog - please check name &  path, (blank to abort) "
  5907. 5895    OUTPUT KBD;F_path$&F$&F_msi$;" H";
  5908. 5896    ENTER KBD;Filename$
  5909. 5897    IF NOT LEN(TRIM$(Filename$)) THEN SUBEXIT
  5910. 5898    F$=Filename$
  5911. 5899    Parse_filename(F$,F_msi$,F_path$)
  5912. 5900    Filename$=F_path$&F$&F_msi$
  5913. 5901    RETURN 
  5914. 5902 !--------------------------------------
  5915. 5903 Gce_err: !
  5916. 5904    SELECT ERRN
  5917. 5905    CASE 53    ! improper file name
  5918. 5906      GOSUB Get_filename
  5919. 5907    CASE ELSE
  5920. 5908    END SELECT
  5921. 5909    File_found=0
  5922. 5910    RETURN 
  5923. 5911  SUBEND
  5924. 5912  !-----------------------------------------------------------------------
  5925. 5913 Prompt:SUB Prompt(Prompt$,Init$,Ans$,Flag)
  5926. 5914    DISP Prompt$
  5927. 5915    OUTPUT KBD;Init$;" H";
  5928. 5916    ENTER KBD;Ans$
  5929. 5917    DISP 
  5930. 5918    Ans$=TRIM$(UPC$(Ans$))
  5931. 5919    A_len=LEN(Ans$)
  5932. 5920    IF NOT A_len THEN Flag=0
  5933. 5921    IF A_len=1 AND Ans$="N" THEN Flag=0
  5934. 5922    IF A_len=1 AND Ans$="Y" THEN Flag=1
  5935. 5923    IF POS(Ans$,"YES") THEN Flag=1
  5936. 5924    IF POS(Ans$,"NO") THEN Flag=0
  5937. 5925  SUBEND
  5938. 5926  !------------------------------------------------------------------------
  5939. 5927 More:SUB More(Filename$,Pdev,Cmds$)
  5940. 5928   !
  5941. 5929    OPTION BASE 1
  5942. 5930    DIM Line$[256],Misc$[256],K$[256]
  5943. 5931    INTEGER Pline,Paging,Rc,File_type,Crt_lines,Print_abort
  5944. 5932 !-------------------------------------------------------
  5945. 5933    Sav_prt$=SYSTEM$("PRINTER IS")
  5946. 5934    PRINTER IS CRT
  5947. 5935    REPEAT
  5948. 5936      ASSIGN @File TO Filename$;FORMAT ON,RETURN Rc
  5949. 5937      IF (NOT LEN(Filename$)) OR (Rc) THEN 
  5950. 5938        BEEP 150,.1
  5951. 5939        DISP "Print Which File ?  - Blank to Exit"
  5952. 5940        OUTPUT KBD;Filename$;
  5953. 5941        ENTER KBD;Filename$
  5954. 5942        IF TRIM$(Filename$)="" THEN GOTO Exit_print
  5955. 5943      END IF
  5956. 5944    UNTIL NOT Rc
  5957. 5945    PRINT USING "/,5(K),/";Cmds$;" FILE: ";Filename$;"  To  Device: ";Pdev
  5958. 5946    ON ERROR GOTO Print_err
  5959. 5947    STATUS @File,1;File_type
  5960. 5948    ON END @File GOTO Exit_print
  5961. 5949    ON KBD,2 GOSUB Kbd_abort
  5962. 5950    DISP CHR$(129);"Space Bar: Pause/Continue   P: Toggle Paging     Esc: Quit";CHR$(128)
  5963. 5951    Print_wait=0
  5964. 5952    STATUS CRT,13;Crt_lines
  5965. 5953    Crt_lines=Crt_lines-7
  5966. 5954    Paging=1
  5967. 5955    One_line=0
  5968. 5956    !--------------------------------
  5969. 5957    LOOP
  5970. 5958      SELECT File_type
  5971. 5959      CASE 1       !
  5972. 5960      CASE 2       ! Bdat
  5973. 5961        ENTER @File;Line$
  5974. 5962      CASE 3       ! Ascii
  5975. 5963        ENTER @File;Line$
  5976. 5964      CASE 4       ! hp-ux
  5977. 5965        ENTER @File USING "#,K";Line$
  5978. 5966      END SELECT
  5979. 5967       !
  5980. 5968      Pline=Pline+1                       ! paging
  5981. 5969      IF Debug THEN DISP Pline,Crt_lines
  5982. 5970      IF Pdev=1 AND Paging=1 THEN 
  5983. 5971        IF Pline>=Crt_lines THEN 
  5984. 5972          OUTPUT KBD;" ";                ! simulate a "space bar press"
  5985. 5973          GOSUB Kbd_abort
  5986. 5974          Pline=1
  5987. 5975        END IF
  5988. 5976      END IF
  5989. 5977      !
  5990. 5978      IF Pdev>1 THEN 
  5991. 5979        OUTPUT Pdev;Line$                    ! to printer
  5992. 5980        DISP "printer: ",Pdev
  5993. 5981      END IF
  5994. 5982      !
  5995. 5983      IF POS(Line$," ") THEN                 ! avoid FF to screen
  5996. 5984        Line$[(POS(Line$," "));1]=" "
  5997. 5985      END IF
  5998. 5986      PRINT Line$
  5999. 5987      IF One_line THEN 
  6000. 5988        OUTPUT KBD;" ";
  6001. 5989        GOSUB Kbd_abort
  6002. 5990      END IF
  6003. 5991       !
  6004. 5992      WAIT Print_wait
  6005. 5993    EXIT IF Print_abort=1
  6006. 5994    END LOOP
  6007. 5995 Print_err:DISP ERRM$
  6008. 5996 Exit_print:!
  6009. 5997    OFF ERROR 
  6010. 5998    OFF KBD
  6011. 5999    ASSIGN @File TO *
  6012. 6000    PRINTER IS VAL(Sav_prt$)
  6013. 6001    DISP 
  6014. 6002    SUBEXIT
  6015. 6003 Kbd_abort:!       Routine to interrupt TYPE/PRINT of file
  6016. 6004    Misc$=SYSTEM$("KBD LINE")
  6017. 6005    K$=KBD$
  6018. 6006    CLEAR LINE        ! clear KBD LINE
  6019. 6007    One_line=0        ! clear single line mode
  6020. 6008 Ka_2:!
  6021. 6009    IF NOT LEN(K$) THEN K$=Misc$
  6022. 6010    K$=UPC$(K$)
  6023. 6011    Misc$=KBD$
  6024. 6012    ON KBD,3 GOTO Exit_abort
  6025. 6013    SELECT K$[1,1]
  6026. 6014    CASE " "
  6027. 6015      LOOP  ! wait here for next space bar
  6028. 6016      END LOOP
  6029. 6017    CASE ""                   !   =  Abort
  6030. 6018      Print_abort=1
  6031. 6019    CASE "P"                   ! P  =  Toggle Paging Breaks
  6032. 6020      IF Paging THEN 
  6033. 6021        Paging=0
  6034. 6022        DISP "paging off"
  6035. 6023      ELSE
  6036. 6024        Paging=1
  6037. 6025        DISP "paging on "
  6038. 6026      END IF
  6039. 6027      K$=" "
  6040. 6028      WAIT .1         ! dwell to lift finger
  6041. 6029    CASE " "
  6042. 6030      SELECT K$[2,2]
  6043. 6031      CASE "^"            ! faster
  6044. 6032        BEEP 300,.01
  6045. 6033        Print_wait=MAX(0,Print_wait-.1)
  6046. 6034      CASE "V"            ! slower
  6047. 6035        BEEP 300,.01
  6048. 6036        Print_wait=Print_wait+.1
  6049. 6037      CASE "E"                    ! <ENTER>  One Line Feed
  6050. 6038        One_line=1
  6051. 6039      END SELECT
  6052. 6040      IF Debug THEN DISP Print_wait
  6053. 6041    END SELECT
  6054. 6042 Exit_abort:ON KBD,2 GOSUB Kbd_abort
  6055. 6043    K$=KBD$
  6056. 6044    IF LEN(K$) THEN 
  6057. 6045      K$=UPC$(K$)
  6058. 6046      IF NOT (K$[1,1]=" ") THEN GOTO Ka_2
  6059. 6047    END IF
  6060. 6048    RETURN 
  6061. 6049  SUBEND
  6062. 6050  !=====================  END OF HPKERMIT
  6063. 6056  SUB Clear
  6064. 6057    Shutdown
  6065. 6058    Startup
  6066. 6059  SUBEND
  6067. 6060  !------------------------------------------------------------------------
  6068. 6061  ! End of PROG File Code -
  6069. 6062  ! IF BASIC Source Code is appended after this comment block
  6070. 6063  ! it has been done so that a DOS Text version of the Program
  6071. 6064  ! could be created. Source Code is included in the "HPBMISC" File
  6072. 6065  !
  6073. 6066  ! The PROG File contains the Compiled CSUBS and will perform better
  6074. 6067  ! Performance is improved 4X by Compiling the following three
  6075. 6068  ! Subprograms:
  6076. 6069  !
  6077. 6070  ! Decode_pack
  6078. 6071  ! Encode_pack
  6079. 6072  ! Spack
  6080. 6073  !
  6081. 6074  ! LOADSUB Decode_pack FROM "HPBMISC"
  6082. 6075  ! LOADSUB Encode_pack FROM "HPBMISC"
  6083. 6076  ! LOADSUB Spack FROM "HPBMISC"
  6084. 6077  !-------------------------------------------------------------------------
  6085. 6080  SUB Decode_pack(Rdata$,INTEGER Quote,Qbin,Rep_ch)
  6086. 6081 Decode_pack: !
  6087. 6082 Dp: !
  6088. 6083  !
  6089. 6084  ! Receive Rdata$ (Kermit Packet)
  6090. 6085  ! Decode all &,#,~ and stuff results into Rdata$
  6091. 6086  !
  6092. 6087    INTEGER B,P,Stuff,Qon,Biton,Reps
  6093. 6088  !
  6094. 6089    ALLOCATE File_buff$[100]            ! use file_buff$ as a local here
  6095. 6090  !------------------------------------------------------------------
  6096. 6091    P=1
  6097. 6092    FOR B=1 TO LEN(Rdata$)
  6098. 6093      Stuff$=Rdata$[B,B]             ! get next  byte
  6099. 6094      Stuff=NUM(Stuff$)
  6100. 6095      IF Debug THEN DISP "P= ";P,"B= ";B,Stuff$,File_buff$[1,P]
  6101. 6096      SELECT Stuff
  6102. 6097      CASE Quote                          ! Control Quoting #
  6103. 6098        IF Qon=1 THEN 
  6104. 6099          IF (NOT Biton) THEN 
  6105. 6100            File_buff$[P,P]=Stuff$              ! ## = #
  6106. 6101          ELSE
  6107. 6102            File_buff$[P,P]=CHR$(Stuff+128)      ! &## = '#
  6108. 6103            Biton=0
  6109. 6104          END IF
  6110. 6105          P=P+1
  6111. 6106          Qon=0
  6112. 6107        ELSE
  6113. 6108          Qon=1
  6114. 6109        END IF
  6115. 6110      CASE Qbin                   ! 8 bit prefix  &    (Biton)
  6116. 6111        IF Qon=1 THEN 
  6117. 6112          IF Biton=1 THEN 
  6118. 6113            File_buff$[P,P]=CHR$(Stuff+128)     ! &#& = '&
  6119. 6114            P=P+1
  6120. 6115            Biton=0
  6121. 6116          ELSE
  6122. 6117            File_buff$[P,P]=Stuff$              ! #& = &
  6123. 6118            P=P+1
  6124. 6119          END IF
  6125. 6120          Qon=0
  6126. 6121        ELSE
  6127. 6122          Biton=1
  6128. 6123        END IF
  6129. 6124      CASE Rep_ch                 ! Repeat Processing  ~
  6130. 6125        IF (NOT Qon) AND (NOT Biton) THEN 
  6131. 6126          BEEP 
  6132. 6127          DISP "Repeat Process";Rdata$[B-1;4]
  6133. 6128          B=B+1
  6134. 6129          Reps=FNUnchar(Rdata$[B,B])           ! number of repeats this char
  6135. 6130          B=B+1
  6136. 6131          IF NUM(Rdata$[B,B])=Quote THEN             ! ~#()
  6137. 6132            Qon=1
  6138. 6133            B=B+1
  6139. 6134          END IF
  6140. 6135           !
  6141. 6136          IF NUM(Rdata$[B,B])=Qbin THEN              ! ~&()
  6142. 6137            Biton=1
  6143. 6138            B=B+1
  6144. 6139          END IF
  6145. 6140           !
  6146. 6141          Ch2rep=NUM(Rdata$[B,B])                 ! Char to Repeat
  6147. 6142          IF Qon THEN Ch2rep=Ch2rep-64
  6148. 6143          IF Biton THEN Ch2rep=Ch2rep+128
  6149. 6144          Ch2rep$=CHR$(Ch2rep)
  6150. 6145          File_buff$[P;Reps]=RPT$(Ch2rep$,Reps)
  6151. 6146          P=P+Reps
  6152. 6147        ELSE        ! #~
  6153. 6148          IF Biton THEN Stuff=Stuff+128
  6154. 6149          IF Qon THEN Stuff=Stuff-64
  6155. 6150          File_buff$[P,P]=CHR$(Stuff)
  6156. 6151          P=P+1
  6157. 6152        END IF
  6158. 6153             !
  6159. 6154      CASE 32 TO 127               ! printable characters
  6160. 6155        IF (Qon) AND (Biton) THEN                 ! &#()  Binary File
  6161. 6156          File_buff$[P,P]=CHR$(FNCtl(Stuff$)+128)
  6162. 6157          P=P+1
  6163. 6158        END IF
  6164. 6159               !
  6165. 6160        IF (Biton) AND (NOT Qon) THEN             ! &
  6166. 6161          File_buff$[P,P]=CHR$(NUM(Stuff$)+128)
  6167. 6162          P=P+1
  6168. 6163        END IF
  6169. 6164              !
  6170. 6165        IF (Qon) AND (NOT Biton) THEN             ! #
  6171. 6166          File_buff$[P,P]=CHR$(FNCtl(Stuff$))
  6172. 6167          P=P+1
  6173. 6168        END IF
  6174. 6169        IF (NOT Qon) AND (NOT Biton) THEN           ! normal char
  6175. 6170          File_buff$[P,P]=Stuff$
  6176. 6171          P=P+1
  6177. 6172        END IF
  6178. 6173           !
  6179. 6174        Qon=0
  6180. 6175        Biton=0
  6181. 6176           !
  6182. 6177      CASE 128 TO 255
  6183. 6178        PRINT TABXY(25,12);"Invalid Char: Extended Ascii # ";Stuff
  6184. 6179      END SELECT
  6185. 6180    NEXT B
  6186. 6181    Rdata$=File_buff$
  6187. 6182  SUBEND
  6188. 6183  !------------------------------------------------------------------------
  6189. 6190  SUB Encode_pack(File_buff$,Packet$,INTEGER Myquote,Qbin,Rep_ch,Spsiz)
  6190. 6191 Encode_pack_s: !
  6191. 6192 Ep: !
  6192. 6193  !
  6193. 6194    DIM Stuff$[1],Myquote$[1],Qbin$[1]
  6194. 6195    INTEGER Pack_full,P,B,Sdata_done,Bl
  6195. 6196  !
  6196. 6197    Myquote$=CHR$(Myquote)
  6197. 6198    Qbin$=CHR$(Qbin)
  6198. 6199    Bl=LEN(File_buff$)
  6199. 6200    Pack_full=0
  6200. 6201    P=1
  6201. 6202    B=1
  6202. 6203  !------------------------------------------------------
  6203. 6204    REPEAT                           ! Until Pack_full=1
  6204. 6205 Stuff:Stuff$=File_buff$[B,B]
  6205. 6206      Stuff=NUM(Stuff$)
  6206. 6207      SELECT Stuff
  6207. 6208      CASE 0 TO 31,127 TO 255,Myquote,Qbin          ! ,Rep_ch !add quoting
  6208. 6209        SELECT Stuff
  6209. 6210        CASE 0 TO 31                               ! # Prefix.  (38=& 35=#)
  6210. 6211          Packet$[P;2]=Myquote$&CHR$(FNCtl(Stuff$))
  6211. 6212          P=P+2
  6212. 6213        CASE Myquote,Qbin
  6213. 6214          Packet$[P;2]=Myquote$&Stuff$
  6214. 6215          P=P+2
  6215. 6216        CASE 127              ! #?
  6216. 6217          Packet$[P;2]=Myquote$&CHR$(Stuff-64)
  6217. 6218          P=P+2
  6218. 6219        CASE 128 TO 159                       ! &# prefixing
  6219. 6220          Packet$[P;3]=Qbin$&Myquote$&CHR$(Stuff-64)
  6220. 6221          P=P+3
  6221. 6222        CASE 128+35,128+38
  6222. 6223          Packet$[P;3]=Qbin$&Myquote$&CHR$(Stuff)
  6223. 6224          P=P+3
  6224. 6225        CASE 160 TO 254                       ! & Prefixing
  6225. 6226          Packet$[P;2]=Qbin$&CHR$(Stuff-128)
  6226. 6227          P=P+2
  6227. 6228        CASE 255              ! &#?
  6228. 6229          Packet$[P;3]=Qbin$&Myquote$&"?"
  6229. 6230          P=P+3
  6230. 6231        END SELECT
  6231. 6232      CASE ELSE           ! printable -  no quoting is needed
  6232. 6233        Packet$[P,P]=Stuff$
  6233. 6234        P=P+1
  6234. 6235      END SELECT
  6235. 6236     !
  6236. 6237      IF P>=Spsiz-4 THEN Pack_full=1
  6237. 6238   !  IF At_eof AND B=Bl THEN
  6238. 6239      IF B=Bl THEN 
  6239. 6240        Pack_full=1
  6240. 6241      END IF
  6241. 6242      B=B+1
  6242. 6243    UNTIL Pack_full
  6243. 6244     !
  6244. 6245    File_buff$=File_buff$[B]                  ! truncate
  6245. 6246    B=1
  6246. 6247  SUBEND
  6247. 6248  !------------------------------------------------------------------------
  6248. 6250 Spack:SUB Spack(Packet$,Pkt$,INTEGER Npak,Sndpkt$)
  6249. 6251 Sspack: ! Form Send Packet Contents from Packet$ data
  6250. 6252         ! IN
  6251. 6253         !  Packet$[],Pkt$,Npak
  6252. 6254         ! OUT
  6253. 6255         !  Sndpkt$[]
  6254. 6256    INTEGER Plen,Cchksum
  6255. 6257    Sndpkt$=""
  6256. 6258    Dlen=LEN(Packet$)
  6257. 6259    Plen=LEN(Packet$)+3
  6258. 6260    Ckpos=Plen+2
  6259. 6261    Sndpkt$[1;1]=""             ! packet mark  ^A
  6260. 6262    Sndpkt$[2;1]=FNTochar$(Plen)   ! length
  6261. 6263    Sndpkt$[3;1]=FNTochar$(Npak MOD 64)      ! packet sequence
  6262. 6264    Sndpkt$[4;1]=Pkt$            ! packet type
  6263. 6265    Sndpkt$[5;LEN(Packet$)]=Packet$  ! Stuff Data
  6264. 6266    Chk=0
  6265. 6267    FOR Ch=2 TO Plen+1
  6266. 6268      Chk=Chk+NUM(Sndpkt$[Ch,Ch])
  6267. 6269    NEXT Ch
  6268. 6270    Cchksum=BINAND(Chk+(BINAND(Chk,192)/64),63)   ! Computed Checksum
  6269. 6271    Sndpkt$[Ckpos;1]=FNTochar$(Cchksum)
  6270. 6272   !
  6271. 6273   ! fLUSH bUFFER hERE ???
  6272. 6274   !
  6273. 6275  SUBEND
  6274. 6276  !=======================================================================
  6275.