############################################################################ # # Name: convertb.icn # # Title: convert 3-field book,chap,verse bitmap into a human- # readable book chapter:verse reference # # Author: Richard L. Goerwitz # # Version: 1.7 # ############################################################################ # # Links: complete.icn ./initfile.icn # ############################################################################ # Declared in indexutl.icn. # record is(FS, s_len, len, no, is_case_sensitive) # global IS # Declared in initfile.icn. # global filestats # record Fs(ind_filename,bmp_filename,lim_filename, IS, ofs_table,all_bitmaps) procedure convertb(bitmap, filename) local no, reference, field_mask # Check for sloppy programming. /filename & abort("convertb","you called me without a filename",70) # If necessary, initialize stats for the current file. # if /filestats | /filestats[filename] then initfile(filename) # see initfile.icn IS := filestats[filename].IS 1 < IS.no < 4 | abort("convertb", "can't handle IS.no < 2 or > 3", 71) # IS.len = the number of bits needed to hold an integer # representation of a single field in filename # IS.no = number of fields in bitmaps for filename no := IS.no-1 field_mask := 2^(IS.len)-1 if IS.no = 3 then { # No need for mask here; add it just in case. reference := Num2Name( iand(field_mask, ishift(bitmap, -(no*IS.len))), "kjv.rtv") | abort("convertb", "can't convert first field", 52) no -:= 1 } else reference := "" reference ||:= " " || iand(field_mask, ishift(bitmap, -(no*IS.len))) no -:= 1 reference ||:= ":" || iand(field_mask, ishift(bitmap, -(no*IS.len))) return reference end procedure Num2Name(i) # Map English book names or abbreviations to numeric values. local names, n static num_table initial { names := [ "Gen", "Exod", "Lev", "Num", "Deut", "Josh", "Judg", "Ruth", "1Sam", "2Sam", "1Kgs", "2Kgs", "1Chr", "2Chr", "Ezra", "Neh", "Esth", "Job", "Pss", "Prov", "Qoh", "Cant", "Isa", "Jer", "Lam", "Ezek", "Dan", "Hos", "Joel", "Amos", "Obad", "Jonah", "Mic", "Nahum", "Hab", "Zeph", "Hag", "Zech", "Mal", "Mat", "Mark", "Luke", "John", "Acts", "Rom", "1Cor", "2Cor", "Gal", "Eph", "Phil", "Col", "1Thess", "2Thess", "1Tim", "2Tim", "Titus", "Phlm", "Heb", "Jas", "1Pet", "2Pet", "1John", "2John", "3John", "Jude", "Rev", "1Esdr", "2Esdr", "Tob", "Jdt", "Addest", "Wis", "Sirp", "Sir", "Bar", "Letjer", "Prazar", "Suz", "Bel", "Prman", "1Macc", "2Macc", "3Macc", "4Macc"] num_table := table() every n := 1 to 84 do insert(num_table, n, get(names)) } return num_table[i] end