home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1605 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  31.3 KB

  1. From: goer@sophist.uucp (Richard Goerwitz)
  2. Newsgroups: alt.sources
  3. Subject: Jewish/Civil calendar, part 02 of 03 (the real part 2)
  4. Message-ID: <1990Jul20.020159.6103@midway.uchicago.edu>
  5. Date: 20 Jul 90 02:01:59 GMT
  6.  
  7.  
  8. ---- Cut Here and unpack ----
  9. #!/bin/sh
  10. # this is hebcalen.02 (part 2 of a multipart archive)
  11. # do not concatenate these parts, unpack them in order with /bin/sh
  12. # file itlib.icn continued
  13. #
  14. if test ! -r shar3_seq_.tmp; then
  15.     echo "Please unpack part 1 first!"
  16.     exit 1
  17. fi
  18. (read Scheck
  19.  if test "$Scheck" != 2; then
  20.     echo "Please unpack part $Scheck next!"
  21.     exit 1
  22.  else
  23.     exit 0
  24.  fi
  25. ) < shar3_seq_.tmp || exit 1
  26. echo "x - Continuing file itlib.icn"
  27. sed 's/^X//' << 'SHAR_EOF' >> itlib.icn &&
  28. X    then f := open(termcap_string)
  29. X    /f := open("/etc/termcap") |
  30. X        er("getentry","I can't access your /etc/termcap file",1)
  31. X
  32. X    getline := create read_file(f)
  33. X    
  34. X    while line := @getline do {
  35. X        if line ? (pos(1) | tab(find("|")+1), =name, any(':|')) then {
  36. X        entry := ""
  37. X        while (\line | @getline) ? {
  38. X            if entry ||:= 1(tab(find(":")+1), pos(0))
  39. X            then {
  40. X            close(f)
  41. X            entry ?:= tab(find("tc=")) ||
  42. X                (move(3), getentry(tab(find(":"))) ?
  43. X                     (tab(find(":")+1), tab(0)))
  44. X            return entry
  45. X            }
  46. X            else {
  47. X            \line := &null # must precede the next line
  48. X            entry ||:= tab(-2)
  49. X            }
  50. X        }
  51. X        }
  52. X    }
  53. X    }
  54. X
  55. X    close(f)
  56. X    er("getentry","can't find and/or process your termcap entry",3)
  57. Xend
  58. X
  59. X
  60. X
  61. Xprocedure read_file(f)
  62. X
  63. X    # Suspends all non #-initial lines in the file f.
  64. X    # Removes leading tabs and spaces from lines before suspending
  65. X    # them.
  66. X
  67. X    local line
  68. X
  69. X    \f | er("read_tcap_file","no valid termcap file found",3)
  70. X    while line := read(f) do {
  71. X    match("#",line) & next
  72. X    line ?:= (tab(many('\t ')) | &null, tab(0))
  73. X    suspend line
  74. X    }
  75. X
  76. X    fail
  77. X
  78. Xend
  79. X
  80. X
  81. X
  82. Xprocedure maketc_table(entry)
  83. X
  84. X    # Maketc_table(s) (where s is a valid termcap entry for some
  85. X    # terminal-type): Returns a table in which the keys are termcap
  86. X    # capability designators, and the values are the entries in
  87. X    # "entry" for those designators.
  88. X
  89. X    local k, v
  90. X
  91. X    /entry & er("maketc_table","no entry given",8)
  92. X    if entry[-1] ~== ":" then entry ||:= ":"
  93. X    
  94. X    tc_table := table()
  95. X
  96. X    entry ? {
  97. X
  98. X    tab(find(":")+1)    # tab past initial (name) field
  99. X
  100. X    while tab(find(":")+1) ? {
  101. X
  102. X        &subject == "" &next
  103. X        if k := 1(move(2), ="=")
  104. X        then /tc_table[k] := decode(tab(find(":")))
  105. X        else if k := 1(move(2), ="#")
  106. X        then /tc_table[k] := integer(tab(find(":")))
  107. X        else if k := 1(tab(find(":")), pos(-1))
  108. X        then /tc_table[k] := true()
  109. X        else er("maketc_table", "your termcap file has a bad entry",3)
  110. X
  111. X    }
  112. X    }
  113. X
  114. X    return tc_table
  115. X
  116. Xend
  117. X
  118. X
  119. X
  120. Xprocedure getval(id)
  121. X
  122. X    /tc_table := maketc_table(getentry(getname())) |
  123. X    er("getval","can't make a table for your terminal",4)
  124. X
  125. X    return \tc_table[id] | fail
  126. X    # er("getval","the current terminal doesn't support "||id,7)
  127. X
  128. Xend
  129. X
  130. X
  131. X
  132. Xprocedure decode(s)
  133. X
  134. X    new_s := ""
  135. X
  136. X    s ? {
  137. X    while new_s ||:= tab(upto('\\^')) do {
  138. X        chr := move(1)
  139. X        if chr == "\\" then {
  140. X        new_s ||:= {
  141. X            case chr2 := move(1) of {
  142. X            "\\" : "\\"
  143. X            "^"  : "^"
  144. X            "E"  : "\e"
  145. X            "b"  : "\b"
  146. X            "f"  : "\f"
  147. X            "n"  : "\n"
  148. X            "r"  : "\r"
  149. X            "t"  : "\t"
  150. X            default : {
  151. X                if any(&digits,chr2) then {
  152. X                char(integer("8r"||chr2||move(2 to 0 by -1))) |
  153. X                    er("decode","bad termcap entry",3)
  154. X                }
  155. X               else chr2
  156. X            }
  157. X            }
  158. X        }
  159. X        }
  160. X        else new_s ||:= char(ord(map(move(1),&lcase,&ucase)) - 64)
  161. X    }
  162. X    new_s ||:= tab(0)
  163. X    }
  164. X
  165. X    return new_s
  166. X
  167. Xend
  168. X
  169. X
  170. X
  171. Xprocedure igoto(cm,col,line)
  172. X
  173. X    local colline, range, increment, str, outstr, chr, x, y
  174. X
  175. X    if col > (tc_table["co"]) | line > (tc_table["li"]) then {
  176. X    colline := string(\col) || "," || string(\line) | string(\col|line)
  177. X    range := "(" || tc_table["co"]-1 || "," || tc_table["li"]-1 || ")"
  178. X    er("igoto",colline || " out of range " || (\range|""),9)
  179. X    } 
  180. X
  181. X    # Use the Iconish 1;1 upper left corner & not the C-ish 0 offsets
  182. X    increment := -1
  183. X    outstr := ""
  184. X    
  185. X    cm ? {
  186. X    while outstr ||:= tab(find("%")) do {
  187. X        tab(match("%"))
  188. X        chr := move(1)
  189. X        if case chr of {
  190. X        "." :  outstr ||:= char(line + increment)
  191. X        "+" :  outstr ||:= char(line + ord(move(1)) + increment)
  192. X        "d" :  {
  193. X            str := string(line + increment)
  194. X            outstr ||:= right(str, integer(tab(any('23'))), "0") | str
  195. X        }
  196. X        }
  197. X        then line :=: col
  198. X        else {
  199. X        case chr of {
  200. X            "n" :  line := ixor(line,96) & col := ixor(col,96)
  201. X            "i" :  increment := 0
  202. X            "r" :  line :=: col
  203. X            "%" :  outstr ||:= "%"
  204. X            "B" :  line := ior(ishift(line / 10, 4), line % 10)
  205. X            ">" :  {
  206. X            x := move(1); y := move(1)
  207. X            line > ord(x) & line +:= ord(y)
  208. X            &null
  209. X            }
  210. X        } | er("goto","bad termcap entry",5)
  211. X        }
  212. X    }
  213. X    return outstr || tab(0)
  214. X    }
  215. X
  216. Xend
  217. X
  218. X
  219. X
  220. Xprocedure iputs(cp, affcnt)
  221. X
  222. X    local baud_rates, char_rates, i, delay, PC
  223. X    static num_chars, char_times
  224. X    # global tty_speed
  225. X
  226. X    initial {
  227. X    num_chars := &digits ++ '.'
  228. X    char_times := table()
  229. X    baud_rates := [0,300,600,1200,1800,2400,4800,9600,19200]
  230. X    char_rates := [0,333,166,83,55,41,20,10,5]
  231. X    every i := 1 to *baud_rates do {
  232. X        char_times[baud_rates[i]] := char_rates[i]
  233. X    }
  234. X    }
  235. X
  236. X    type(cp) == "string" |
  237. X    er("iputs","you can't iputs() a non-string value!",10)
  238. X
  239. X    cp ? {
  240. X    delay := tab(many(num_chars))
  241. X    if ="*" then {
  242. X        delay *:= \affcnt |
  243. X        er("iputs","affected line count missing",6)
  244. X    }
  245. X    writes(tab(0))
  246. X    }
  247. X
  248. X    if (\delay, tty_speed ~= 0) then {
  249. X    PC := tc_table["pc"] | "\000"
  250. X    char_time := char_times[tty_speed] | (return "speed error")
  251. X    delay := (delay * char_time) + (char_time / 2)
  252. X    every 1 to delay by 10
  253. X    do writes(PC)
  254. X    }
  255. X
  256. X    return
  257. X
  258. Xend
  259. SHAR_EOF
  260. echo "File itlib.icn is complete" &&
  261. # ============= hebcalen.hlp ==============
  262. echo "x - extracting hebcalen.hlp (Text)"
  263. sed 's/^X//' << 'SHAR_EOF' > hebcalen.hlp &&
  264. X
  265. XThis program accepts a year of the Jewish calendar, for example
  266. X"5750", and produces on the screen a calendar of that year with a 
  267. Xvisually equivalent civil calendar opposite it for easy conversion of 
  268. Xdates. The months of the civil year are abbreviated to
  269. X
  270. XJAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
  271. X
  272. Xand of the Jewish calendar to
  273. X
  274. XNIS IYA SIV TAM AV ELU TIS HES KIS TEV SHE ADA AD2.
  275. X
  276. XMonths are normally displayed three at a time. You call up the next
  277. Xthree by hitting return. At the end of the year you can indicate if
  278. Xyou wish the program to conclude, by hitting return again. If in
  279. Xresponse to the question, Do you wish to continue? you enter "y" and
  280. Xhit return, the next year will be displayed.
  281. X
  282. XEach Jewish month has its name on the left. The corresponding secular
  283. Xdates will have the name of the month on the right, and when the month
  284. Xchanges it will be indicated on the right also.
  285. X
  286. XIf you wish, you may enter a civil year in the form -70 for BCE dates
  287. Xand +70 for CE dates. The Jewish year beginning prior to Jan 1 of that
  288. Xyear will be displayed, and you can continue with the next Jewish year
  289. Xif you wish to complete the desired civil year.
  290. X
  291. XYou may enter CE or AD instead of + or BC or BCE instead of the minus
  292. Xsign if you wish. It is best to avoid spaces, so enter 1987AD, for
  293. Xexample.
  294. X
  295. XThe year 0 is not meaningful in either calendar. No date prior to 1 
  296. Xin the Jewish calendar should be entered. The program will calculate
  297. Xany future year, but will take longer for years much beyond the year
  298. X6020 in the Jewish reckoning. For example, the year 7000 will take
  299. Xthree minutes or so to appear. Earlier years should appear in a few
  300. Xseconds.
  301. X
  302. XA status line at the bottom of the screen indicates the civil and
  303. XJewish year, and the number of days in each. Jewish years may contain
  304. X354, 355, 356, 384, 385 or 386 days according to circumstances.
  305. X
  306. XWhen you are familiar with this program you can enter the years you
  307. Xwish to see on the command line. For example, if you call the program
  308. X
  309. X        iconx calendar 5704 +1987 1BC
  310. X
  311. Xyou will see in turn the Jewish year 5704, the Jewish year commencing
  312. Xin 1986 and the Jewish year commencing in 2 B.C.E. You still have the
  313. Xoption of seeing the years subsequent to these years if you wish. Just
  314. Xenter "y" when asked if you want to continue. When you enter "n", you
  315. Xwill get the next year of your list.
  316. X
  317. XAll civil dates are according to the Gregorian Calendar which first
  318. Xcame into use in 1582 and was accepted in different places at
  319. Xdifferent times. Prior to that date the Julian calendar was in use. At
  320. Xthe present time the Julian calendar is 13 days behind the Gregorian
  321. XCalendar, so that March 15 1917 in our reckoning is March 2 in the
  322. XJulian Calendar. The following table shows the number of days that
  323. Xmust be subtracted from the Gregorian date given here to find the Julian
  324. Xdate. In the early centuries of this table and before the calendar was
  325. Xintercalated erratically, so a simple subtraction is not possible. Note that
  326. Xthe change in the number to subtract applies from March 1 in the century
  327. Xyear, since in the Julian Calendar that will be February 29 except in years
  328. Xdivisible by 400 which are leap years in the Gregorian calendar also.
  329. X
  330. XCentury          # to subtract         Century          # to subtract
  331. X  21                    13                11                    6
  332. X  20                    13                10                    5
  333. X  19                    12                 9                     4
  334. X  18                    11                 8                     4
  335. X  17                    10                 7                     3
  336. X  16                    10                 6                     2
  337. X  15                     9                 5                     1
  338. X  14                     8                 4                     1
  339. X  13                     7                 3                     0
  340. X  12                     7                 2                    -1
  341. X                                           1                    -2
  342. X
  343. X
  344. SHAR_EOF
  345. # ============= hebcalen.dat ==============
  346. echo "x - extracting hebcalen.dat (Text)"
  347. sed 's/^X//' << 'SHAR_EOF' > hebcalen.dat &&
  348. X3%8255%8%20%-3762%384
  349. X4%23479%9%8%-3742%354
  350. X4%24950%8%28%-3722%354
  351. X5%501%8%17%-3702%385
  352. X6%15725%9%6%-3682%355
  353. X6%17196%8%26%-3662%355
  354. X6%18667%8%15%-3642%383
  355. X1%7971%9%3%-3622%353
  356. X1%9442%8%23%-3602%383
  357. X2%24666%9%10%-3582%354
  358. X3%217%8%30%-3562%354
  359. X3%1688%8%19%-3542%384
  360. X4%16912%9%7%-3522%354
  361. X4%18383%8%27%-3502%354
  362. X4%19854%8%17%-3482%385
  363. X6%9158%9%5%-3462%355
  364. X6%10629%8%25%-3442%355
  365. X6%12100%8%14%-3422%383
  366. X1%1404%9%2%-3402%353
  367. X1%2875%8%23%-3382%383
  368. X2%18099%9%10%-3362%354
  369. X2%19570%8%30%-3342%354
  370. X2%21041%8%19%-3322%384
  371. X4%10345%9%7%-3302%354
  372. X4%11816%8%28%-3282%354
  373. X4%13287%8%17%-3262%385
  374. X6%2591%9%5%-3242%353
  375. X6%4062%8%25%-3222%383
  376. X7%19286%9%11%-3202%355
  377. X7%20757%9%2%-3182%353
  378. X7%22228%8%22%-3162%383
  379. X2%11532%9%8%-3142%355
  380. X2%13003%8%28%-3122%355
  381. X2%14474%8%17%-3102%385
  382. X4%3778%9%7%-3082%354
  383. X4%5249%8%27%-3062%354
  384. X4%6720%8%16%-3042%383
  385. X5%21944%9%4%-3022%353
  386. X5%23415%8%24%-3002%383
  387. X7%12719%9%11%-2982%355
  388. X7%14190%8%31%-2962%355
  389. X7%15661%8%20%-2942%385
  390. X2%4965%9%8%-2922%355
  391. X2%6436%8%28%-2902%355
  392. X2%7907%8%18%-2882%385
  393. X3%23131%9%7%-2862%354
  394. X3%24602%8%27%-2842%383
  395. X5%13906%9%13%-2822%355
  396. X5%15377%9%2%-2802%355
  397. X5%16848%8%22%-2782%385
  398. X7%6152%9%10%-2762%355
  399. X7%7623%8%30%-2742%355
  400. X7%9094%8%19%-2722%385
  401. X1%24318%9%7%-2702%355
  402. X1%25789%8%28%-2682%355
  403. X2%1340%8%17%-2662%385
  404. X3%16564%9%6%-2642%354
  405. X3%18035%8%24%-2622%384
  406. X5%7339%9%12%-2602%354
  407. X5%8810%9%2%-2582%354
  408. X5%10281%8%22%-2562%385
  409. X6%25505%9%10%-2542%355
  410. X7%1056%8%30%-2522%355
  411. X7%2527%8%19%-2502%385
  412. X1%17751%9%8%-2482%355
  413. X1%19222%8%28%-2462%383
  414. X3%8526%9%15%-2442%354
  415. X3%9997%9%6%-2422%354
  416. X3%11468%8%24%-2402%384
  417. X5%772%9%12%-2382%354
  418. X5%2243%9%1%-2362%354
  419. X5%3714%8%21%-2342%385
  420. X6%18938%9%9%-2322%355
  421. X6%20409%8%29%-2302%355
  422. X6%21880%8%19%-2282%383
  423. X1%11184%9%7%-2262%355
  424. X1%12655%8%27%-2242%383
  425. X3%1959%9%14%-2222%354
  426. X3%3430%9%3%-2202%354
  427. X3%4901%8%24%-2182%384
  428. X4%20125%9%12%-2162%354
  429. X4%21596%9%1%-2142%354
  430. X4%23067%8%21%-2122%385
  431. X6%12371%9%9%-2102%355
  432. X6%13842%8%30%-2082%383
  433. X1%3146%9%18%-2062%353
  434. X1%4617%9%7%-2042%353
  435. X1%6088%8%27%-2022%383
  436. X2%21312%9%14%-2002%354
  437. X2%22783%9%3%-1982%354
  438. X2%24254%8%23%-1962%384
  439. X4%13558%9%11%-1942%354
  440. X4%15029%8%31%-1922%354
  441. X4%16500%8%20%-1902%385
  442. X6%5804%9%9%-1882%353
  443. X6%7275%8%29%-1862%383
  444. X7%22499%9%17%-1842%353
  445. X7%23970%9%6%-1822%353
  446. X7%25441%8%26%-1802%383
  447. X2%14745%9%13%-1782%355
  448. X2%16216%9%2%-1762%355
  449. X2%17687%8%22%-1742%385
  450. X4%6991%9%11%-1722%354
  451. X4%8462%8%31%-1702%383
  452. X5%23686%9%20%-1682%353
  453. X5%25157%9%9%-1662%353
  454. X6%708%8%29%-1642%383
  455. X7%15932%9%15%-1622%355
  456. X7%17403%9%4%-1602%355
  457. X7%18874%8%24%-1582%385
  458. X2%8178%9%12%-1562%355
  459. X2%9649%9%1%-1542%355
  460. X2%11120%8%21%-1522%385
  461. X4%424%9%10%-1502%354
  462. X4%1895%8%31%-1482%383
  463. X5%17119%9%17%-1462%355
  464. X5%18590%9%6%-1442%355
  465. X5%20061%8%28%-1422%383
  466. X7%9365%9%14%-1402%355
  467. X7%10836%9%4%-1382%355
  468. X7%12307%8%24%-1362%385
  469. X2%1611%9%12%-1342%355
  470. X2%3082%9%1%-1322%385
  471. X3%18306%9%21%-1302%354
  472. X3%19777%9%11%-1282%354
  473. X3%21248%8%31%-1262%383
  474. X5%10552%9%17%-1242%355
  475. X5%12023%9%6%-1222%355
  476. X5%13494%8%26%-1202%385
  477. X7%2798%9%14%-1182%355
  478. X7%4269%9%3%-1162%355
  479. X7%5740%8%23%-1142%385
  480. X1%20964%9%11%-1122%355
  481. X1%22435%8%31%-1102%385
  482. X3%11739%9%21%-1082%354
  483. X3%13210%9%10%-1062%354
  484. X3%14681%8%28%-1042%384
  485. X5%3985%9%16%-1022%354
  486. X5%5456%9%5%-1002%354
  487. X5%6927%8%26%-982%385
  488. X6%22151%9%14%-962%355
  489. X6%23622%9%3%-942%385
  490. X1%12926%9%22%-922%355
  491. X1%14397%9%11%-902%355
  492. X1%15868%9%1%-882%383
  493. X3%5172%9%19%-862%354
  494. X3%6643%9%8%-842%354
  495. X3%8114%8%28%-822%384
  496. X4%23338%9%16%-802%354
  497. X4%24809%9%5%-782%354
  498. X5%360%8%25%-762%385
  499. X6%15584%9%13%-742%355
  500. X6%17055%9%2%-722%383
  501. X1%6359%9%21%-702%353
  502. X1%7830%9%11%-682%353
  503. X1%9301%8%31%-662%383
  504. X2%24525%9%18%-642%354
  505. X3%76%9%7%-622%354
  506. X3%1547%8%27%-602%384
  507. X4%16771%9%16%-582%354
  508. X4%18242%9%5%-562%385
  509. X6%7546%9%24%-542%355
  510. X6%9017%9%13%-522%353
  511. X6%10488%9%2%-502%383
  512. X7%25712%9%22%-482%353
  513. X1%1263%9%11%-462%353
  514. X1%2734%8%31%-442%383
  515. X2%17958%9%18%-422%354
  516. X2%19429%9%6%-402%355
  517. X2%20900%8%27%-382%384
  518. X4%10204%9%15%-362%354
  519. X4%11675%9%4%-342%383
  520. X6%979%9%23%-322%355
  521. X6%2450%9%12%-302%353
  522. X6%3921%9%2%-282%383
  523. X7%19145%9%19%-262%355
  524. X7%20616%9%10%-242%353
  525. X7%22087%8%30%-222%383
  526. X2%11391%9%16%-202%355
  527. X2%12862%9%6%-182%385
  528. X4%2166%9%26%-162%354
  529. X4%3637%9%15%-142%354
  530. X4%5108%9%4%-122%383
  531. X5%20332%9%23%-102%353
  532. X5%21803%9%13%-82%353
  533. X5%23274%9%2%-62%383
  534. X7%12578%9%19%-42%355
  535. X7%14049%9%8%-22%355
  536. X7%15520%8%28%-2%385
  537. X2%4824%9%16%19%355
  538. X2%6295%9%5%39%385
  539. X3%21519%9%25%59%354
  540. X3%22990%9%14%79%354
  541. X3%24461%9%3%99%383
  542. X5%13765%9%21%119%355
  543. X5%15236%9%10%139%355
  544. X5%16707%8%30%159%385
  545. X7%6011%9%18%179%355
  546. X7%7482%9%7%199%385
  547. X1%22706%9%27%219%355
  548. X1%24177%9%16%239%355
  549. X1%25648%9%5%259%385
  550. X3%14952%9%25%279%354
  551. X3%16423%9%14%299%354
  552. X3%17894%9%2%319%384
  553. X5%7198%9%21%339%354
  554. X5%8669%9%10%359%354
  555. X5%10140%8%30%379%385
  556. X6%25364%9%18%399%355
  557. X7%915%9%7%419%385
  558. X1%16139%9%26%439%355
  559. X1%17610%9%15%459%355
  560. X1%19081%9%4%479%383
  561. X3%8385%9%22%499%354
  562. X3%9856%9%12%519%354
  563. X3%11327%9%1%539%384
  564. X5%631%9%20%559%354
  565. X5%2102%9%9%579%385
  566. X6%17326%9%28%599%355
  567. X6%18797%9%18%619%355
  568. X6%20268%9%7%639%383
  569. X1%9572%9%26%659%353
  570. X1%11043%9%15%679%355
  571. X1%12514%9%4%699%383
  572. X3%1818%9%23%719%354
  573. X3%3289%9%12%739%354
  574. X3%4760%9%1%759%384
  575. X4%19984%9%20%779%354
  576. X4%21455%9%9%799%385
  577. X6%10759%9%28%819%355
  578. X6%12230%9%17%839%355
  579. X6%13701%9%6%859%383
  580. X1%3005%9%25%879%353
  581. X1%4476%9%14%899%353
  582. X1%5947%9%4%919%383
  583. X2%21171%9%22%939%354
  584. X2%22642%9%11%959%384
  585. X4%11946%9%30%979%354
  586. X4%13417%9%19%999%354
  587. X4%14888%9%9%1019%385
  588. X6%4192%9%28%1039%355
  589. X6%5663%9%17%1059%353
  590. X6%7134%9%6%1079%383
  591. X7%22358%9%25%1099%353
  592. X7%23829%9%15%1119%353
  593. X7%25300%9%4%1139%383
  594. X2%14604%9%21%1159%355
  595. X2%16075%9%10%1179%385
  596. X4%5379%9%30%1199%354
  597. X4%6850%9%19%1219%354
  598. X4%8321%9%8%1239%383
  599. X5%23545%9%27%1259%353
  600. X5%25016%9%16%1279%353
  601. X6%567%9%5%1299%383
  602. X7%15791%9%23%1319%355
  603. X7%17262%9%12%1339%385
  604. X2%6566%10%1%1359%355
  605. X2%8037%9%20%1379%355
  606. X2%9508%9%9%1399%385
  607. X3%24732%9%30%1419%354
  608. X4%283%9%19%1439%354
  609. X4%1754%9%8%1459%383
  610. X5%16978%9%25%1479%355
  611. X5%18449%9%14%1499%355
  612. X5%19920%9%6%1519%383
  613. X7%9224%9%23%1539%355
  614. X7%10695%9%12%1559%385
  615. X1%25919%10%1%1579%355
  616. X2%1470%9%20%1599%355
  617. X2%2941%9%9%1619%385
  618. X3%18165%9%29%1639%354
  619. X3%19636%9%18%1659%354
  620. X3%21107%9%7%1679%383
  621. X5%10411%9%24%1699%355
  622. X5%11882%9%14%1719%385
  623. X7%1186%10%3%1739%355
  624. X7%2657%9%22%1759%355
  625. X7%4128%9%11%1779%385
  626. X1%19352%9%30%1799%355
  627. X1%20823%9%20%1819%355
  628. X1%22294%9%9%1839%385
  629. X3%11598%9%29%1859%354
  630. X3%13069%9%18%1879%354
  631. X3%14540%9%5%1899%384
  632. X5%3844%9%25%1919%354
  633. X5%5315%9%14%1939%385
  634. X6%20539%10%3%1959%355
  635. X6%22010%9%22%1979%355
  636. X6%23481%9%11%1999%385
  637. X1%12785%9%30%2019%355
  638. X1%14256%9%19%2039%355
  639. X1%15727%9%8%2059%383
  640. X3%5031%9%26%2079%354
  641. X3%6502%9%15%2099%384
  642. X4%21726%10%5%2119%354
  643. X4%23197%9%24%2139%354
  644. X4%24668%9%13%2159%385
  645. X6%13972%10%2%2179%355
  646. X6%15443%9%21%2199%355
  647. X6%16914%9%11%2219%383
  648. X1%6218%9%30%2239%353
  649. SHAR_EOF
  650. # ============= README ==============
  651. echo "x - extracting README (Text)"
  652. sed 's/^X//' << 'SHAR_EOF' > README &&
  653. XFor the bold in heart:  Type in "cp Makefile.dist Makefile; make" and
  654. Xwatch the sparks fly.  When done, type "hebcalen."  If you are satis-
  655. Xfied that it works, exit, then su root, and then type "make install."
  656. X
  657. XThis archive contains a test Unix port of Alan Corre's Jewish/Civil
  658. Xcalendar for MS-DOS.  My changes to his code are extensive, and yet
  659. Xmundane.  Mainly I just rewrote the input/output routines so that they
  660. Xwould be portable in a Unix environment, and would work with all the
  661. Xnon-cookie terminals I have access to (e.g. VT100, ANSI, IBM 3101).  In
  662. Xparticular, I made sure to eliminate all assumptions about terminal
  663. Xlength, width, and ability to display standout and/or underline modes.
  664. XI also removed all characters which would require an unsigned internal
  665. Xrepresentation (i.e. 8-bits).
  666. X
  667. XProbably the only really substantial changes I made were to add some
  668. Xconvenient defaults.  For instance, if you press CR at the
  669. Xinstructions prompt, you'll move on automatically to the year prompt.
  670. XIf you press CR at the year prompt, hebcalen assumes that you want the
  671. Xcurrent civil year.  Most of the prompts let you type "q" if you want
  672. Xto quit at that point.  Another added default is a search mechanism
  673. Xfor data files.  As long as the hebcalen data files are in your path,
  674. Xyou no longer need to have them in the current directory when hebcalen
  675. Xis invoked.  These changes represent mere conveniences, and do not
  676. Xalter the substance of the original distribution.
  677. X
  678. XFrom a packaging standpoint, the original calendar program has been
  679. Xtotally redone.  The original single file has been broken down into
  680. Xits constituent parts, and renamed "hebcalen" so as to avoid naming
  681. Xconflicts with tickler programs extant on many Unix systems.  I've
  682. Xalso added a Makefile to ease the pains of installation and
  683. Xmaintenance.  Just rename or copy Makefile.dist to Makefile, type
  684. X"make," and then give the program a few trial runs.  When satisfied it
  685. Xworks fine, then type "make install."  Make sure, before you do this,
  686. Xthat you edit the makefile to reflect your local file structure.
  687. X
  688. XThe original distribution is included as cal.text.  Please keep it
  689. Xaround if you plan to do any hacking, or even perusal of the code.
  690. XIt's a nice piece of work.
  691. X
  692. XMany, many thanks to Alan Corre for a well-written and useful contri-
  693. Xbution to the Icon community's code pool.
  694. X
  695. X
  696. X   -Richard L. Goerwitz          goer%sophist@uchicago.bitnet
  697. X   goer@sophist.uchicago.edu     rutgers!oddjob!gide!sophist!goer
  698. X
  699. SHAR_EOF
  700. # ============= Makefile.dist ==============
  701. echo "x - extracting Makefile.dist (Text)"
  702. sed 's/^X//' << 'SHAR_EOF' > Makefile.dist &&
  703. X# If you don't like this name, change it here and in the source
  704. X# files.  In particular, don't forget to do a global search and
  705. X# replace in hebcalen.icn, and don't forget to rename all the
  706. X# data files!
  707. XPROGNAME = hebcalen
  708. X
  709. X# Please edit these to reflect your local file structure.
  710. XDESTDIR = /usr/local/bin
  711. XDATA_DIR = /usr/local/lib/$(PROGNAME)
  712. XOWNER = bin
  713. XGROUP = bin
  714. X
  715. X# Itlib.icn is an Icon termlib package I added to facilitate
  716. X# porting the package to Unix.  It is not part of the original
  717. X# distribution.
  718. XSRC = $(PROGNAME).icn itlib.icn
  719. XDATA = $(PROGNAME).hlp $(PROGNAME).dat
  720. XOTHER = README Makefile
  721. X
  722. X# I hope you won't have to use this.
  723. X# DEBUGFLAG = -t
  724. X
  725. X# All this sh -c stuff is because some make programs can't specify
  726. X# a default shell.  In those cases where it matters, I call sh.
  727. X$(PROGNAME): $(SRC)
  728. X    test -f $(PROGNAME).hlp
  729. X    test -f $(PROGNAME).dat
  730. X    @-sh -c "test -f cal.text || echo You've deleted cal.text\!\!"
  731. X    icont $(DEBUGFLAG) -o $(PROGNAME) $(SRC)
  732. X    @rm -f $(PROGNAME).icn
  733. X
  734. X$(PROGNAME).icn: $(PROGNAME).src
  735. X    sh -c "sed \"s|/usr/local/lib/$(PROGNAME)|$(DATA_DIR)|g\" $(PROGNAME).src > $(PROGNAME).icn"
  736. X
  737. X# Pessimistic assumptions regarding the environment (in particular,
  738. X# I don't assume you have the BSD "install" shell script).
  739. Xinstall: $(PROGNAME)
  740. X    @sh -c "test -d $(DESTDIR) || mkdir $(DESTDIR)"
  741. X    cp $(PROGNAME) $(DESTDIR)/$(PROGNAME)
  742. X    chgrp $(GROUP) $(DESTDIR)/$(PROGNAME)
  743. X    chown $(OWNER) $(DESTDIR)/$(PROGNAME)
  744. X    -mkdir $(DATA_DIR)
  745. X    cp $(DATA) $(DATA_DIR)/
  746. X    chgrp $(GROUP) $(DATA_DIR)
  747. X    chown $(OWNER) $(DATA_DIR)
  748. X    chgrp $(GROUP) $(DATA_DIR)/*
  749. X    chown $(OWNER) $(DATA_DIR)/*
  750. X    @echo "\nDone.\n"
  751. X
  752. Xclean:
  753. X    -rm -f hebcalen
  754. X    -rm -f *.u?
  755. SHAR_EOF
  756. # ============= cal.text ==============
  757. echo "x - extracting cal.text (Text)"
  758. sed 's/^X//' << 'SHAR_EOF' > cal.text &&
  759. X#
  760. X# This is the original calendar distribution for MS-DOS, as written
  761. X# and packaged by Alan D. Corre.  Many thanks to him for an extremely
  762. X# useful and well-written piece of software!  - RLG
  763. X#
  764. X
  765. X#A VISUALLY EQUIVALENT JEWISH/CIVIL CALENDAR
  766. X#ALAN D. CORRE, University of Wisonsin-Milwaukee
  767. X#COPYRIGHT (c) 1990
  768. X#Permission is hereby given to all persons to copy, compile and pass to
  769. X#others this code provided that (1) it is not used for monetary gain; 
  770. X#(2) it is not subverted from its original purpose, and is changed only
  771. X#to the extent necessary to make it work on a different computer or terminal.
  772. X#No guarantees are given or implied as to the correctness of information
  773. X#furnished by this program.
  774. X#Written in the beautiful Icon programming language. Further information from
  775. X#icon-project@arizona.edu
  776. X#If my math were longer this program would be shorter. Excuse me.
  777. X#This work is respectfully devoted to the authors of two books consulted
  778. X#with much profit: "A Guide to the Solar-Lunar Calendar" by B. Elihu Rothblatt
  779. X#published by our sister Hebrew Dept. in Madison, Wis., and "Kiddush HaHodesh"
  780. X#by Rabbenu Moses ben Maimon, on whom be peace.
  781. X#The Jewish year harmonizes the solar and lunar cycle, using the 19-year cycle
  782. X#of Meton (c. 432 BCE). It corrects so that certain dates shall not fall on
  783. X#certain days for religious convenience. The Jewish year has six possible
  784. X#lengths, 353,354,355,383,384,385 days, according to day and time of new
  785. X#year lunation and position in Metonic cycle. Time figures from 6pm previous
  786. X#night. The lunation of year 1 is calculated to be on a Monday (our Sunday
  787. X#night) at ll:11:20pm. Our data table begins with a hypothetical year 0,
  788. X#corresponding to 3762 B.C.E. Calculations in this program are figured in
  789. X#the ancient Babylonian unit of halaqim "parts" of the hour = 1/1080 hour.
  790. X#Version given here should work without change under MS-DOS. Hints are given
  791. X#for modifying the code for other systems. Your MS-DOS should be sensitive to
  792. X#ANSI screen controls. On many machines you may achieve this by having the
  793. X#MS-DOS file ansi.sys available at boot time, and also a file called 
  794. X#config.sys which contains the statement DEVICE=ANSI.SYS  Hints are offered
  795. X#in case this is impossible.
  796. X#Material consists of three sections separated by legend CUT HERE. This first
  797. X#section should be placed in a file called calendar.icn. and compiled with
  798. X#icont. Section two should be placed in a file called calendar.hlp.
  799. X#The absence of this file will not impede the program. The information in 
  800. X#this file is unsuitable for the Macintosh. I can supply an alternate file.
  801. X#Section three should be placed in a file called calendar.dat. This file is
  802. X#essential, and must contain no extraneous matter at the beginning.
  803. X#Program is run under MS.DOS by entering the command:
  804. X# iconx calendar
  805. X#which may optionally be followed by the years desired in the form 5750
  806. X#for a Jewish year +1990 or 1990AD or 1990CE or -1990 or 1990BC or
  807. X#1990BCE for a civil year. On some systems iconx can be omitted.
  808. X
  809. Xrecord date(yr,mth,day)
  810. Xrecord molad(day,halaqim)
  811. Xglobal cyr,jyr,days_in_jyr,current_molad,current_day,infolist
  812. X
  813. Xprocedure main(cmd)
  814. Xlocal COPYRIGHT
  815. X#sticks around in memory
  816. X  COPYRIGHT := "Copyright (c) Alan D. Corre 1990"
  817. X#an acute accent on my e will be appreciated if available
  818. X  clear()
  819. X  banner("PERPETUAL JEWISH/CIVIL CALENDAR","","by","","ALAN D. CORRE")
  820. X  write("\n\nCopyright (c) Alan D. Corre 1990")
  821. X  if *cmd = 0 then {
  822. X#putting an asterisk indicates that user might need help
  823. X    n := 1; put(cmd,"*")} else
  824. X    n := *cmd
  825. X    every p := 1 to n do {
  826. X  initialize(cmd[p])
  827. X  process()}
  828. Xend
  829. X
  830. Xprocedure banner(l[])
  831. X#Creates a banner to begin programs. If you don't have the extended ASCII
  832. X#character set, replace each char(n) with some character that you have
  833. X#such as " " or "-"
  834. X#Does not work well if your screen has variable spacing.
  835. Xlocal n
  836. X  write();write();write()
  837. X  writes(char(201)) #top left right angle
  838. X  writes(repl(char(205),78)) #straight line
  839. X  writes(char(187)) #top right right angle
  840. X  writes(char(186)) #upright line at left
  841. X  writes(right(char(186),79)) #upright line at right
  842. X  every n := 1 to *l do {
  843. X    writes(char(186)) #upright line at left
  844. X    writes(center(l[n],78),char(186)) #string centered followed by upright line
  845. X    writes(char(186)) #upright line at left
  846. X    writes(right(char(186),79)) #upright line at right
  847. X}
  848. X  writes(char(200)) #bottom left right angle
  849. X  writes(repl(char(205),78)) #straight line
  850. X  write(char(188)) #bottom right right angle
  851. X  write()
  852. Xreturn
  853. Xend
  854. X
  855. Xprocedure instructions(filename)
  856. X#Gives user access to a help file which is printed out in chunks.
  857. Xlocal filvar,counter,line
  858. X  writes("Do you need instructions? y/n ")
  859. X  if upto('yY',read()) then {
  860. X#The following if-statement fails if the file is not available
  861. X  counter := 0
  862. X  if filvar := open(filename) then
  863. X#Read the help file. 
  864. X    while line := read(filvar) do {
  865. X#Write out a line and increment the counter
  866. X      write(line)
  867. X      counter +:= 1
  868. X#Now we have a screenful; ask if we should continue
  869. X      if counter >22 then {
  870. X        write()
  871. X        writes ("More? y/n ")
  872. X#User has had enough; break out of loop
  873. X        if upto('nN',read()) then break  else
  874. X#User wants more; reset counter and continue
  875. X          counter := 0}} else
  876. X#This else goes with the second if-statement; the attempt to open the
  877. X#help file failed:
  878. X      write("Sorry, instructions not available.")}
  879. X    write ("Press return to continue.")
  880. X    read()
  881. X#Close the file if it existed and was opened. If it was never opened
  882. X#the value of filvar will be null. This check has to be made because
  883. X#an attempt to use close() on a variable NOT valued at a file would
  884. X#cause an error. 
  885. X/filvar | close(filvar)
  886. Xend
  887. X
  888. Xprocedure clear()
  889. X#clears the screen. If you dont have ANSI omit the next line
  890. X  writes("\e[2J")
  891. Xend
  892. X
  893. Xprocedure initialize_list()
  894. X#while user views banner, put info of calendar.dat into a global list
  895. Xlocal infile,n
  896. X  infolist := list(301)
  897. X  if not (infile := open("calendar.dat")) then
  898. X    stop("This program must have the file CALENDAR.DAT on line in order to _
  899. X          function properly.")    
  900. X#the table is arranged arbitrarily at twenty year intervals with 301 entries.
  901. X  every n := 1 to 301 do
  902. X    infolist[n] := read(infile)
  903. X  close(infile)
  904. Xend
  905. X
  906. Xprocedure initialize_variables()
  907. X#get the closest previous year in the table
  908. Xlocal line,quotient
  909. X  quotient := jyr.yr / 20 + 1
  910. X#only 301 entries. Figure from last if necessary.
  911. X  if quotient > 301 then quotient := 301
  912. X#pull the appropriate info, put into global variables
  913. X  line := infolist[quotient]
  914. X  line ? { current_molad.day := tab(upto('%'))
  915. X         move(1)
  916. X     current_molad.halaqim := tab(upto('%'))
  917. X     move(1)
  918. X     cyr.mth := tab(upto('%'))
  919. X     move(1)
  920. X     cyr.day := tab(upto('%'))
  921. X     move(1)
  922. X     cyr.yr := tab(upto('%'))
  923. X     days_in_jyr := line[-3:0]
  924. X     }
  925. X#begin at rosh hashana
  926. X  jyr.day := 1
  927. X  jyr.mth := 7
  928. Xreturn
  929. Xend
  930. X
  931. Xprocedure initialize(yr)
  932. Xlocal year
  933. X#initialize global variables
  934. Xinitial {  cyr := date(0,0,0)
  935. X  jyr := date(0,0,0)
  936. X  current_molad := molad(0,0)
  937. X  initialize_list()}
  938. X  clear()
  939. X#user may need help
  940. X  if yr == "*" then {
  941. X  instructions("CALENDAR.HLP")
  942. X  clear()
  943. X  writes("Please enter the year. If you are entering a CIVIL year, precede _
  944. X         by + for \ncurrent era, - (the minus sign) for before current era. ")
  945. X  year := read()} else
  946. X  year := yr
  947. X  while not (jyr.yr := cleanup(year)) do {
  948. X    writes("I do not understand ",year,". Please try again ")
  949. X    year := read()}
  950. X  clear()
  951. X  initialize_variables()
  952. Xreturn
  953. Xend
  954. X
  955. Xprocedure cleanup(str)
  956. X#tidy up the string. Bugs still possible.
  957. X  if (not upto('.+-',str)) & integer(str) & (str > 0) then return str
  958. X  if upto('-bB',str) then return (0 < (3761 - checkstr(str)))
  959. X  if upto('+cCaA',str) then return (checkstr(str) + 3760)
  960. Xfail
  961. Xend
  962. X
  963. Xprocedure checkstr(s)
  964. X#does preliminary work on string before cleanup() cleans it up
  965. Xlocal letter,n,newstr
  966. X  newstr := ""
  967. X  every n := 1 to *s do
  968. X    if integer(s[n]) then
  969. X      newstr ||:= s[n]
  970. X  if (*newstr = 0) | (newstr = 0) then fail
  971. Xreturn newstr
  972. Xend
  973. X
  974. Xprocedure process()
  975. X#gets out the information
  976. Xlocal limit,dj,dc
  977. X#6039 is last year handled by the table in the usual way
  978. X  if jyr.yr <= 6039 then {
  979. X    limit := jyr.yr % 20 
  980. X    jyr.yr := ((jyr.yr / 20) * 20)} else {
  981. X#otherwise figure from 6020 and good luck
  982. X    limit := jyr.yr - 6020
  983. X    jyr.yr := 6020}
  984. X  ans := "y"
  985. X  establish_jyr()
  986. X  every 1 to limit do {
  987. X#tell user something is going on
  988. X    writes(" .")
  989. X#increment the years, establish the type of Jewish year
  990. X    cyr_augment()
  991. X    jyr_augment()
  992. X    establish_jyr()}
  993. X  clear() 
  994. X  while upto('Yy',ans) do {
  995. X  yj := jyr.yr
  996. X  dj := days_in_jyr
  997. X  every n := 1 to 4 do {
  998. X    clear()
  999. X    every 1 to 3 do
  1000. X      write_a_month()
  1001. X    write("Press the space bar to continue")
  1002. X    write()
  1003. X    writes(status_line(yj,dj))
  1004. X    getch()}
  1005. X    if jyr.mth = 6 then {
  1006. X      clear()
  1007. X      write_a_month()
  1008. X      every 1 to 15 do write()
  1009. X      write(status_line(yj,dj))}
  1010. X    write()
  1011. X    writes("Do you wish to continue? Enter y<es> or n<o>. ")
  1012. X    ans := getch()}
  1013. Xreturn
  1014. Xend
  1015. X
  1016. Xprocedure cyr_augment()
  1017. X#Make civil year a year later, we only need consider Aug,Sep,Nov.
  1018. Xlocal days,newmonth,newday
  1019. X if cyr.mth = 8 then
  1020. X   days := 0 else
  1021. X if cyr.mth = 9 then
  1022. X   days := 31 else
  1023. X if cyr.mth = 10 then
  1024. X   days := 61 else
  1025. X stop("Error in cyr_augment")
  1026. X  writes(" .")
  1027. X  days := (days + cyr.day-365+days_in_jyr)
  1028. X  if isleap(cyr.yr + 1) then days -:= 1
  1029. X#cos it takes longer to get there
  1030. X  if days <= 31 then {newmonth := 8; newday := days} else
  1031. X  if days <= 61 then {newmonth := 9; newday := days-31} else
  1032. X  {newmonth := 10; newday := days-61} 
  1033. X  cyr.mth := newmonth
  1034. X  cyr.day := newday
  1035. X  cyr.yr +:= 1
  1036. X  if cyr.yr = 0 then cyr.yr := 1
  1037. Xreturn
  1038. Xend
  1039. X
  1040. X
  1041. Xprocedure header()
  1042. X#creates the header for Jewish and English side. If ANSI not available,
  1043. X#substitute "S" for "\e[7mS\e[0m" each time.
  1044. SHAR_EOF
  1045. echo "End of  part 2"
  1046. echo "File cal.text is continued in part 3"
  1047. echo "3" > shar3_seq_.tmp
  1048. exit 0
  1049.  
  1050.    -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
  1051.    goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer
  1052.