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

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