[Remind-Fans] Every Thursday except...
Tim Chase
remind at tim.thechases.com
Sat Sep 19 18:09:05 EDT 2020
On 2020-09-19 17:46, Ed Blackman wrote:
> One last question: what is the scope of variables in remind?
> There's no discussion of scope in the man page, suggesting that
> there's only global scope, and that I should "UNSET meeting" before
> the ENDIF for cleanliness.
As best I understand it, the default scope is "global for one day".
Which is to say it's global, but gets re-evaluated for each pass on
each day if doing a multi-day calendar. You can persist a variable
across multiple days with the PRESERVE keyword (which should be
enough to jump you to the "PRESERVING VARIABLES" section of the
man-page) which is handy for things that have a high cost associated
with them (evaluate them once and then preserve & reuse for each day
in the run) as shown in the example in the man-pages.
> Is that correct? A quick test shows that "meeting" is still set
> outside the IF block if I don't UNSET it, so it's not block scope,
> but I haven't used variables before so there might be some
> complexity I'm missing, or just no scopes/only global scope.
But yes, it's otherwise global scope. I usually try to namespace
them with a prefix like BDAY_varname, ANNIV_varname, WORK_varname
however these sometimes butt up against the
maximum-variable-name-length of 16 chars.
-tim
More information about the Remind-fans
mailing list