home *** CD-ROM | disk | FTP | other *** search
/ The Weather Channel - Everything Weather / TheWeatherChannel-EverythingWeather-Win31.iso / twcia / calndr1 / calndrx.dxr / 00001.ls next >
Encoding:
Text File  |  1995-08-25  |  6.0 KB  |  216 lines

  1. on startMovie
  2.   global firstDayOfMonthList, thisMonth, dayList, monthList, thisYear, pictureFlag, offsetX, offsetY, width, height, minderSprite, calPath, CDPath, HDPath, linkString, pictureName
  3.   set pictureFlag to 1
  4.   set firstDayOfMonthList to []
  5.   set linkString to EMPTY
  6.   set minderSprite to 18
  7.   puppetSprite(minderSprite, 1)
  8.   set the trails of sprite minderSprite to 1
  9.   puppetSprite(2, 1)
  10.   globalButtonInit(45, 48)
  11.   set offsetX to 236
  12.   set offsetY to 70
  13.   set width to 55
  14.   set height to 43
  15.   set dayList to ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
  16.   set monthList to ["January", 31, "February", 28, "March", 31, "April", 30, "May", 31, "June", 30, "July", 31, "August", 31, "September", 30, "October", 31, "November", 30, "December", 31]
  17.   put EMPTY into field "selected"
  18.   set the cursor of sprite 48 to -1
  19.   set thisYear to value(word 4 of the abbr date)
  20.   setUpYear()
  21.   set thisMonth to word 2 of the long date
  22.   put thisMonth && thisYear into field "monthName"
  23.   setCal()
  24.   set x to getPos(monthList, thisMonth)
  25.   set the castNum of sprite 2 to 40 + ((x + 1) / 2)
  26.   set file to char 1 to 3 of thisMonth & pictureFlag + 1 & ".PCT"
  27.   set the fileName of cast 10 to calPath & "calndr1\" & file
  28.   set the mouseDownScript to "click"
  29. end
  30.  
  31. on click
  32.   if the frame = 11 then
  33.     dontPassEvent()
  34.     exit
  35.   end if
  36.   if the clickOn then
  37.     puppetSound("click1.aif")
  38.     updateStage()
  39.     puppetSound(0)
  40.   end if
  41. end
  42.  
  43. on stopMovie
  44.   global minderSprite
  45.   puppetSprite(minderSprite, 0)
  46.   puppetSprite(2, 1)
  47.   puppetSprite(43, 0)
  48.   clearMinder()
  49.   freeSprites(45, 48)
  50. end
  51.  
  52. on setUpYear
  53.   global firstDayOfMonthList, thisYear
  54.   cursor(4)
  55.   set asciiYear to string(thisYear)
  56.   set century to value(char 1 to 2 of asciiYear)
  57.   set tyear to value(char 3 to 4 of asciiYear)
  58.   set day to 1
  59.   repeat with i = 1 to 12
  60.     set month to i
  61.     set year to tyear
  62.     if month < 3 then
  63.       set month to month + 10
  64.       set year to year - 1
  65.     else
  66.       set month to month - 2
  67.     end if
  68.     set dow to (((26 * month) - 2) / 10) + day + year + (year / 4) + (century / 4) - (2 * century) + 777
  69.     set dow to (dow mod 7) + 1
  70.     setAt(firstDayOfMonthList, i, dow)
  71.   end repeat
  72.   cursor(-1)
  73. end
  74.  
  75. on showPic
  76.   global thisMonth, hmpList, calPath, pictureFlag
  77.   set x to value(word 2 of field "monthName")
  78.   set pictureFlag to x mod 2
  79.   cursor(4)
  80.   set file to char 1 to 3 of thisMonth & pictureFlag + 1 & ".PCT"
  81.   set the fileName of cast 10 to calPath & "calndr1\" & file
  82.   updateStage()
  83.   set file to char 1 to 3 of thisMonth & ".txt"
  84.   set fileObject to FileIO(mnew, "read", calPath & "calndr1\" & file)
  85.   if fileObject < 0 then
  86.     alert("can't read file" && calPath & "calndr1\" & file)
  87.     put EMPTY into field 18
  88.   else
  89.     put fileObject(mReadFile) into field 18
  90.     fileObject(mdispose)
  91.   end if
  92.   set year to char 3 to 4 of word 2 of field "monthName"
  93.   set file to char 1 to 3 of thisMonth & year & ".hmp"
  94.   set fileObject to FileIO(mnew, "read", calPath & "calndr1\" & "facts\" & file)
  95.   if fileObject < 0 then
  96.     set hmpList to EMPTY
  97.   else
  98.     set hmpList to fileObject(mReadFile)
  99.     fileObject(mdispose)
  100.   end if
  101.   cursor(-1)
  102. end
  103.  
  104. on factSearch date
  105.   global hmpList
  106.   put EMPTY into field "HMP Field"
  107.   repeat with i = 1 to the number of lines in hmpList
  108.     if (i mod 2) = 0 then
  109.       next repeat
  110.     end if
  111.     if line i of hmpList starts date then
  112.       put line i + 1 of hmpList into field "HMP Field"
  113.       exit repeat
  114.     end if
  115.   end repeat
  116.   delete char the number of chars in date of date
  117.   repeat with i = 1 to the number of lines in field 18
  118.     if (i mod 2) = 0 then
  119.       next repeat
  120.     end if
  121.     if line i of field 18 starts date then
  122.       put line i + 1 of field 18 into field "factField"
  123.       exit repeat
  124.     end if
  125.   end repeat
  126. end
  127.  
  128. on leapCheck
  129.   global thisYear, monthList
  130.   set q to thisYear mod 4
  131.   if q = 0 then
  132.     setAt(monthList, 4, 29)
  133.   else
  134.     setAt(monthList, 4, 28)
  135.   end if
  136. end
  137.  
  138. on makeFile theDate
  139.   global minderFileName, thisYear, thisMonth, HDPath
  140.   cursor(4)
  141.   put theDate into field "selected"
  142.   set z to string((getPos(monthList, thisMonth) + 1) / 2) & "/"
  143.   put word 3 of theDate & "/" after z
  144.   factSearch(z)
  145.   set minderFileName to HDPath & "calndr1\" & thisYear
  146.   put word 3 of theDate after minderFileName
  147.   put "." & char 1 to 3 of thisMonth after minderFileName
  148.   set fileObject to FileIO(mnew, "read", minderFileName)
  149.   if fileObject < 0 then
  150.     put EMPTY into field 13
  151.   else
  152.     put fileObject(mReadFile) into field 13
  153.     fileObject(mdispose)
  154.   end if
  155.   cursor(-1)
  156.   if the frame < label("reminder") then
  157.     go("reminder")
  158.   end if
  159. end
  160.  
  161. on reminderTest
  162.   set n to label("reminder") + 1
  163.   if (the frame = n) or (the frame = (n + 1)) then
  164.     if field 13 <> EMPTY then
  165.       writeFile("write")
  166.     else
  167.       writeFile("delete")
  168.     end if
  169.   end if
  170. end
  171.  
  172. on writeFile job
  173.   global minderFileName
  174.   set fileObject to FileIO(mnew, "write", minderFileName)
  175.   if fileObject < 0 then
  176.     alert("we've had an error saving the file" && minderFileName)
  177.   else
  178.     set n to value(word 3 of field "selected")
  179.     if job = "write" then
  180.       fileObject(mWriteString, field 13)
  181.       fileObject(mdispose)
  182.       removeMinder(n, 1)
  183.     else
  184.       if job = "delete" then
  185.         fileObject(mDelete)
  186.         removeMinder(n, 0)
  187.       end if
  188.     end if
  189.   end if
  190. end
  191.  
  192. on removeMinder dayNumber, setClearFlag
  193.   global offsetX, offsetY, height, width, minderSprite, firstDay
  194.   set location to dayNumber + firstDay - 2
  195.   if setClearFlag = 0 then
  196.     set the trails of sprite minderSprite to 0
  197.   end if
  198.   set the locV of sprite minderSprite to offsetY + (location / 7 * height)
  199.   set the locH of sprite minderSprite to offsetX + (location mod 7 * width)
  200.   updateStage()
  201.   set the locV of sprite minderSprite to -20
  202.   set the locH of sprite minderSprite to -20
  203.   updateStage()
  204.   set the trails of sprite minderSprite to 1
  205. end
  206.  
  207. on CDcheck
  208.   global CDPath
  209.   set fileObject to FileIO(mnew, "read", CDPath & "lingo.ini")
  210.   if fileObject < 0 then
  211.     alert("Please insert the Everything Weather CDROM into your CDROM drive to access this feature or click on the Back button to exit this section. ")
  212.     abort()
  213.   end if
  214.   fileObject(mdispose)
  215. end
  216.