home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / fun / astroalm.sit / Almanac / stack.txt < prev   
Text File  |  1989-10-15  |  11KB  |  371 lines

  1. -- stack: in
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 3
  11. -- first background id: 2765
  12. -- card count: 15
  13. -- first card id: 2966
  14. -- list block id: 11014
  15. -- print block id: 9282
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 54688 bytes
  21. -- stack block size: 10240 bytes
  22. -- created by hypercard version: 0x00000000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on openStack
  69.   global force,intl,moon
  70.   if the version < "1.2" then
  71.     Ask "This stack requires HyperCard 1.2.1 or newer" with "Drat!"
  72.     go recent cd
  73.   end if
  74.   put 0 into moon
  75.   if the short name of second cd is "Occult." then put 1 into moon
  76.   put 0 into force
  77.   hide message box
  78.   put the seconds/86400 + 16480.5 + DSTCheck()/24 into jd2
  79.   put trunc(jd2+24000000) +1 into jd
  80.   get the date
  81.   if it contains "."
  82.   then put true into intl
  83. else put false into intl
  84. convert it to dateItems
  85. if intl then
  86.   repeat with i=1 to number of chars of it
  87.     if char i of it = "." then put "," into char i of it
  88.   end repeat
  89.   put item 1 of it into d
  90.   put item 2 of it into m
  91. else
  92.   put item 2 of it into m
  93.   put item 3 of it into d
  94. end if
  95. put false into val
  96. if m>4 and m<=10 then put true into val
  97. put trunc(jd-7*trunc(jd/7)) into w
  98. if m=4 and d>=w-1 then put true into val
  99. if m=10 and (d-w)>=25 then put false into val
  100. set hilite of bkgnd button "DST" of cd origin to val
  101. if val then
  102.   put "D" into char 3 of last word of cd fld coords of cd origin
  103. else
  104.   put "S" into char 3 of last word of cd fld coords of cd origin
  105. end if
  106. push cd
  107. if the short name of this cd is "origin" then
  108.   put line 2 of cd fld "Algol" into ecl
  109.   repeat
  110.     if ecl > jd2 then exit repeat
  111.     add 2.8673075 to ecl
  112.   end repeat
  113.   set numberFormat to "0.0"
  114.   put "Next minimum of Algol occurs in" && (ecl-jd2)*24 && "hours at JD=" into line 1 of cd fld Algol
  115.   set numberFormat to "0.###"
  116.   put ecl+2400000 after line 1 of cd fld Algol
  117.   put ecl into line 2 of cd fld Algol
  118. end if
  119. end openStack
  120.  
  121. function nDate Uflag,Jflag,n
  122. -- Uflag =0 for no UT, 1 for UT
  123. -- Jflag =12 for JT, 0 for no JT
  124. -- n = # days after given date
  125. global intl
  126. get the seconds
  127. add 86400*n+3600*(Jflag+Uflag*DSTcheck()) to it
  128. convert it to long date
  129. if intl then
  130.   put char 1 to (offset(".",second word of it)-1) of second word of it && third word of it && last word of it into he
  131. else
  132.   put char 1 to (offset(",",third word of it)-1) of third word of it && second word of it && last word of it into he
  133. end if
  134. return he
  135. end nDate
  136.  
  137. function DSTcheck
  138. get first word of line 4 of cd fld Coords of cd origin
  139. if hilite of bkgnd button "DST" of cd origin
  140. then put it-1 into temp
  141. else put it into temp
  142. return temp
  143. end DSTcheck
  144.  
  145. function sgn x
  146. if x<0 then
  147.   get -1
  148. else if x=0 then
  149.   get 0
  150. else if x>0 then
  151.   get 1
  152. end if
  153. return it
  154. end sgn
  155.  
  156. function sind n
  157. return sin(n*pi/180)
  158. end sind
  159.  
  160. function cosd n
  161. return cos(n*pi/180)
  162. end cosd
  163.  
  164. function tand n
  165. return tan(n*pi/180)
  166. end tand
  167.  
  168. on dayOfYear
  169.   -- returns day, dayUT as number of day in year
  170.   global dayUT,day,daySecs,intl
  171.   put the date into daysecs
  172.   if intl then
  173.     repeat with i=1 to number of chars of daysecs
  174.       if char i of daysecs = "." then put "/" into char i of daysecs
  175.     end repeat
  176.   end if
  177.   convert daySecs to seconds
  178.   put number of chars of the date into ndate
  179.   put "12/31/" & (char ndate-1 to ndate of the date)-1 into Jan0
  180.   convert Jan0 to seconds
  181.   put (daySecs-Jan0)/86400 into day
  182.   put (daySecs-Jan0+3600*DSTcheck())/86400 into dayUT
  183. end dayOfYear
  184.  
  185. on cheb a,b,c
  186.   global x,xa,xb
  187.   put 2*x*a-b+c into temp
  188.   put a into xb
  189.   put temp into xa
  190. end cheb
  191.  
  192. on UT
  193.   global day,daySecs,x,xa,xb,m
  194.   dayOfYear -- gets daySecs
  195.   get ((the seconds-daySecs)/3600+DSTcheck())mod 24
  196.   put trunc(it) into h
  197.   put trunc(60*(it-h)) into m
  198.   if m<10 then put "0" before m
  199.   if h=0 then put "0" before h
  200.   put "Universal Time = "& h &":" & m into line 1 of fld UT
  201.   put it into line 2 of fld UT
  202. end UT
  203.  
  204. on ST
  205.   global day,daySecs,x,xa,xb,dayUT
  206.   dayOfYear -- gets day
  207.   put (dayUT-1)/183-1 into x
  208.   put 0 into a
  209.   put 0 into b
  210.   put 7 into i
  211.   repeat until i=0
  212.     cheb a,b,word i+1 of cd fld "Sidereal Cheb" of cd origin
  213.     put xa into a
  214.     put xb into b
  215.     subtract 1 from i
  216.   end repeat
  217.   put xb into b2
  218.   cheb a,b,word 1 of cd fld "Sidereal Cheb" of cd origin
  219.   get ((xa-b2)/2+((the seconds-daySecs)/3600+DSTcheck())*1.00273791- (line 2 of cd fld "coords" of cd origin)/15+24) mod 24
  220.   put trunc(it) into h
  221.   put trunc(60*(it-h)) into m
  222.   if m<10 then put "0" before m
  223.   if h=0 then put "0" before h
  224.   put "Sidereal Time = "& h &":" & m into line 1 of fld ST
  225.   put it into line 2 of fld ST
  226. end ST
  227.  
  228. on hm decv,arg
  229.   global h,m
  230.   put trunc(arg) into h
  231.   put trunc(60*(arg-h)) into m
  232.   if decv then put abs(m) into m
  233.   if m<10 then put "0" before m
  234. end hm
  235.  
  236. on calc num,force
  237.   set cursor to 1001
  238.   -- calcs ra and dec, force =1 means do it anyway
  239.   global day,daySecs,x,xa,xb,dayUT,it,h,m,mode
  240.   dayOfYear -- gets day,dayUT
  241.   put pi/180 into fac
  242.   get line 3 of fld UT
  243.   put line 1 of cd fld "Coords" of cd origin into lat
  244.   if (it=trunc(dayUT) and the optionkey is up) and force=0 then
  245.     put line 5 of fld Pos into dra
  246.     put (line 6 of fld Pos) into dec
  247.     put line 3 of fld rise into arg
  248.   else
  249.     set cursor to 1002
  250.     put trunc(dayUT) into line 3 of fld UT
  251.     put (dayUT+((the seconds-daySecs)/3600+DSTcheck())/24-1)/183-1 into x
  252.     put 0 into a
  253.     put 0 into b
  254.     put num into i
  255.     repeat until i=0
  256.       set cursor to busy
  257.       cheb a,b,word i+1 of fld "ra cheb"
  258.       put xa into a
  259.       put xb into b
  260.       subtract 1 from i
  261.     end repeat
  262.     put xb into b2
  263.     cheb a,b,word 1 of fld "ra cheb"
  264.     get ((xa-b2)/2+48) mod 24
  265.     put it*15 into dra
  266.     put dra into line 5 of fld Pos
  267.     hm false,it
  268.     put short name of this cd &" R.A. = "& h &"h " & m &"m"into line 1 of fld Pos
  269.     put 0 into a
  270.     put 0 into b
  271.     put num into i
  272.     repeat until i=0
  273.       set cursor to busy
  274.       cheb a,b,word i+1 of fld "dec cheb"
  275.       put xa into a
  276.       put xb into b
  277.       subtract 1 from i
  278.     end repeat
  279.     put xb into b2
  280.     cheb a,b,word 1 of fld "dec cheb"
  281.     get (xa-b2)/2
  282.     put it into dec
  283.     put it into line 6 of fld Pos
  284.     put empty into sign
  285.     if it<0 and it>-1 then put "-" into sign
  286.     if it>0 then put "+" into sign
  287.     hm true,it
  288.     put short name of this cd&" Dec.  = "&sign&h&"┬░ "&m&"'" into line 2 of fld Pos
  289.     if "Sun" is in short name of this cd then
  290.       get (-.20791-sind(lat)*sind(dec))/(cosd(lat)*cosd(dec))
  291.       put abs(atan(sqrt(1-it*it)/it)) into ang
  292.       if -.20791<sind(lat)*sind(dec) then put pi-ang into ang
  293.       put ang/fac/15 into delta
  294.       put (dra/15+(line 2 of fld UT)-line 2 of fld 2+24-DSTcheck()) mod 24 into arg
  295.       get arg-delta
  296.       put it into line 3 of cd fld twilight
  297.       hm false,it
  298.       ampm
  299.       put "Twilight begins at "& h &":" & m && mode into line 1 of cd fld twilight
  300.       get arg+delta
  301.       put it into line 4 of cd fld twilight
  302.       hm false,it
  303.       ampm
  304.       put "Twilight ends    at "& h &":" & m && mode into line 2 of cd fld twilight
  305.     end if
  306.     get -sind(lat)*sind(dec)/cosd(lat)/cosd(dec)
  307.     put atan(sqrt(1-it*it)/it) into ang
  308.     if dec>0 then
  309.       add pi to ang
  310.     end if
  311.     put ang/fac/15 into delta
  312.     put dra/15+line 2 of fld UT-line 2 of fld ST+24-DSTcheck()into arg
  313.     get (arg-delta) mod 24
  314.     put arg into line 3 of fld rise
  315.     put it into line 4 of fld rise
  316.     hm false,it
  317.     ampm
  318.     put short name of this cd && "Rises at "& h &":" & m && mode into line 1 of fld rise
  319.     get (arg+delta) mod 24
  320.     put it into line 5 of fld rise
  321.     hm false,it
  322.     ampm
  323.     put short name of this cd && "Sets  at "& h &":" & m && mode into line 2 of fld rise
  324.     set cursor to 1001
  325.   end if
  326.   -- calc alt and az of object
  327.   put ((360+15*(line 2 of fld ST)-dra) mod 360) into LHA
  328.   put cosd(LHA)*sind(lat)-tand(dec)*cosd(lat) into den
  329.   put round(atanq(den,sind(LHA))/fac) into temp
  330.   put sind(lat)*sind(dec)+cosd(lat)*cosd(dec)*cosd(LHA) into sina
  331.   if abs(sina)<1 then
  332.     put round(atan(sina/(sqrt(1-sina*sina)))/fac) into alt
  333.     if alt>0 then
  334.       put "Az. = "& temp into line 3 of fld Pos
  335.       put "Alt. = " & alt into line 4 of fld Pos
  336.     else
  337.       if temp>180
  338.       then put "W" into tem
  339.     else put "E" into tem
  340.     put "below " & tem & " horizon" into line 3 of fld Pos
  341.     put empty into line 4 of fld Pos
  342.   end if
  343. else
  344.   beep
  345. end if
  346. set cursor to 1
  347. end calc
  348.  
  349. function atanq x,y
  350. get atan(y/x)
  351. if x>0 then add pi to it
  352. return it mod (2*pi)
  353. end atanq
  354.  
  355. on ampm
  356.   global h,mode,intl
  357.   if intl then
  358.     put empty into mode
  359.   else
  360.     put h into h2
  361.     if h>11 then
  362.       subtract 12 from h
  363.       put "PM" into mode
  364.     else
  365.       put "AM" into mode
  366.     end if
  367.     if h=0 then put 12 into h
  368.   end if
  369. end ampm
  370.  
  371.