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

  1. ############################################################################
  2. #
  3. #    Name:     name2num.icn
  4. #
  5. #    Title:     convert English book name to an integer
  6. #
  7. #    Author:     Richard L. Goerwitz
  8. #
  9. #    Version: 1.3
  10. #
  11. ############################################################################
  12. #
  13. #  Used by ref_2_bitmap(), convertr(), etc.
  14. #
  15. ############################################################################
  16.  
  17.  
  18. procedure name2num(s)
  19.  
  20.     # Map English book names or abbreviations to numeric values.
  21.  
  22.     local n, b_name, tmp_names, i, nameset
  23.     static names, abbrevtbl
  24.     initial {
  25.  
  26.     names :=     ["genesis", "exodus", "leviticus", "numbers",
  27.               "deuteronomy", "joshua", "judges", "ruth",
  28.               "1samuel", "2samuel", "1kings", "2kings",
  29.               "1chronicles", "2chronicles", "ezra",
  30.               "nehemiah", "esther", "job", "psalms",
  31.               "proverbs", "ecclesiastes", "canticles",
  32.               "isaiah", "jeremiah", "lamentations", "ezekiel",
  33.               "daniel", "hosea", "joel", "amos", "obadiah",
  34.               "jonah", "micah", "nahum", "habakkuk",
  35.               "zephaniah", "haggai", "zechariah", "malachi",
  36.               "matthew", "mark", "luke", "john", "acts",
  37.               "romans", "1corinthians", "2corinthians",
  38.               "galations", "ephesians", "philippians",
  39.               "colossians", "1thessalonians",
  40.               "2thessalonians", "1timothy", "2timothy",
  41.               "titus", "philemon", "hebrews", "james",
  42.               "1peter", "2peter", "1john", "2john", "3john",
  43.               "jude", "revelation", "tobit", "judith", "wisdom",
  44.               "sirach", "baruch", "1maccabees", "2maccabees",
  45.  
  46.               "gen", "exod", "lev", "num", "deut", "josh",
  47.               "judg", "ruth", "1sam", "2sam", "1kgs", "2kgs",
  48.               "1chr", "2chr", "ezra", "neh", "esth", "job",
  49.               "pss", "prov", "qoh", "cant", "isa", "jer",
  50.               "lam", "ezek", "dan", "hos", "joel", "amos",
  51.               "obad", "jonah", "mic", "nahum", "hab", "zeph",
  52.               "hag", "zech", "mal", "mat", "mark", "luke",
  53.               "john", "acts", "rom", "1cor", "2cor", "gal",
  54.               "eph", "phil", "col", "1thess", "2thess",
  55.               "1tim", "2tim", "titus", "phlm", "heb", "jas",
  56.               "1pet", "2pet", "1john", "2john", "3john",
  57.               "jude", "rev", "tob", "jdt", "wis", "sir",
  58.               "bar", "1macc", "2macc",
  59.  
  60.               "dt", "jdg", "jg", "rth", "sa1", "sa2", "ki1",
  61.               "ki2", "ch1", "ch2", "jl", "mt", "mk", "lk",
  62.               "jn", "co1", "co2", "th1", "th2", "ti1", "ti2",
  63.               "phm", "pe1", "pe2", "jo1", "jo2", "jo3", "1jn",
  64.               "2jn", "3jn",
  65.  
  66.               "son", "solomon", "ecclesiasticus", "ecclus"]
  67.  
  68.         abbrevtbl := table()
  69.     tmp_names := copy(names)
  70.     every i := (1 to 73) | (1 to 73) |
  71.         5|7|7|8|9|10|11|12|13|14|29|40|41|42|43|46|
  72.         47|52|53|54|55|57|60|61|62|63|64|62|63|64|
  73.         22|22|70|70
  74.     do {
  75.         insert(abbrevtbl, get(tmp_names), i)
  76.     }
  77.     }
  78.  
  79.     nameset := set()
  80.     every insert(nameset, complete(map(s), names))
  81.     case *nameset of {
  82.     0 : fail
  83.     1 : return abbrevtbl[!nameset]
  84.     default : suspend abbrevtbl[!sort(nameset)]
  85.     }
  86.     
  87. end
  88.