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

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