home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ccdos / ccbpcb.bas < prev    next >
BASIC Source File  |  2020-01-01  |  3KB  |  86 lines

  1. 1    'Run this program on the PC in conjunction with a Fortran program
  2. 2    '(CCBOOT.FOR) on the mainframe to download Kermit to the PC.  This
  3. 3    'program will run for about thirty minutes, depending on line speed.
  4. 4    ' Bill Catchings, June 1984 (Revised Sept 1984)
  5. 5    ' Columbia University Center for Computing Activities
  6.  
  7. 6    ' This program is converted from MSBPCB.BAS
  8. 7    ' Quanfang Zhang, July 1991 
  9. 8    ' Zhejiang University, P.R.China
  10.  
  11. 10   t$ = time$                ' Save the time.
  12. 20   defint a-z                ' All integer to gain some speed.
  13. 30   n$ = chr$(0)
  14. 40   z = asc("0")
  15. 50   t = asc("~")-z
  16. 60   def fnuchr%(a$)=asc(a$)-z
  17. 70   open "com1:9600,s,7,1,cs,ds,cd" as #1
  18.  
  19. 100  print#1,"O ,2"            ' Char constants "O", " " and ","
  20. 110  input#1,f$
  21. 120  if len(f$) < 5 then goto 110    ' In case the host echos the ACK.
  22. 130  input#1,n
  23. 135 print f$+" "+str$(n)
  24. 140  if n > 20 then goto 900
  25. 150  open f$ for output as #2
  26. 160  print "Outputting to "+f$
  27. 170  goto 300                ' Correct version of the file.
  28.  
  29. 200  gosub 1000                ' Do turnaround char processing
  30. 210  print#1,"NO"            ' Tell host data was incorrect.
  31. 220  goto 320
  32.  
  33. 300  gosub 1000                ' Do turnaround char processing
  34. 310  print#1,"OK"            ' Say the line was all right.
  35. 320  input#1,x$
  36. 330  if len(x$) < 5 then goto 320    ' In case the host echos ACK/NAK
  37. 340  input#1,n
  38. 345 print x$+" "+str$(n)
  39. 350  if len(x$) <> n then goto 200    ' Length doesn't match, NAK it.
  40. 360  if x$ = "&&&&&&&&&&" then goto 800    ' End of file?
  41. 370  y$ = ""                ' Set output string to null.
  42. 380  goto 500
  43.  
  44. 400  print#2,y$;            ' Print the output string.
  45. 410  goto 300                ' Go get another line.
  46.  
  47. 500  if len(x$) = 0 goto 400        ' Done with input string?
  48. 510  a = fnuchr%(x$)
  49. 520  if a = t then goto 700        ' Null repeat character?
  50. 530  q$=mid$(x$,2,3)            ' Get the quadruplet to decode.
  51. 540  x$=mid$(x$,5)
  52. 550  b = fnuchr%(q$)
  53. 560  q$ = mid$(q$,2)
  54. 570  c = fnuchr%(q$)
  55. 580  q$ = mid$(q$,2)
  56. 590  d = fnuchr%(q$)
  57.  
  58. 600  y$ = y$ + chr$(((a * 4) + (b \ 16)) and 255) ' Decode the quad.
  59. 610  y$ = y$ + chr$(((b * 16) + (c \ 4)) and 255)
  60. 620  y$ = y$ + chr$(((c * 64) + d) and 255)
  61. 630  goto 500                ' Get another quad.
  62.     
  63. 700  x$ = mid$(x$,2)            ' Expand nulls.
  64. 710  r = fnuchr%(x$)            ' Get the number of nulls.
  65. 715 print " Null: ",r
  66. 720  x$ = mid$(x$,2)
  67. 730   for i=1 to r            ' Loop, adding nulls to string.
  68. 740   y$ = y$ + n$
  69. 750   next
  70. 760  print#2,y$;            ' Print the nulls.
  71. 770  y$ = ""                ' Clear the output buffer.
  72. 780  goto 500
  73.  
  74. 800  print "Processing complete, elapsed time: "+t$+" to "+time$
  75. 810  print "Output in "+f$
  76. 820  close #1,#2
  77. 830  goto 9999
  78.  
  79. 900  print "?The format of the BOO file is incorrect"
  80. 910  goto 820
  81.  
  82. 1000 x$ = input$(1,#1)        ' Make this line RETURN for full-duplex
  83. 1010 if x$ <> chr$(17) then goto 1000    ' Loop for a turn around char.
  84. 1020 return
  85.  
  86. 9999 end