home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3578 < prev    next >
Encoding:
Text File  |  1991-07-03  |  20.1 KB  |  735 lines

  1. Newsgroups: alt.sources
  2. From: goer@ellis.uchicago.edu (Richard L. Goerwitz)
  3. Subject: kjv browser, part 2 of 11
  4. Message-ID: <1991Jul3.064929.27914@midway.uchicago.edu>
  5. Date: Wed, 3 Jul 1991 06:49:29 GMT
  6.  
  7. ---- Cut Here and feed the following to sh ----
  8. #!/bin/sh
  9. # this is bibleref.02 (part 2 of a multipart archive)
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file listutil.icn continued
  12. #
  13. if test ! -r _shar_seq_.tmp; then
  14.     echo 'Please unpack part 1 first!'
  15.     exit 1
  16. fi
  17. (read Scheck
  18.  if test "$Scheck" != 2; then
  19.     echo Please unpack part "$Scheck" next!
  20.     exit 1
  21.  else
  22.     exit 0
  23.  fi
  24. ) < _shar_seq_.tmp || exit 1
  25. if test ! -f _shar_wnt_.tmp; then
  26.     echo 'x - still skipping listutil.icn'
  27. else
  28. echo 'x - continuing file listutil.icn'
  29. sed 's/^X//' << 'SHAR_EOF' >> 'listutil.icn' &&
  30. X#
  31. X#      writelist(), which writes a bitmap list in human readable form
  32. X#          to a file.
  33. X#
  34. X############################################################################
  35. X#
  36. X#  Links: ./rewrap.icn (also uses push_shell(), which is in ./passutil.icn)
  37. X#
  38. X############################################################################
  39. X
  40. X# Declared in bibleref.icn.
  41. X# record lst(l,pos,old_n,s)
  42. X
  43. X
  44. Xprocedure display_list()
  45. X
  46. X    #
  47. X    #  Display a retrieved "hit list."
  48. X    #
  49. X    local passage, subscr
  50. X
  51. X    #
  52. X    # We're in the midst of a scanning expression in the main
  53. X    # command loop.  If the "d" command was given with no arguments,
  54. X    # then default to the last list retrieved.
  55. X    #
  56. X    if pos(0) then {
  57. X    subscr := (0 ~= *lists) | {
  58. X        err_message("No lists have been created yet.")
  59. X        fail
  60. X    }
  61. X    }
  62. X    #
  63. X    # If we are not at pos(0) then we are to go to a specific list
  64. X    # in the list history.
  65. X    #
  66. X    else {
  67. X    if not {
  68. X        tab(upto('-+' ++ &digits)) &
  69. X        subscr := integer(tab(many('-+' ++ &digits))) &
  70. X        pos(0)
  71. X    }
  72. X    # If we don't have an integer, then the user has screwed
  73. X    # up somehow.
  74. X    then {
  75. X        err_message("Garbage characters after \"d\" command.")
  76. X        fail
  77. X    }
  78. X    # Check to be sure the subscript give is in range.
  79. X    lists[subscr] | {
  80. X        err_message("There is no list number "||subscr||".")
  81. X        fail
  82. X    }
  83. X    }
  84. X
  85. X    #
  86. X    # While listlist gives us a valid passage reference, display it.
  87. X    # When it returns &null or fails, quit.
  88. X    #
  89. X    repeat {
  90. X
  91. X        # Display the list (defaults above to the last list in the list
  92. X        # history).  Use listlist().  Arg 1 is the lst record, which
  93. X        # contains a list and a position to start viewing that list at.
  94. X        # The second arg to listlist tells the user the length of the
  95. X        # list.  The last arg specifies how many display columns we can
  96. X        # eat up before truncating.
  97. X     passage := listlist(lists[subscr],
  98. X                "list length = "||*lists[subscr].l,
  99. X                getval("co")-10)  |  fail
  100. X    if /passage then return
  101. X    else display_passage(passage)
  102. X    }
  103. Xend
  104. X
  105. X
  106. X
  107. Xprocedure listlist(lst_rec, msg, width)
  108. X
  109. X    local l, i, ss, j, n, prompt, rsp, rsp2
  110. X    static lines
  111. X    initial lines := getval("li")-3
  112. X
  113. X    # "l" is a record of type lst, containing the list to print
  114. X    # "msg" is the message to put on the status line
  115. X    # "width" gives the length to which lines in l are truncated
  116. X    # "offset" gives the starting offset in l at which to begin
  117. X    #    printing (default 0).
  118. X
  119. X    l := lst_rec.l
  120. X
  121. X    repeat {
  122. X    i := 0
  123. X    while *l >= (ss := lst_rec.pos + (lines > (i +:= 1))) do {
  124. X        iputs(igoto(getval("cm"), 1, i))
  125. X        normal(); iputs(getval("ce"))
  126. X        writes(" ", left(ss||".",7))
  127. X        if ss = \lst_rec.old_n then {
  128. X        # Boldface last viewed passage from this list.
  129. X        boldface(); writes(convertb(l[ss], kjv_filename)[1:\width|0])
  130. X        normal()
  131. X        } else writes(convertb(l[ss], kjv_filename)[1:\width|0])
  132. X    }
  133. X
  134. X    # If we haven't reached the end of the displayable screen,
  135. X    # then clear lines until we reach it...
  136. X    if i-1 ~= lines+1 then {
  137. X        every j := i to lines+1 do {
  138. X        iputs(igoto(getval("cm"), 1, j))
  139. X        normal(); iputs(getval("ce"))
  140. X        }
  141. X    }
  142. X    # Display message on status line.
  143. X    status_line("-- " || \msg || " --" | "", "", "c")
  144. X
  145. X    # If we're to the end of the screen, and there's still more to
  146. X    # display, then...
  147. X    if *l > lines & (lst_rec.pos+i) ~= (*l+1) then {
  148. X        rsp :=
  149. X        snarf_input("Press !/a/b/c/m/n/p/s/v/w (q = quit viewing):  ")
  150. X        case map(rsp) of {
  151. X        "!"    : push_shell()
  152. X        "a"    : write_list(l, "append")
  153. X        "b"    : lst_rec.pos := (0 < lst_rec.pos-lines+1) | 0
  154. X        "c"    : next            
  155. X        "m"|"" : (lst_rec.pos := (*l > (lst_rec.pos+i-1)))
  156. X        "n"    : {
  157. X            n := \lst_rec.old_n+1 | {
  158. X            err_message("Type \"v\" to set the current passage.")
  159. X            next
  160. X            }
  161. X            if 0 < n <= *l then {
  162. X            if not (lst_rec.pos < n < lst_rec.pos+lines)
  163. X            then lst_rec.pos := (0 < n-2) | n-1
  164. X            lst_rec.old_n := n & (return l[n])
  165. X            } else err_message("Out of range.")
  166. X        }            
  167. X        "p"    : {
  168. X            n := \lst_rec.old_n-1 | {
  169. X            err_message("Type \"v\" to set the current passage.")
  170. X            next
  171. X            }
  172. X            if 0 < n <= *l then {
  173. X            if not (lst_rec.pos < n < lst_rec.pos+lines)
  174. X            then lst_rec.pos := (0 < n-2) | n-1
  175. X            lst_rec.old_n := n & (return l[n])
  176. X            } else err_message("Out of range.")
  177. X        }            
  178. X        "q"    : break
  179. X        "s"    : {
  180. X            l := (lst_rec.l := sort(lst_rec.l))
  181. X            lst_rec.old_n := &null
  182. X        }
  183. X        "v"    : {
  184. X            rsp2 := snarf_input("View which passage:  ")
  185. X            rsp2 == (""|"q") & next
  186. X            if n := integer(rsp2) then {
  187. X            if 0 < n <= *l then {
  188. X                if not (lst_rec.pos < n < lst_rec.pos+lines)
  189. X                then lst_rec.pos := (0 < n-2) | n-1
  190. X                lst_rec.old_n := n
  191. X                return l[n]
  192. X            } else err_message("Out of range.")
  193. X            } else err_message("Invalid passage number.")
  194. X        }
  195. X        "w"    : write_list(l)
  196. X        default : {
  197. X            if n := integer(rsp)-1 then {
  198. X            if 0 <= n < *l
  199. X            then lst_rec.pos := n
  200. X            else err_message("Out of range.")
  201. X            } else err_message("Invalid command.")
  202. X        }
  203. X        }
  204. X    }
  205. X    # ...otherwise, we've displayed everything.
  206. X    else {
  207. X        prompt := "c/n/p/s/v/w (q to go to previous menu):  "
  208. X        if *l <= lines
  209. X        then rsp:= snarf_input("Press !/a/" || prompt) | next
  210. X        else rsp :=    snarf_input("Press !/a/b/" || prompt) | next
  211. X        case map(rsp) of {
  212. X        "!"    : push_shell()
  213. X        "a"    : write_list(l,"append")
  214. X        "b"    : lst_rec.pos := (0 < lst_rec.pos-lines+1) | 0
  215. X        "c"|"" : next
  216. X        "m"    : next    # no more to display; just stay were we are
  217. X        "n"    : {
  218. X            n := \lst_rec.old_n+1 | {
  219. X            err_message("No passage viewed yet from this list.")
  220. X            next
  221. X            }
  222. X            if 0 < n <= *l then {
  223. X            lst_rec.old_n := n & (return l[n])
  224. X            if not (lst_rec.pos < n < lst_rec.pos+lines)
  225. X            then lst_rec.pos := (0 < n-2) | n-1
  226. X            } else err_message("Out of range.")
  227. X        }            
  228. X        "p"    : {
  229. X            n := \lst_rec.old_n-1 | {
  230. X            err_message("No passage viewed yet from this list.")
  231. X            next
  232. X            }
  233. X            if 0 < n <= *l then {
  234. X            lst_rec.old_n := n & (return l[n])
  235. X            if not (lst_rec.pos < n < lst_rec.pos+lines)
  236. X            then lst_rec.pos := (0 < n-2) | n-1
  237. X            } else err_message("Out of range.")
  238. X        }            
  239. X        "q"    : break
  240. X        "s"    : {
  241. X            l := (lst_rec.l := sort(lst_rec.l))
  242. X            lst_rec.old_n := &null
  243. X        }
  244. X        "v"    : {
  245. X            rsp2 := snarf_input("View which passage:  ")
  246. X            rsp2 == (""|"q") & next
  247. X            if n := integer(rsp2) then {
  248. X            if 0 < n <= *l then {
  249. X                if not (lst_rec.pos < n < lst_rec.pos+lines)
  250. X                then lst_rec.pos := (0 < n-2) | n-1
  251. X                lst_rec.old_n := n
  252. X                return l[n]
  253. X            } else err_message("Out of range.")
  254. X            } else err_message("Invalid passage number.")
  255. X        }
  256. X        "w"    : write_list(l)
  257. X        default : {
  258. X            if n := integer(rsp)-1 then {
  259. X            if 0 <= n < *l
  260. X            then lst_rec.pos := n
  261. X            else err_message("Out of range.")
  262. X            } else {
  263. X            err_message("Invalid command.")
  264. X            }
  265. X        }
  266. X        }
  267. X    }
  268. X    }
  269. X    return
  270. X
  271. Xend
  272. X
  273. X
  274. X
  275. Xprocedure write_list(l, switch)
  276. X
  277. X    #
  278. X    # Used for writing the contents of a displayed list to a file.
  279. X    #
  280. X    local fname, outtext, i
  281. X
  282. X    # Get straight whether we are appending or clobbering.
  283. X    (/switch := "a") | (switch := "w")
  284. X
  285. X    until \outtext do {
  286. X    fname := snarf_input("Enter filename (! for shell; q to quit):  ")
  287. X    case fname of {
  288. X        ""   : fail
  289. X        "!"  : push_shell() & initialize_screen()
  290. X        "q"  : fail
  291. X        default : {
  292. X        outtext := open(fname, switch) | {
  293. X            case switch of {
  294. X            "a" : err_message("Can't append to " || fname || ".")
  295. X            "w" : err_message("Cannot write to " || fname || ".")
  296. X            default : quit("write_passage", "internal error", 80) 
  297. X            }
  298. X        }
  299. X        }
  300. X    }
  301. X    }
  302. X    message("Writing.")
  303. X    every i := 1 to *l do
  304. X    write(outtext, " ", left(i||".",7), convertb(l[i], kjv_filename))
  305. X    close(outtext)
  306. X    message("Done.")
  307. X    return
  308. X
  309. Xend
  310. X
  311. X
  312. X
  313. Xprocedure show_lists()
  314. X
  315. X    #
  316. X    # Display stats for all generated lists.  So far the only routine
  317. X    # that can generate lists is search_database().  Every time it
  318. X    # generates a list, it inserts that list into the global list,
  319. X    # lists (declared and initialized in bibleref.icn).
  320. X    #
  321. X    local expanded_list, i, result
  322. X    
  323. X    #
  324. X    # We're in the midst of a scanning expression in the main
  325. X    # command loop.  If the "l" command was given with no arguments,
  326. X    # then default to the last list retrieved.
  327. X    #
  328. X    if not pos(0) then {
  329. X    err_message("Garbage characters after \"l\" command.")
  330. X    fail
  331. X    }
  332. X    *lists = 0 & {
  333. X    err_message("No lists in memory.")
  334. X    fail
  335. X    }
  336. X
  337. X    repeat {
  338. X    result :=
  339. X        listlistS(lists, "list of viewable lists", getval("co")-10) | fail
  340. X    if /result
  341. X    then return
  342. X    else result ? display_list()
  343. X    }
  344. Xend
  345. X
  346. X
  347. X
  348. Xprocedure listlistS(all_lists, msg, width)
  349. X
  350. X    local l, offset, i, ss, j, n, prompt, rsp, rsp2
  351. X    static lines
  352. X    initial lines := getval("li")-3
  353. X
  354. X    # "all_lists" is a list of records of type lst
  355. X    # "msg" is the message to put on the status line
  356. X    # "width" gives the length to which lines in l are truncated
  357. X
  358. X    l := all_lists
  359. X
  360. X    offset := 0
  361. X    repeat {
  362. X    i := 0
  363. X    while *l >= (ss := offset + (lines > (i +:= 1))) do {
  364. X        iputs(igoto(getval("cm"), 1, i))
  365. X        normal(); iputs(getval("ce"))
  366. X        writes(" ", left(ss||".",5))
  367. X        writes("length = " || *l[i].l || ", search pattern = " || l[i].s)
  368. X    }
  369. X
  370. X    # If we haven't reached the end of the displayable screen,
  371. X    # then clear lines until we reach it...
  372. X    if i-1 ~= lines+1 then {
  373. X        every j := i to lines+1 do {
  374. X        iputs(igoto(getval("cm"), 1, j))
  375. X        normal(); iputs(getval("ce"))
  376. X        }
  377. X    }
  378. X    # Display message on status line.
  379. X    status_line("-- " || \msg || " --" | "", "", "c")
  380. X
  381. X    # If we're to the end of the screen, and there's still more to
  382. X    # display, then...
  383. X    if *l > lines & (offset+i) ~= (*l+1) then {
  384. X        rsp := snarf_input("Press !/b/c/m/v (q = quit viewing):  ")
  385. X        case map(rsp) of {
  386. X        "!"    : push_shell()
  387. X        "b"    : offset := (0 < offset-lines+1) | 0
  388. X        "c"    : next            
  389. X        "m"|"" : (offset := (*l > (offset+i-1)))
  390. X        "q"    : break
  391. X        "v"    : {
  392. X            rsp2 := snarf_input("View which list:  ")
  393. X            rsp2 == (""|"q") & next
  394. X            if n := integer(rsp2) then {
  395. X            if 0 < n <= *l
  396. X            then return n
  397. X            else err_message("Out of range.")
  398. X            }
  399. X            else err_message("Invalid passage number.")
  400. X        }
  401. X        default : {
  402. X            err_message("Command invalid in this context.")
  403. X        }
  404. X        }
  405. X    }
  406. X    # ...otherwise, we've displayed everything.
  407. X    else {
  408. X        prompt := "c/v (q to go to previous menu):  "
  409. X        if *l <= lines
  410. X        then rsp:= snarf_input("Press !/" || prompt) | next
  411. X        else rsp :=    snarf_input("Press !/b/" || prompt) | next
  412. X        case map(rsp) of {
  413. X        "!"    : push_shell()
  414. X        "b"    : offset := (0 < offset-lines+1) | 0
  415. X        "c"|"" : next
  416. X        "m"    : next    # no more to display; just stay were we are
  417. X        "q"    : break
  418. X        "v"    : {
  419. X            rsp2 := snarf_input("View which list:  ")
  420. X            rsp2 == (""|"q") & next
  421. X            if n := integer(rsp2) then {
  422. X            if 0 < n <= *l
  423. X            then return n
  424. X            else err_message("Out of range.")
  425. X            }
  426. X            else err_message("Invalid passage number.")
  427. X        }
  428. X        default : {
  429. X            err_message("Command invalid in this context.")
  430. X        }
  431. X        }
  432. X    }
  433. X    }
  434. X    return
  435. X
  436. Xend
  437. X
  438. SHAR_EOF
  439. echo 'File listutil.icn is complete' &&
  440. true || echo 'restore of listutil.icn failed'
  441. rm -f _shar_wnt_.tmp
  442. fi
  443. # ============= passutil.icn ==============
  444. if test -f 'passutil.icn' -a X"$1" != X"-c"; then
  445.     echo 'x - skipping passutil.icn (File already exists)'
  446.     rm -f _shar_wnt_.tmp
  447. else
  448. > _shar_wnt_.tmp
  449. echo 'x - extracting passutil.icn (Text)'
  450. sed 's/^X//' << 'SHAR_EOF' > 'passutil.icn' &&
  451. X############################################################################
  452. X#
  453. X#    Name:     1.9
  454. X#
  455. X#    Title:     utilities for displaying passages
  456. X#
  457. X#    Author:     Richard L. Goerwitz
  458. X#
  459. X#    Version: passutil.icn
  460. X#
  461. X############################################################################
  462. X#
  463. X#  Contains:
  464. X#
  465. X#      display_passage(ref), which displays ref, but fails if ref
  466. X#          either can't be converted to a bitmap or else can, but
  467. X#          doesn't correspond to any text in the main file
  468. X#
  469. X#      listpassage(l, msg, width), which displays the lines contained
  470. X#          in list l, truncating them to width, and displaying msg
  471. X#          both near the top of the screen and on the status line
  472. X#
  473. X#      writepassage(l, msg, switch), which writes list l to a file
  474. X#          (the name of which it prompts the user to enter); if switch
  475. X#          is nonnull, then it appends l to the file the user enters,
  476. X#          rather then overwriting it
  477. X#
  478. X#      get_{next,prev}_passage(), which generates the bitmap for the
  479. X#          next/previous reference in the KJV file
  480. X#
  481. X#      push_shell(), which suspends bibleref, and starts up either
  482. X#          /bin/sh, or the program named in the SHELL environment
  483. X#          variable.
  484. X#
  485. X############################################################################
  486. X#
  487. X#  Links: ./rewrap.icn
  488. X#
  489. X#  See also: ./bibleref.icn
  490. X#
  491. X############################################################################
  492. X
  493. X
  494. Xprocedure display_passage(passage_ref)
  495. X
  496. X    local msg, d_list, bitmap, text
  497. X    static width
  498. X    # global kjv_filename
  499. X    initial {
  500. X    # decide how long to make lines.  The display procedures
  501. X    # listpassage leaves a margin on the left (8 spaces).  On
  502. X    # a typical display, it looks nice to leave about nine
  503. X    # spaces on the other side.  This leaves getval("co")-17
  504. X    # spaces left for text in between.  The space left for
  505. X    # text here is stored in the static variable "width."
  506. X    width := (18 < getval("co")-17) |
  507. X        quit("display_passage","your terminal is too narrow",98)
  508. X    }
  509. X
  510. X    # Try to convert passage_ref to a retrieve-format bitmap.
  511. X    if type(passage_ref) == "string" then {
  512. X    *passage_ref > 0 | fail
  513. X    bitmap := ref_2_bitmap(passage_ref, kjv_filename) | fail
  514. X    }
  515. X    # If the passage_ref is not a string, the it's probably already
  516. X    # been converted; try to use it as-is.
  517. X    else bitmap := passage_ref
  518. X
  519. X    repeat {
  520. X
  521. X    message("Locating text in main file...")
  522. X        # Now check to see if the passage is present in the indexed text.
  523. X    text := bitmap_2_text(bitmap, kjv_filename) | fail
  524. X
  525. X        # Rewrap passage to width characters per line; put them into a list.
  526. X    d_list := []
  527. X    every put(d_list, rewrap(text, width))
  528. X    put(d_list, rewrap(&null, width))
  529. X
  530. X        # Get the name of the current passage, using standard abbrevs.
  531. X    msg := convertb(bitmap, kjv_filename)
  532. X
  533. X        # Display passage.
  534. X    bitmap := listpassage(bitmap, d_list, msg, width) | fail
  535. X    # If bitmap ends up null, then return.
  536. X    if /bitmap then return
  537. X
  538. X    }
  539. X
  540. Xend
  541. X
  542. X
  543. X
  544. Xprocedure listpassage(bitmap, l, msg, width)
  545. X
  546. X    local offset, ss, done, i, j, n, rsp, prompt
  547. X    static lines, top_margin
  548. X    initial {
  549. X    (lines := getval("li")-4) > 6 |
  550. X        quit("listpassage", "your terminal isn't tall enough", 96)
  551. X    top_margin := 3
  552. X    }
  553. X
  554. X    # "l" is a list of lines to print
  555. X    # "msg" is the message to put on the status line
  556. X    # "width" gives the length to which lines in l are truncated
  557. X
  558. X    offset := 0
  559. X    repeat {
  560. X
  561. X    # Set up top margin.
  562. X    every j := 1 to top_margin do {
  563. X        iputs(igoto(getval("cm"), 1, j))
  564. X        if j = 2 then {
  565. X        writes(repl(" ",3))
  566. X        underline()
  567. X        writes(msg)
  568. X        }
  569. X        normal(); iputs(getval("ce"))
  570. X    }
  571. X
  572. X    i := 0
  573. X    while *l >= (ss := offset + (lines > (i +:= 1))) do {
  574. X        iputs(igoto(getval("cm"), 1, i+top_margin))
  575. X        normal(); iputs(getval("ce"))
  576. X        writes(repl(" ", 8), l[ss][1:\width|0])
  577. X    }
  578. X
  579. X    # If we haven't reached the end of the displayable screen,
  580. X    # then clear lines until we reach it...
  581. X    if i-1 ~= lines then {
  582. X        every j := (i+top_margin) to lines+1 do {
  583. X        iputs(igoto(getval("cm"), 1, j))
  584. X        normal(); iputs(getval("ce"))
  585. X        }
  586. X    }
  587. X    status_line("** " || \msg || " **" | "", "", "c")
  588. X
  589. X    # If there's more to do, but we're at the end of the display,
  590. X    # then...
  591. X    if *l > lines & (offset+i) ~= (*l+1) then {
  592. X        rsp := snarf_input("Press !/a/b/c/m/w/+/- (q to quit viewing):  ")
  593. X        case map(rsp) of {
  594. X        "!"    : push_shell()
  595. X        "a"    : write_passage(l, msg, "append")
  596. X        "b"    : offset := (0 < offset-lines+1) | 0
  597. X        "c"    : next
  598. X        "m"|"" : (offset := (*l > (offset+i-1)))
  599. X        "+"    : return get_next_bitmap(bitmap)
  600. X        "-"    : return get_prev_bitmap(bitmap)
  601. X        "q"    : return
  602. X        "w"    : write_passage(l, msg)
  603. X        default : err_message("Command is invalid in this context.")
  604. X        }
  605. X    }
  606. X    # ...otherwise, we've displayed everything.
  607. X    else {
  608. X        prompt := "c/w/+/- (q to go to previous menu):  "
  609. X        if *l <= lines
  610. X        then rsp:= snarf_input("Press !/a/" || prompt) | next
  611. X        else rsp :=    snarf_input("Press !/a/b/" || prompt) | next
  612. X        case map(rsp) of {
  613. X        "!"    : push_shell()
  614. X        "a"    : write_passage(l, msg, "append")
  615. X        "b"    : offset := (0 < offset-lines+1) | 0
  616. X        "c"|"" : next
  617. X        "m"    : next
  618. X        "+"    : return get_next_bitmap(bitmap)
  619. X        "-"    : return get_prev_bitmap(bitmap)
  620. X        "q"    : return
  621. X        "w"    : write_passage(l, msg)
  622. X        default : err_message("Command is invalid in this context.")
  623. X        }
  624. X    }
  625. X    }
  626. X
  627. Xend
  628. X
  629. X
  630. X
  631. Xprocedure write_passage(passage_list, msg, switch)
  632. X
  633. X    local fname, outtext
  634. X
  635. X    # Get straight whether we are appending or clobbering.
  636. X    (/switch := "w") | (switch := "a")
  637. X
  638. X    until \outtext do {
  639. X    fname := snarf_input("Enter filename (! for shell; q to quit):  ")
  640. X    case fname of {
  641. X        ""   : fail
  642. X        "!"  : push_shell() & initialize_screen()
  643. X        "q"  : fail
  644. X        default : {
  645. X        outtext := open(fname, switch) | {
  646. X            case switch of {
  647. X            "a" : err_message("Can't append to " || fname || ".")
  648. X            "w" : err_message("Cannot write to " || fname || ".")
  649. X            default : quit("write_passage", "internal error", 80) 
  650. X            }
  651. X        }
  652. X        }
  653. X    }
  654. X    }
  655. X    message("Writing.")
  656. X    write(\outtext, msg)
  657. X    every write(outtext,!passage_list)
  658. X    close(outtext)
  659. X    message("Done.")
  660. X    return
  661. X
  662. Xend
  663. X
  664. X
  665. X
  666. Xprocedure get_next_bitmap(lastone)
  667. X
  668. X    local next_bitmap
  669. X    initial message("Reading limits file...")
  670. X
  671. X    next_bitmap := NextBitmap(lastone, kjv_filename) | {
  672. X    err_message(convertb(lastone, kjv_filename) || " has no successor.")
  673. X    fail
  674. X    }
  675. X    return next_bitmap
  676. X
  677. Xend
  678. X
  679. X
  680. X
  681. Xprocedure get_prev_bitmap(lastone)
  682. X
  683. X    local prev_bitmap
  684. X    initial message("Reading limits file...")
  685. X
  686. X    prev_bitmap := PrevBitmap(lastone, kjv_filename) | {
  687. X    err_message(convertb(lastone, kjv_filename) || " has no predecessor.")
  688. X    fail
  689. X    }
  690. X    return prev_bitmap
  691. X
  692. Xend
  693. X
  694. X
  695. X
  696. Xprocedure push_shell()
  697. X
  698. X    local status
  699. X    static shell
  700. X    initial shell := getenv("SHELL") | "/bin/sh"
  701. X
  702. X    clear()
  703. X    status := system(shell)
  704. X    clear()
  705. X
  706. X    return status
  707. X
  708. Xend
  709. SHAR_EOF
  710. true || echo 'restore of passutil.icn failed'
  711. rm -f _shar_wnt_.tmp
  712. fi
  713. # ============= srchutil.icn ==============
  714. if test -f 'srchutil.icn' -a X"$1" != X"-c"; then
  715.     echo 'x - skipping srchutil.icn (File already exists)'
  716.     rm -f _shar_wnt_.tmp
  717. else
  718. > _shar_wnt_.tmp
  719. echo 'x - extracting srchutil.icn (Text)'
  720. sed 's/^X//' << 'SHAR_EOF' > 'srchutil.icn' &&
  721. X############################################################################
  722. SHAR_EOF
  723. true || echo 'restore of srchutil.icn failed'
  724. fi
  725. echo 'End of  part 2'
  726. echo 'File srchutil.icn is continued in part 3'
  727. echo 3 > _shar_seq_.tmp
  728. exit 0
  729. -- 
  730.  
  731.    -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  732.    goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  733.