Announcement

Collapse
No announcement yet.

Ocelot CMAX Programs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I was able to eliminate 21 lines of code with your example! Since the APPDIG forum seems to be back up, I'll post my holiday code there, but even after studying the changes you made to my season code, I don't see that it can be applied to my Holiday code.

    Comment


      #17
      Here is the Holiday snippet:

      <pre class="ip-ubbcode-code-pre">
      0001 - IF Month is = January (1) // New Years
      0002 - AND Day of Month is = 1 //
      0003 - THEN Celebration = New-Years-Day //
      0004 - THEN Skip to line 34 //
      0005 - IF Month is = February (2) // Presidents Day
      0006 - AND Day of Month is &gt; 14 //
      0007 - AND Day of Month is &lt; 22 //
      0008 - AND Day of Week is = Monday (1) //
      0009 - THEN Celebration = Presidents-Day //
      0010 - THEN Skip to line 34 //
      0011 - IF Month is = May (5) // Memorial Day
      0012 - AND Day of Month is &gt; 24 //
      0013 - AND Day of Week is = Monday (1) //
      0014 - THEN Celebration = Memorial-Day //
      0015 - THEN Skip to line 34 //
      0016 - IF Month is = July (7) // Independence Day
      0017 - AND Day of Month is = 4 //
      0018 - THEN Celebration = Independence-Day //
      0019 - THEN Skip to line 34 //
      0020 - IF Month is = September (9) // Labor Day
      0021 - AND Day of Month is &lt; 8 //
      0022 - AND Day of Week is = Monday (1) //
      0023 - THEN Celebration = Labor-Day //
      0024 - THEN Skip to line 34 //
      0025 - IF Month is = November (11) // Thanksgiving
      0026 - AND Day of Month is &gt; 21 //
      0027 - AND Day of Month is &lt; 29 //
      0028 - AND Day of Week is = Thursday (4) //
      0029 - THEN Celebration = Thanksgiving //
      0030 - THEN Skip to line 34 //
      0031 - IF Month is = December (12) // Christmas
      0032 - AND Day of Month is = 25 //
      0033 - THEN Celebration = Christmas //
      0034 - ...
      </pre>

      Comment


        #18
        Eliminating program lines is one thing, but maintaining program readability is another. I would leave the holiday routine you have just the way it is. For the 4 or 5 lines you could save in rewriting it using, say, a day of the year approach, it would get messy to look at or make adjustments (like for leap years) and just not worth it. There is no mathematical pattern to holidays so you're stuck with individual tests just like you're using.

        -----------------------------
        If you don't know what you're doing... do it neatly.

        Comment

        Working...
        X