[Remind-Fans] user functions

hymie at lactose.homelinux.net hymie at lactose.homelinux.net
Thu Jan 5 13:03:21 EST 2017


>> Now that you mention it, I wonder if I can use the choose() function
>> to just pre-populate a year-long class list, and have remind automatically
>> notice "lesson_num just passed 8, so go to the next class".  Ooooooooooo...
>>
>
>If you figure that out, please share!!!

OK.

I'm not proud of this.  I suspect Dianne will shriek when she sees it.
But it works.

First caveat is that it's very hard to insert comments.  So my example is
going to work for a year.  That way I can have a separate section for
2016, 2017, etc., with comments.

Second caveat is that my programming style is based on "minimum effort"
rather than "readability."

Third caveat -- if your list of classes isn't long enough, choose() will
return the last entry no matter how big the index gets.  Going one year
at a time should control this issue, but you should still know that it's
there.

With that...

We need a start date.  The first class that impacts 2017, even though
it actually started in 2016.  Again, Dianne pointed out that variables
are inefficient, but I prefer the ease of knowing I can make my changes
in only one place.

set start '2016-11-09'

We have a couple of dates we skipped due to holidays or whatever

omit 2016-12-28
omit 2017-02-01
omit 2017-03-29
omit 2017-12-27

We need a function that counts class days since the start date

FSET lesson_num(x) nonomitted(x, trigdate(), \
     "Mon","Tue","Thu","Fri","Sat","Sun")

Then we get ugly.  Note that remind is insistant about not having a
"last comma with no item after it".  That's why I put the commas at the
beginning of each line -- for easy cut-n-paste without having to remember
to add/remove the comma.

I need to add 1 to lesson_num(start)/8 because the lesson_num and division
are zero-based counters, but choose() is a 1-based counter.  Same issue
with the class number at the end -- modulo is also zero-based.

rem wed 2017 skip msg \
[choose(lesson_num(start)/8+1 \
, "Salsa / Waltz" \
, "Night Club / Salsa" \
, "E Coast / Night Club" \
, "Tango / E Coast" \
, "Cha Cha / Tango" \
, "W Coast / Cha Cha" \
, "Bachata / W Coast" \
, "Rumba / Merengue" \
)] # [lesson_num(start)%8+1]

And that should do it.  If you add more dates to the OMIT context,
everything else gets readjusted.

Your mileage may vary, no warranties expressed or implied, ask your doctor
before using my code, for entertainment purposes only.

--hymie!    http://lactose.homelinux.net/~hymie    hymie at lactose.homelinux.net


More information about the Remind-fans mailing list