rify.mud 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <DEFINE RIFY (OUTF "TUPLE" INFS "AUX" IN OUT BUF TERM CHAR CNT FLAG "NAME" RTN)
  2. #DECL((OUTF) STRING
  3. (TUP) <TUPLE <REST STRING>>
  4. (IN OUT) <OR CHANNEL FALSE>
  5. (BUF TERM) STRING
  6. (CHAR) CHARACTER
  7. (CNT FLAG) FIX)
  8. <SET FLAG 0>
  9. <COND (<SET OUT <OPEN "READ" .OUTF>>
  10. <CLOSE .OUT>
  11. <RETURN "Output file exists" .RTN>)
  12. (<SET OUT <OPEN "PRINT" .OUTF>>)
  13. (T
  14. <RETURN "Can't open output file" .RTN>)>
  15. <SET BUF <ISTRING 200 #CHARACTER 0>>
  16. <SET TERM <STRING #CHARACTER 13 #CHARACTER 12 #CHARACTER 92>>
  17. <REPEAT ()
  18. <COND (<EMPTY? .INFS>
  19. <RETURN>)
  20. (<SET IN <OPEN "READ" <1 .INFS>>>
  21. <COND (<0? .FLAG>
  22. <PRINC ".dv xgp
  23. .fo 0 fonts;20fg kst
  24. .nr verbose 1
  25. .nr print_page1_headings 1
  26. " .OUT>
  27. <PRINC <STRING ".sr right_heading " <1 .INFS>> .OUT>
  28. <PRINC "
  29. .so r;r macros
  30. .nf
  31. " .OUT>)
  32. (T
  33. <PRINC <STRING ".sr right_heading " <1 .INFS>> .OUT>
  34. <PRINC "
  35. .bp
  36. " .OUT>)>
  37. <PRINC ".keep
  38. " .OUT>
  39. <SET INFS <REST .INFS>>
  40. <SET FLAG 1>
  41. <REPEAT ()
  42. <SET CNT <READSTRING .BUF .IN .TERM '<RETURN>>>
  43. <PRINTSTRING .BUF .OUT .CNT>
  44. <COND (<==? <SET CHAR <READCHR .IN #CHARACTER 0>> #CHARACTER 13>
  45. <READCHR .IN <>>
  46. <TERPRI .OUT>)
  47. (<==? .CHAR #CHARACTER 92>
  48. <PRINC "\\" .OUT>)
  49. (<==? .CHAR #CHARACTER 0>
  50. <PRINC "..
  51. .end_keep
  52. " .OUT>
  53. <OR <EMPTY? .INFS>
  54. <PRINC ".keep
  55. " .OUT>>
  56. <RETURN>)>
  57. <COND (<OR <AND <G? .CNT 4>
  58. <=? <SUBSTRUC .BUF 0 5> " end ">>
  59. <AND <G? .CNT 2>
  60. <OR <=? <SUBSTRUC .BUF 0 3> "end">
  61. <=? <SUBSTRUC .BUF 0 3> "END">>>>
  62. <PRINC "..
  63. .end_keep
  64. " .OUT>
  65. <REPEAT ()
  66. <COND (<==? <SET CHAR <NEXTCHR .IN #CHARACTER 0>>
  67. #CHARACTER 13>
  68. <READCHR .IN>
  69. <READCHR .IN <>>
  70. <TERPRI .OUT>)
  71. (<==? .CHAR #CHARACTER 12>
  72. <READCHR .IN>)
  73. (T <RETURN>)>>
  74. <COND (<==? .CHAR #CHARACTER 0>
  75. <RETURN>)>
  76. <AND <==? <NTH .BUF 1> !\e>
  77. <PRINC ".bp
  78. " .OUT>>
  79. <PRINC ".keep
  80. " .OUT>)>>)
  81. (T
  82. <PRINC <STRING "Couldn't open " <1 .INFS> #CHARACTER 13>>
  83. <SET INFS <REST .INFS>>)>>
  84. <CLOSE .OUT>
  85. "DONE">