Highligh current calendar day

Thread to discuss the MLOutlook family of applications: MLCalendar / MLEmail / MLPhoneBook
ebr
Intermediate
Intermediate
Posts: 339
Joined: Mon Dec 04, 2006 3:27 pm
Contact:

Postby ebr » Fri Jan 11, 2008 3:50 pm

Sure. A couple of pretty simple macros do the trick:

First, the main macro called GetToday's Events (called from MLScheduler at 1:00am):

Code: Select all

MLCalendar|Get_Date_info~{{currentDayOfMonth}}!
MLMath|Add~TodaysEvents~{{MLCalendar_DateEvent_StartTime}}~ ~{{MLCalendar_DateEvent_Subject}}<BR>!
MLConditional|IsEqual##{{MLCalendar_Next_Events_Available}}##1##Logic.GetNextEvents!
MLConditional|IsEqual##{{TodaysEvents}}##<BR>##SetVariable|TodaysEvents~***No Events***


And the supporting loop macro GetNextEvents:

Code: Select all

MLCalendar|Get_Next_Date_info~{{currentDayOfMonth}}!
MLMath|Add~TodaysEvents~{{TodaysEvents}}~{{MLCalendar_DateEvent_StartTime}}~ ~{{MLCalendar_DateEvent_Subject}}<BR>!
MLConditional|IsEqual##{{MLCalendar_Next_Events_Available}}##1##Logic.GetNextEvents


This macro pair uses recursive calls to enumerate all the events for a given day and produces a server variable called "TodaysEvents" that will contain all the events separated by a <BR> (for display in a text.multiline field) or the string "***No Events***"

I have a similar set of macros that get tomorrow's events but it is inelegant at this point because I know of no way to do date math in MLServer. So, it will work every day except the last day of each month.

90CE
Developer
Developer
Posts: 573
Joined: Mon Nov 28, 2005 1:19 am
Location: Waukee, Iowa
Contact:

Postby 90CE » Fri Jan 11, 2008 4:03 pm

Would the following variables be useful:

{{TodaysDate}}
{{TomorrowsDate}}
{{YesterdaysDate}}

I can add a function that allows you to obtains these values quickly. Then you could set an event to that fires every night at 12:01 am. Would this help.

Tracy

ebr
Intermediate
Intermediate
Posts: 339
Joined: Mon Dec 04, 2006 3:27 pm
Contact:

Postby ebr » Fri Jan 11, 2008 4:15 pm

I suppose they couldn't hurt but, for purposes of these functions, we'd need the day of month as an individual number. Today is already covered in the server with currentDayOfMonth, currentYear, etc. Tomorrows is the more difficult because we need to change the month if we're rolling over to a new month.

So, tomorrowMonth, tomorrowDay of Month, tomorrowYear could potentially be helpful. But, it will still require some bit of more sophisticated logic on the user's end because we'd have to re-set the month/year in MLCalendar before doing the get_Date_info calls.

While we're talking variables, I have a question - is there a reason why the MLCalendar variables stray from the normal naming conventions in MLServer - using underscores in them?

User avatar
jjjukebox
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1024
Joined: Sat May 22, 2004 9:54 pm
Location: Toronto
Contact:

Postby jjjukebox » Fri Jan 11, 2008 7:58 pm

I got the daily events idea from reading ebr's post and have a slightly different approach. I set MLScheduler to run Calendar.EventPopulate.Start at 12:01am.

Calendar.EventsPopulate.Start
Macro|
SetVariable|Calendar_Daily_Reminders~!
MLCalendar|GET_DATE_INFO~{{currentdayofmonth}}!
Calendar.EventsPopulate.Reminders

Calendar.EventsPopulate.Reminders
Macro|
MLConditional|IsEqual##{{mlcalendar_dateevent_subject}}## ##DoNothing##SetVariable|Calendar_Daily_Reminders~{{Calendar_Daily_Reminders}}{{mlcalendar_dateevent_starttime}} {{mlcalendar_dateevent_subject}}<br>!
MLConditional|IsEqual##{{mlcalendar_next_events_available}}##0##DoNothing##Calendar.EventsPopulate.CheckNext

Calendar.EventsPopulate.CheckNext
Macro|
MLCalendar|GET_NEXT_DATE_INFO~{{Calendar_Current_Day}}!
Calendar.EventsPopulate.Reminders

The results in variable {{Calendar_Daily_Reminders}} is todays events and reminders.

Make sure you dont create any variables in the MLCalenadar format like MLCalendar_xxx_xxx as they will get deleted if you ever use the delete variables tab in the plugin.

As for the highlighting of todays calendar grid box, I think what we also need a variable that represents which grid box represents todays date.

For example, if we had a variable like MLCalendar_Todays_Gridbox and the value was say 13, then we could send a command like this a 12:01am:
MLCMD|All~setProperty|applycolor~stage~{{MLCalendar_Todays_Gridbox}}~0x333333~50

However this would only work if your calendar was part of the stage and the calendar grid boxes were the first 37 buttons.

The only other fix would to have a tri-state button with different tint for on, off, and another defined state.

What I have now is that I set MLScheduler to run CalendarGallery.GridDayReset at 12:02am.

CalendarGallery.GridDayReset
Macro|
SetVariable|Calendar_Current_Day~{{currentdayofmonth}}!
SetVariable|CurrentCalendarGrid~0!
CalendarGallery.GridDayCalculate

CalendarGallery.GridDayCalculate
Macro|
MLMath|Add~CurrentCalendarGrid~{{CurrentCalendarGrid}}~1!
CalendarGallery.GridDaySet

CalendarGallery.GridDaySet
Macro|
MLConditional|IsEqual##{{MLCalendar_Date_{{CurrentCalendarGrid}}}}##{{Calendar_Current_Day}}##SetVariable|Calendar_Current_GridDay~{{CurrentCalendarGrid}}##CalendarGallery.GridDayCalculate

The result in Calendar_Current_GridDay is the grid box number for today.

Then at 12:03am I run CalendarGallery.GridDayHighlight

CalendarGallery.GridDayHighlight
Macro|MLCMD|All~setProperty|applycolor~stage~{{Calendar_Previous_GridDay}}~0x333333~100!MLCMD|All~setProperty|applycolor~stage~{{Calendar_Current_GridDay}}~0x333333~50!SetVariable|Calendar_Previous_GridDay~{{Calendar_Current_GridDay}}

Just my 2 cents

Later
J.J. Jukebox
Member

heystew
Newbie
Newbie
Posts: 12
Joined: Sun Oct 21, 2007 2:25 pm
Contact:

Today's Events

Postby heystew » Mon Jul 07, 2008 8:50 pm

Has anyone spent any more time putting today's events on the main screen? Just curious what other creative ideas people have had. The calendar discussion has been very quiet.

kirkfrey
Expert
Expert
Posts: 759
Joined: Wed Jan 12, 2005 10:55 am
Contact:

Postby kirkfrey » Mon Jul 14, 2008 10:05 pm

It would be good to be able to get the next "x" events. "today" and "tomorrow" are ok but I'd like to put the next 5 things out there that may be today or next week...
Kirk

Just trying to figure it out...

Droezel
Member
Member
Posts: 75
Joined: Fri Aug 03, 2007 2:35 am
Contact:

Postby Droezel » Sun Feb 01, 2009 9:25 am

I'm getting upcoming events like this through MLScript:

Code: Select all

Option Explicit

Sub GetUpcomingEvents

    dim arEvents()
    dim i
    dim j
    dim sEvent
    dim sDay

    'Force the calendar to the current month and year
    MLServer.cmdReceive "MLCalendar|SET_CURRENT_MONTH''~" & MLServer.GetVariable ("currentmonth")
    MLServer.cmdReceive "MLCalendar|SET_CURRENT_YEAR''~" & MLServer.GetVariable ("currentyear")

    j = 0

    For i = 1 to 42

        sEvent = MLServer.GetVariable ("mlcalendar_date_display_" & Cstr(i))
        sDay = MLServer.GetVariable ("mlcalendar_date_" & Cstr(i))

        If (sEvent  <> "") and (sDay >= MLServer.GetVariable("currentdayofmonth")) Then

            'get the first event
            MLServer.cmdReceive "MLCalendar|GET_DATE_INFO~" & sDay
            Redim Preserve arEvents(j)
            arEvents(j) = MLServer.GetVariable("mlcalendar_dateevent_startdate") & " - " & MLServer.GetVariable("mlcalendar_dateevent_subject")
            j = j + 1

            'get next events on this day if available
            Do Until MLServer.GetVariable("mlcalendar_next_events_available") = "0"
                MLServer.cmdReceive "MLCalendar|GET_NEXT_DATE_INFO~" & sDay
                Redim Preserve arEvents(j)
                arEvents(j) = MLServer.GetVariable("mlcalendar_dateevent_startdate") & " - " & MLServer.GetVariable("mlcalendar_dateevent_subject")
                j = j + 1
            Loop

        End If

    Next

    'delete existing vars
    MLServer.DelVariable  "calendar_upcomingevents_*"
   
    'put all events in mlserver vars
    j = 0
    For j = 0 to UBound(arEvents)
        MLServer.SetVariable "calendar_upcomingevents_" & Cstr(j), arEvents(j)
    Next

End Sub

Call GetUpcomingEvents


Maybe it's of use to anyone...

User avatar
ronsatter
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1304
Joined: Mon Dec 04, 2006 1:40 am
Location: San Leandro, CA
Contact:

Postby ronsatter » Sat Feb 07, 2009 3:45 am

Hi Droezel,

I try to take advantage of your scripting skills whenever possible. Thanks for the MLCalendar script above. I have my calendar events displayed in a different fashion on my scenes, but I now use your script to populate the calendar event variables: {{calendar_upcomingevents_0}} ~ {{calendar_upcomingevents_1}} ~ {{calendar_upcomingevents_2}}, etc.

Then I load them into the 0019 Typewriter Text Object (Something like the "Marquee Scroll") and see my calendar events scroll like news headlines. It's flashy ... but not too trashy. 8)

As for Kirk's request:
It would be good to be able to get the next "x" events. "today" and "tomorrow" are ok but I'd like to put the next 5 things out there that may be today or next week...


Is it possible to modify your script to loop through all of the remaining days of the current month and populate variables for all remaining events, not just today's events?

Thanks,

Ron
If it ain't broke ... don't fix it!

Droezel
Member
Member
Posts: 75
Joined: Fri Aug 03, 2007 2:35 am
Contact:

Postby Droezel » Sat Feb 07, 2009 5:05 am

My script was meant to populate all remaining events in the current month, but I had an faulty condition in it. Here's the correct script that effectively does all upcoming events.

Code: Select all

Sub GetUpcomingEvents

    dim arEvents()
    dim i
    dim j
    dim sEvent
    dim sDay
    dim iDay

    'Force the calendar to the current month and year
    MLServer.cmdReceive "MLCalendar|SET_CURRENT_MONTH''~" & MLServer.GetVariable ("currentmonth")
    MLServer.cmdReceive "MLCalendar|SET_CURRENT_YEAR''~" & MLServer.GetVariable ("currentyear")

    j = 0

    For i = 1 to 42

        sEvent = MLServer.GetVariable ("mlcalendar_date_display_" & Cstr(i))
        sDay = MLServer.GetVariable ("mlcalendar_date_" & Cstr(i))

        If sDay <> "" Then
           iDay = Cint(sDay)
        Else
           iDay = 0
        End If

        If (sEvent  <> "") and (iDay >= Cint(MLServer.GetVariable("currentdayofmonth"))) Then

            'get the first event
            MLServer.cmdReceive "MLCalendar|GET_DATE_INFO~" & sDay
            Redim Preserve arEvents(j)
            arEvents(j) = MLServer.GetVariable("mlcalendar_dateevent_startdate") & " - " & MLServer.GetVariable("mlcalendar_dateevent_subject")
            j = j + 1

            'get next events on this day if available
            Do Until MLServer.GetVariable("mlcalendar_next_events_available") = "0"
                MLServer.cmdReceive "MLCalendar|GET_NEXT_DATE_INFO~" & sDay
                Redim Preserve arEvents(j)
                arEvents(j) = MLServer.GetVariable("mlcalendar_dateevent_startdate") & " - " & MLServer.GetVariable("mlcalendar_dateevent_subject")
                j = j + 1
            Loop

        End If

    Next

    'delete existing vars
    MLServer.DelVariable  "calendar_upcomingevents_*"
   
    'put all events in mlserver vars
    j = 0
    For j = 0 to UBound(arEvents)
        MLServer.SetVariable "calendar_upcomingevents_" & Cstr(j), arEvents(j)
    Next

End Sub

Call GetUpcomingEvents

User avatar
ronsatter
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1304
Joined: Mon Dec 04, 2006 1:40 am
Location: San Leandro, CA
Contact:

Postby ronsatter » Sat Feb 07, 2009 11:48 am

Thanks Droezel ... works like a charm. :D

Ron
If it ain't broke ... don't fix it!


Return to “MLOutlook”

Who is online

Users browsing this forum: No registered users and 1 guest