5 Replies Latest reply on Mar 11, 2009 7:50 PM by fazstp

    Dependent on the day of the week

    dlbernst Level 1
      Hi. I was wondering if someone could please help me.

      I need some way of Director detecting what day of the week it is, and based on that day it needs to open a specific folder.

      So if its currently wednesday, I need it to open the 'wednesday' folder in explorer.

      I would really appreciate your help. Thanks
        • 1. Re: Dependent on the day of the week
          Level 7
          BuddyAPI has a function called baSystemTime() that can tell you the day
          of the week in text. Then you can use BuddyAPI's baOpenFile to open it.
          Like this:

          iDay=baSystemTime("%A")
          baOpenFile(the moviePath&iDay,"normal")

          You can get BuddyAPI from www.mods.com.au/budapi. It is free to use up
          to 2 commands, so the above can be done without paying for it. Though I
          recommend buying it since there are so many useful things in there.
          • 2. Re: Dependent on the day of the week
            James Newton, ACP Level 3
            There's a Calendar behavior in the Text section of the Library Palette (Window | Library Palette). This has a GetWeekDay () method.

            put script("Calendar").GetWeekDay(the systemDate)
            -- "Sun"

            vScript = script("Calendar")
            vScript.myFullDayFlag = TRUE
            put vScript.GetWeekDay(the systemDate)
            -- "Sunday"

            You can find an updated version of the Calendar behavior >here<,
            • 3. Re: Dependent on the day of the week
              Level 7
              You could create a JavaScript function like so:
              //
              function jsGetDay() { return new Date().getDay() }

              and bear in mind when you write your folder-opening code that 0 ==
              Sunday; 1 == Monday; ...; 6 == Saturday
              So:
              --
              on mouseDown me
              lFolderNames = ["Sunday", "Monday", "Tuesday", "Wednesday",
              "Thursday", "Friday", "Saturday"]
              tFolder = "path_to_folder" & the last char of the moviePath &
              lFolderNames[jsGetDay() + 1]
              -- code to open named folder
              end
              • 4. Re: Dependent on the day of the week
                James Newton, ACP Level 3
                Nice one Sean! I've learned something new today!
                • 5. Re: Dependent on the day of the week
                  fazstp Level 2
                  on WeekDay var_date
                  if voidP( var_date ) then
                  var_date = ( the systemDate )
                  end if

                  var_day = ( var_date - date( 2004, 1, 3 ) ) MOD 7

                  case ( var_day ) of

                  0: return "Saturday"
                  1, -6: return "Sunday"
                  2, -5: return "Monday"
                  3, -4: return "Tuesday"
                  4, -3: return "Wednesday"
                  5, -2: return "Thursday"
                  6, -1: return "Friday"

                  end case

                  end WeekDay