home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / finance / tas515dm.zip / EXAMPLES.ZIP / MISSDATE.TAS < prev    next >
Text File  |  1991-05-05  |  3KB  |  67 lines

  1. { MISSDATE.TAS
  2.  
  3.    Script to find "missing" dates in a ticker file.
  4.  
  5.    This script will scan the dates in the ticker and point out 
  6.    invalid dates (like Saturdays and Sundays). It will also 
  7.    check the weekdays for "consecutiveness". In other words, 
  8.    a Friday follows a Thursday etc. If it finds a "gap", it
  9.    checks the date missing against a list of holidays (which 
  10.    are probably wrong, since I didn't save my old daytimers).
  11.  
  12. }
  13.    
  14. #output_file 'missdate.lst'
  15. i : number;
  16. day1 = daywk(dates[1]);    { get first day in file}
  17. i = 2;                     { start with second day}
  18. :loop
  19. if i > quote_count then return;  { are we done?}
  20. day2 = daywk(dates[i]);          { pick up the day of the week}
  21. if day2 < 1 or day2 > 5 then     { is it Sunday or Saturday ?}
  22.     begin
  23.     if day2 = 0 then              
  24.         badday = 'Sunday'
  25.     else
  26.         badday = 'Saturday';
  27.     writeln(ticker,datestr(dates[i]),' is a ',badday,'!');
  28.     end
  29. else
  30. if day1 = 5 and day2 = 1 then goto nextone; { Friday precedes Monday}
  31. day1 = day1 + 1;           { see what next day SHOULD be}
  32. if day2 = day1 then goto nextone;   { Compare to WHAT IT IS}
  33. dayd1 = dates[i-1];        { Not what it should be..get full date}
  34. dayd2 = dates[i];          { ditto}
  35. { Now this next part is how you could do a "holiday" check..
  36.   because the date you are comparing against is bigger than 
  37.   32,767 which is the maximum number we can specify without a 
  38.   decimal point, we need to make the number a "big" number by
  39.   adding a decimal zero. 
  40.   The following if statements are just checking that the missing 
  41.   day is one of the holidays for the last two years. As I said 
  42.   above, I might have left a few out...if you fill them in, please
  43.   send the script back to me with as many as you can put in.
  44. }
  45. if dayd1 < 890101.0 and dayd2 > 890101.0 then goto nextone; { nyears  89}
  46. if dayd1 < 890529.0 and dayd2 > 890529.0 then goto nextone; { mem day 89}
  47. if dayd1 < 890704.0 and dayd2 > 890704.0 then goto nextone; { 4th jul 89}
  48. if dayd1 < 890904.0 and dayd2 > 890904.0 then goto nextone; { lab day 89}
  49. if dayd1 < 891123.0 and dayd2 > 891123.0 then goto nextone; { gobble  89}
  50. if dayd1 < 891225.0 and dayd2 > 891225.0 then goto nextone; { xmax    89}
  51. if dayd1 < 900101.0 and dayd2 > 900101.0 then goto nextone; { nyears  90}
  52. if dayd1 < 900212.0 and dayd2 > 900212.0 then goto nextone; { pres    90}
  53. if dayd1 < 900101.0 and dayd2 > 900101.0 then goto nextone; { nyears  90}
  54. if dayd1 < 900704.0 and dayd2 > 900704.0 then goto nextone; { 4th jul 90}
  55. if dayd1 < 900903.0 and dayd2 > 900903.0 then goto nextone; { lab day 90}
  56. if dayd1 < 901122.0 and dayd2 > 901122.0 then goto nextone; { gobble  90}
  57. if dayd1 < 901225.0 and dayd2 > 901225.0 then goto nextone; { xmax    90}
  58. if dayd1 < 910101.0 and dayd2 > 910101.0 then goto nextone; { nyears  90}
  59. if dayd1 < 910218.0 and dayd2 > 910218.0 then goto nextone; { pres    90}
  60. days1 = datestr(dayd1);    { make the prior date readable}
  61. days2 = datestr(dayd2);    { make the current date readable}
  62. writeln(ticker,' is missing date between ',days1,' and ',days2);
  63. :nextone                   { LABEL for getting next day}
  64. day1 = day2;               { make the current day into the prior day}
  65. i = i+1;                   { move on to the next day}
  66. goto loop;                 { and go do it again..what else?}
  67.