home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume33 / remind / part11 < prev    next >
Encoding:
Text File  |  1992-11-10  |  73.1 KB  |  2,263 lines

  1. Newsgroups: comp.sources.misc
  2. From: dfs@doe.carleton.ca (David F. Skoll)
  3. Subject:  v33i068:  remind - A replacement for calendar, Part11/12
  4. Message-ID: <1992Nov10.042035.1434@sparky.imd.sterling.com>
  5. X-Md4-Signature: f892ce4e2bb42672c29efbdf83626ec6
  6. Date: Tue, 10 Nov 1992 04:20:35 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: dfs@doe.carleton.ca (David F. Skoll)
  10. Posting-number: Volume 33, Issue 68
  11. Archive-name: remind/part11
  12. Environment: UNIX, MS-DOS
  13. Supersedes: remind: Volume 17, Issue 3-6
  14.  
  15. #!/bin/sh
  16. # This is part 11 of Remind 03.00.00
  17. if touch 2>&1 | fgrep 'amc' > /dev/null
  18.  then TOUCH=touch
  19.  else TOUCH=true
  20. fi
  21. # ============= remind.1 ==============
  22. if test X"$1" != X"-c" -a -f 'remind.1'; then
  23.     echo "File already exists: skipping 'remind.1'"
  24. else
  25. echo "x - extracting remind.1 (Text)"
  26. sed 's/^X//' << 'SHAR_EOF' > remind.1 &&
  27. X.TH REMIND 1 "20 October 1992"
  28. X.UC4
  29. X.SH NAME
  30. Xremind \- a sophisticated reminder service
  31. X.SH SYNOPSIS
  32. X.B remind [\fIoptions\fR] \fIfilename\fR [\fIdate\fR]
  33. X.SH DESCRIPTION
  34. X\fBRemind\fR reads the supplied \fIfilename\fR and executes the commands
  35. Xfound in it.  The commands are used to issue reminders and alarms.  Each
  36. Xreminder or alarm can consist of a message sent to standard output, or
  37. Xa program to be executed.
  38. X.SH OPTIONS
  39. X.TP
  40. X.B \-n
  41. XThe \fB\-n\fR option causes \fBRemind\fR to print the \fBnext\fR occurrence
  42. Xof each reminder in a simple calendar format.  You can sort this by
  43. Xdate by piping the output through \fBsort(1)\fR.
  44. X.TP
  45. X.B \-r
  46. XThe \fB\-r\fR option disables \fBRUN\fR directives and the \fBshell()\fR
  47. Xfunction
  48. X.TP
  49. X.B \-c\fR\fIn\fR
  50. XThe \fB\-c\fR option causes \fBRemind\fR to produce a calendar which is sent to
  51. Xstandard output.  If you supply a number \fIn\fR, then a calendar will
  52. Xbe generated for \fIn\fR months, starting with the current month.  By
  53. Xdefault, a calendar for only the current month is produced.  If \fIn\fR
  54. Xstarts with '+', then a calendar for \fIn\fR weeks is produced.
  55. X.TP
  56. X.B \-w\fR\fIn\fR
  57. XThe \fB\-w\fR option specifies the output width of the formatted calendar,
  58. Xin columns.  By default, the calendar is formatted for an 80-column
  59. Xdevice.
  60. X.TP
  61. X.B \-s\fR\fIn\fR
  62. XThe \fB\-s\fR option is very similar to the \fB\-c\fR option, except
  63. Xthat the output calendar is not formatted.  It is listed in a "simple
  64. Xformat" which can be used as input for more sophisticated calendar-drawing
  65. Xprograms.
  66. X.TP
  67. X.B \-v
  68. XThe \fB\-v\fR option makes the output of \fBRemind\fR slightly more verbose.
  69. X.TP
  70. X.B \-o
  71. XThe \fB\-o\fR option causes \fBRemind\fR to ignore all \fBONCE\fR directives.
  72. X.TP
  73. X.B \-t
  74. XThe \fB\-t\fR option causes \fBRemind\fR to trigger all non-expired reminders,
  75. Xregardless of the \fIdelta\fR supplied for each reminder.
  76. X.TP
  77. X.B \-h
  78. XThe \fB\-h\fR option ("hush...") supresses certain warning and information
  79. Xmessages.  In particular, if no reminders are triggered, this mode
  80. Xproduces no output.
  81. X.TP
  82. X.B \-a
  83. XThe \fB\-a\fR option causes \fBRemind\fR not to immediately trigger timed
  84. Xreminders which would also be queued.
  85. X.TP
  86. X.B \-q
  87. XThe \fB\-q\fR option causes \fBRemind\fR not to queue timed reminders
  88. Xfor later execution.
  89. X.TP
  90. X.B \-f
  91. XThe \fB\-f\fR option causes \fBRemind\fR to remain in the foreground
  92. Xwhen processing queued reminders, rather than forking off
  93. Xa background process to handle them.
  94. X.TP
  95. X.B \-e
  96. XThe \fB\-e\fR option diverts error messages (normally sent to the
  97. Xstandard error stream) to the standard output stream.
  98. X.TP
  99. X.B \-d\fR\fIchars\fR
  100. XThe \fB-d\fR option enables certain debugging modes.  The \fIchars\fR
  101. Xspecify which modes to enable:
  102. X.RS 2
  103. X.TP
  104. X.B e
  105. XEcho all input lines
  106. X.TP
  107. X.B x
  108. XTrace all expression evaluation
  109. X.TP
  110. X.B t
  111. XDisplay all trigger date computation
  112. X.TP
  113. X.B v
  114. XDump the variable table after execution of the reminder script
  115. X.TP
  116. X.B l
  117. XEcho lines when displaying error messages
  118. X.RE
  119. X.TP
  120. X\fB\-b\fR[\fIn\fR]
  121. XSet the time format for the calendar and simple-calendar outputs.  \fIN\fR
  122. Xcan range from 0 to 2, with the default 0.  A value of 0 causes times
  123. Xto be inserted in 12-hour (am/pm) format.  1 causes times to be inserted
  124. Xin 24-hour format, and 2 inhibits the automatic insertion of times in the
  125. Xcalendar output.
  126. X.TP
  127. X\fB\-x\fR[\fIn\fR]
  128. XSets the iteration limit for the \fBSATISFY\fR clause of a \fBREM\fR
  129. Xcommand.  Defaults to 150.
  130. X.TP
  131. X\fB\-z\fR[\fIn\fR]
  132. XRuns \fBRemind\fR in the daemon mode.  If \fIn\fR is supplied, it
  133. Xspecifies how often (in minutes) \fBRemind\fR should wake up to
  134. Xcheck if the reminder script has been changed.  \fIN\fR defaults
  135. Xto 5, and can range from 5 to 60.  Note that the use of the
  136. X\fB\-z\fR option also enables the \fB\-f\fR option.
  137. X.PP
  138. XIf you supply a \fIdate\fR on the command line, it must consist of
  139. X\fIday month year\fR, where \fIday\fR is the day of the month,
  140. X\fImonth\fR is at least the first three letters of the English name
  141. Xof the month, and \fIyear\fR is a year (all 4 digits) from 1990 to
  142. Xabout 2075.  You can leave out the \fIday\fR, which then defaults to 1.
  143. X.PP
  144. XIf you do supply a \fIdate\fR on the command line, then \fBRemind\fR uses
  145. Xit, rather than the actual system date, as its notion of "today."
  146. XThis lets you create calendars for future months, or test to see
  147. Xhow your reminders will be triggered in the future.
  148. X.SH REMINDER FILES
  149. X.PP
  150. X\fBRemind\fR uses scripts to control its operation.  The commands
  151. Xinside a script can range from
  152. Xthe very simple and almost immediately understandable:
  153. X.PP
  154. X.nf
  155. X    REM 6 Jan MSG David's birthday
  156. X.fi
  157. X.PP
  158. Xto the baroque and obscure:
  159. X.PP
  160. X.nf
  161. X    REM [trigger(date(thisyear, 1, 1) + 180)] ++5 OMIT \\
  162. X    sat sun SKIP MSG [ord(thisyear-1980)] payment due %b!
  163. X.fi
  164. X.PP
  165. XA reminder file consists of commands, with one command per line.  Several
  166. Xlines can be continued using the backslash character, as in the above
  167. Xexample.  In this case, all of the concatenated lines are treated as a
  168. Xsingle line by \fBRemind\fR.  Note that if an error occurs, \fBRemind\fR
  169. Xreports the line number of the last line of a continued line.
  170. X.PP
  171. X\fBRemind\fR ignores blank lines, and lines beginning with the '#' or ';'
  172. Xcharacters.  You can use the semicolon as a comment character if you
  173. Xwish to pass a \fBRemind\fR script through the C pre-processor, which
  174. Xinterprets the '#' character as the start of a pre-processing
  175. Xdirective.
  176. X.PP
  177. X\fBRemind\fR is not case sensitive; you can generally use any mixture of upper-
  178. Xor lower-case for commands, parameters, invocation options, etc.
  179. X.SH THE REM COMMAND
  180. X.PP
  181. XThe most powerful command in a \fBRemind\fR script is the \fBREM\fR command.
  182. XThis command is responsible for issuing reminders.
  183. XIts syntax is:
  184. X.PP
  185. X.RS
  186. X\fBREM\fR [\fBONCE\fR] [\fIdate_spec\fR]
  187. X[\fIback\fR]
  188. X[\fIdelta\fR]
  189. X[\fIrepeat\fR]
  190. X[\fBSKIP\fR | \fBBEFORE\fR | \fBAFTER\fR]
  191. X[\fBOMIT\fR \fIomit_list\fR]
  192. X[\fBAT\fR \fItime\fR [\fItdelta\fR] [\fItrepeat\fR]]
  193. X[\fBUNTIL\fR \fIexpiry_date\fR]
  194. X\fBMSG\fR | \fBRUN\fR | \fBCAL\fR | \fBSATISFY\fR
  195. X.I body
  196. X.RE
  197. X.PP
  198. XThe parts of the \fBREM\fR command can be specified in any order, except
  199. Xthat the \fIbody\fR must come immediately after the \fBMSG\fR,
  200. X\fBRUN\fR, \fBCAL\fR or \fBSATISFY\fR keyword.
  201. X.PP
  202. XThe \fBREM\fR token is optional, providing that the remainder
  203. Xof the command cannot be mistaken for another \fBRemind\fR command
  204. Xsuch as \fBOMIT\fR or \fBRUN\fR.  The portion of the \fBREM\fR command
  205. Xbefore the \fBMSG\fR, \fBRUN\fR, \fBCAL\fR or \fBSATISFY\fR clause
  206. Xis called a \fItrigger\fR.
  207. X.PP
  208. X.B MSG, RUN, and CAL
  209. X.PP
  210. XThe keywords \fBMSG\fR, \fBRUN\fR and \fBCAL\fR denote the \fItype\fR
  211. Xof the reminder.  (\fBSATISFY\fR is more complicated and will be explained
  212. Xlater.)  A \fBMSG\fR type reminder simply prints a message to the standard
  213. Xoutput, after passing the \fIbody\fR through a special substitution filter,
  214. Xdescribed in the section "The Substitution Filter."  A \fBRUN\fR-type
  215. Xreminder also passes the \fIbody\fR through the substitution filter, but
  216. Xthen executes the result as a system command.  A \fBCAL\fR-type reminder
  217. Xis used only to place entries in the calendar produced when \fBRemind\fR
  218. Xis run with the \-c or \-s options.
  219. X.PP
  220. X.B DATE SPECIFICATIONS
  221. X.PP
  222. XA \fIdate_spec\fR consists of zero to four parts.
  223. XThese parts are
  224. X.I day
  225. X(day of month),
  226. X.I month
  227. X(month name),
  228. X.I year
  229. Xand
  230. X.I weekday.
  231. X.I Month
  232. Xand
  233. X.I weekday
  234. Xare the English names of months and weekdays.  At least the first three
  235. Xcharacters must be used.  The following are examples of the various parts of a
  236. X.I date_spec:
  237. X.TP
  238. X.I day:
  239. X1, 22, 31, 14, 3
  240. X.TP
  241. X.I month:
  242. XJANUARY, feb, March, ApR, may, Aug
  243. X.TP
  244. X.I year:
  245. X1990, 1993, 2030, 95 (interpreted as 1995).  The year can range
  246. Xfrom 1990 to 2075.
  247. X.TP
  248. X.I weekday:
  249. XMonday, tue, Wed, THU, Friday, saturday, sundAy
  250. X.PP
  251. XNote that there can be several
  252. X.I weekday
  253. Xcomponents separated by spaces in a
  254. X.I date_spec.
  255. X.PP
  256. X.B INTERPRETATION OF DATE SPECIFICATIONS
  257. X.PP
  258. XThe following examples show how date specifications are interpreted.
  259. X.PP
  260. X1. Null date specification - the reminder is triggered every day.
  261. XThe trigger date for a specific run is simply the current system date.
  262. X.PP
  263. X2. Only
  264. X.I day
  265. Xpresent.  The reminder is triggered on the specified day of each month.
  266. XThe trigger date for a particular run is the closest such day to the
  267. Xcurrent system date.  For example:
  268. X.nf
  269. X    REM 1 MSG First of every month.
  270. X    REM 31 MSG 31st of every month that has 31 days.
  271. X.fi
  272. X.PP
  273. X3. Only
  274. X.I month
  275. Xpresent.  The reminder is triggered every day of the specified month.
  276. XExample:
  277. X.nf
  278. X    REM Feb MSG Every day in February
  279. X.fi
  280. X.PP
  281. X4.
  282. X.I day
  283. Xand
  284. X.I month
  285. Xpresent.  Examples:
  286. X.nf
  287. X    REM 6 Jan MSG Every 6th of January
  288. X    REM Feb 29 MSG Every 29th of February
  289. X.fi
  290. X.PP
  291. X5.  Only
  292. X.I year
  293. Xpresent. Example:
  294. X.nf
  295. X    REM 1991 MSG Every day in 1991
  296. X.fi
  297. X.PP
  298. X6.
  299. X.I year
  300. Xand
  301. X.I day
  302. Xpresent.  Examples:
  303. X.nf
  304. X    REM 1 1990 MSG 1st of every month in 1990
  305. X    REM 1992 23 MSG 23rd of every month in 1992
  306. X.fi
  307. X.PP
  308. X7.
  309. X.I year
  310. Xand
  311. X.I month
  312. Xpresent.  Examples:
  313. X.nf
  314. X    REM Feb 1991 MSG Every day in Feb 1991
  315. X    REM 1992 September MSG Every day in Sept 1992
  316. X.fi
  317. X.PP
  318. X8.
  319. X.I year, month
  320. Xand
  321. X.I day
  322. Xpresent.  Examples:
  323. X.nf
  324. X    REM 8 Jan 1991 MSG 8th January 1991.
  325. X    REM 1992 March 9 MSG 9th March 1992.
  326. X.fi
  327. X.PP
  328. X9.
  329. X.I weekday
  330. Xonly.  Examples:
  331. X.nf
  332. X    REM Sat MSG Every Saturday
  333. X    REM Mon Tue Wed Thu Fri MSG Every working day
  334. X    REM Monday Wednesday MSG Every Monday and Wednesday
  335. X.fi
  336. X.PP
  337. X10.
  338. X.I weekday
  339. Xand
  340. X.I day
  341. Xpresent.  Examples:
  342. X.nf
  343. X    REM Sat 1 MSG First Saturday of every month
  344. X    REM Mon Tue Wed Thu Fri 15 \\
  345. X        MSG 1st working day after 15th of every month
  346. X.fi
  347. X.PP
  348. X11.
  349. X.I weekday
  350. Xand
  351. X.I month
  352. Xpresent.  Examples:
  353. X.nf
  354. X    REM Mon March MSG Every Monday in March
  355. X    REM Mon Tue Wed Thu Fri Feb MSG Every working day in February
  356. X.fi
  357. X.PP
  358. X12.
  359. X.I weekday, month
  360. Xand
  361. X.I day
  362. Xpresent.  Examples:
  363. X.nf
  364. X    REM Mon 1 March MSG First Monday in March
  365. X    REM Sat Sun 15 July MSG First Sat or Sun on or after 15 July
  366. X.fi
  367. X.PP
  368. X13.
  369. X.I weekday
  370. Xand
  371. X.I year
  372. Xpresent.  Example:
  373. X.nf
  374. X    REM Sat Sun 1991 MSG Every Saturday and Sunday in 1991
  375. X.fi
  376. X.PP
  377. X14.
  378. X.I weekday, day
  379. Xand
  380. X.I year
  381. Xpresent.  Examples:
  382. X.nf
  383. X    REM Mon 15 1990 MSG 1st Mon after 15th of every month in 1990
  384. X    REM Mon Tue Wed Thu Fri 1 1990 \\
  385. X        MSG 1st working day of every month in 1990
  386. X.fi
  387. X.PP
  388. X15.
  389. X.I weekday, month
  390. Xand
  391. X.I year
  392. Xpresent.  Example:
  393. X.nf
  394. X    REM Mon Wed 1991 Feb MSG Every Mon and Wed in Feb 1991.
  395. X.fi
  396. X.PP
  397. X16.
  398. X.I weekday, day, month
  399. Xand
  400. X.I year
  401. Xpresent.  Example:
  402. X.nf
  403. X    REM Mon Tue Wed Thu Fri 28 Oct 1990 \\
  404. X        MSG 1st working day on or after 28 October 1990.
  405. X.fi
  406. X.PP
  407. XNote that when both
  408. X.I weekday
  409. Xand
  410. X.I day
  411. Xare specified,
  412. X.B Remind
  413. Xchooses the first date on or after the specified
  414. X.I day
  415. Xwhich also satisfies the
  416. X.I weekday
  417. Xconstraint.  It does this by picking the first date on or after the specified
  418. X.I day
  419. Xwhich is listed in the list of
  420. X.I weekdays.
  421. XThus, a reminder like:
  422. X.PP
  423. X.nf
  424. X    REM Mon Tue 28 Oct 1990 MSG Hi
  425. X.fi
  426. X.PP
  427. Xwould be issued only on Monday, 29 October, 1990.  It would not be issued
  428. Xon Tuesday, 30 October, 1990, since the 29th is the first date to satisfy
  429. Xthe
  430. X.I weekday
  431. Xconstraints.
  432. X.PP
  433. X.B BACKWARD SCANNING
  434. X.PP
  435. XSometimes, it is necessary to specify a date as being a set amount of
  436. Xtime before another date.  For example, the last Monday in a given
  437. Xmonth is computed as the first Monday in the next month, minus 7 days.
  438. XThe \fIback\fR specification in the reminder is used in this case:
  439. X.PP
  440. X.nf
  441. X    REM Mon 1 -7 MSG Last Monday of every month.
  442. X.fi
  443. X.PP
  444. XA \fIback\fR is specified with one or two dashes followed by an integer.
  445. XThis causes \fBRemind\fR to move "backwards" from what would normally be the
  446. Xtrigger date.  The difference between \-\-7 and \-7 will be explained
  447. Xwhen the \fBOMIT\fR keyword is described.
  448. X.PP
  449. X.B ADVANCE WARNING
  450. X.PP
  451. XFor some reminders, it is appropriate to receive advance warning of the
  452. Xevent.  For example, you may wish to be reminded of someone's birthday
  453. Xseveral days in advance.  The \fIdelta\fR portion of the \fBREM\fR command
  454. Xachieves this.  It is specified as one or two "+" signs followed by a number
  455. X\fIn\fR.  Again, the difference between the "+" and "++" forms will
  456. Xbe explained under the \fBOMIT\fR keyword.
  457. X\fBRemind\fR will trigger the reminder on computed trigger date, as well as
  458. Xon each of the \fIn\fR days before the event.  Here are some examples:
  459. X.PP
  460. X.nf
  461. X    REM 6 Jan +5 MSG Remind me of birthday 5 days in advance.
  462. X.fi
  463. X.PP
  464. XThe above example would be triggered every 6th of January, as well as the
  465. X1st through 5th of January.
  466. X.PP
  467. X.B PERIODIC REMINDERS
  468. X.PP
  469. XWe have already seen some built-in mechanisms for certain types of
  470. Xperiodic reminders.  For example, an event occurring every Wednesday
  471. Xcould be specified as:
  472. X.PP
  473. X.nf
  474. X    REM Wed MSG Event!
  475. X.fi
  476. X.PP
  477. XHowever, events which do not repeat daily, weekly, monthly or yearly require
  478. Xanother approach.  The \fIrepeat\fR component of the \fBREM\fR command
  479. Xfills this need.  To use it, you must completely specify a date (year, month
  480. Xand day, and optionally weekday.)  The \fIrepeat\fR component is an asterisk
  481. Xfollowed by a number specifying the repetition period in days.
  482. X.PP
  483. XFor example, suppose you get paid every second Wednesday, and your
  484. Xlast payday was Wednesday, 28 October, 1992.  You can use:
  485. X.PP
  486. X.nf
  487. X    REM 28 Oct 1992 *14 MSG Payday
  488. X.fi
  489. X.PP
  490. XThis issues the reminder every 14 days, starting from the calculated trigger
  491. Xdate.  You can use \fIdelta\fR and \fIback\fR with \fIrepeat.\fR  Note,
  492. Xhowever, that the \fIback\fR is used only to compute the initial
  493. Xtrigger date; thereafter, the reminder repeats with the specified
  494. Xperiod.  Similarly, if you specify a weekday, it is used only to calculate
  495. Xthe initial date, and does not affect the repetition period.
  496. X.PP
  497. X.B EXPIRY DATES
  498. X.PP
  499. XSome reminders should be issued periodically for a certain time, but then
  500. Xexpire.  For example, suppose you have a class every Friday, and that your
  501. Xlast class is on 11 December 1992.  You can use:
  502. X.PP
  503. X.nf
  504. X    REM Fri UNTIL 11 Dec 1992 MSG Class today.
  505. X.fi
  506. X.PP
  507. XAnother example:  Suppose you have jury duty from 30 November 1992 until
  508. X4 December 1992.  The following reminder will issue the message every day
  509. Xof your jury duty, as well as 2 days ahead of time:
  510. X.PP
  511. X.nf
  512. X    REM 30 Nov 1992 *1 +2 UNTIL 4 Dec 1992 MSG Jury duty
  513. X.fi
  514. X.PP
  515. XNote that the \fIrepeat\fR of *1 is necessary; without it, the reminder
  516. Xwould be issued only on 30 November (and the two days preceding.)
  517. X.PP
  518. X.B THE ONCE KEYWORD
  519. X.PP
  520. XSometimes, it is necessary to ensure that reminders are run only once
  521. Xon a given day.  For example, if you have a reminder which makes a backup
  522. Xof your files every Friday:
  523. X.PP
  524. X.nf
  525. X    REM Fri RUN do_backup
  526. X.fi
  527. X.PP
  528. X(Here, \fIdo_backup\fR is assumed to be a program or shell script which
  529. Xdoes the work.)  If you run \fBRemind\fR from your .login script, for
  530. Xexample, and log in several times per day, the \fIdo_backup\fR program
  531. Xwill be run each time you log in.  If, however, you use the \fBONCE\fR
  532. Xkeyword in the reminder, the \fBRemind\fR checks the last access date of
  533. Xthe reminder script.  If it is the same as the current date, \fBRemind\fR
  534. Xassumes that it has already been run, and will not issue reminders containing
  535. Xthe \fBONCE\fR keyword.
  536. X.PP
  537. XNote that if you view or edit your reminder script, the last access date
  538. Xwill be updated, and the \fBONCE\fR keyword will not operate properly.
  539. XIf you start \fBRemind\fR with the \fB\-o\fR option, then the \fBONCE\fR
  540. Xkeyword will be ignored.
  541. X.PP
  542. X.B LOCALLY OMITTING WEEKDAYS
  543. X.PP
  544. XThe \fBOMIT\fR portion of the \fBREM\fR command is used to "omit" certain
  545. Xdays when counting the \fIdelta\fR or \fIback\fR.  It is specified using
  546. Xthe keyword \fBOMIT\fR followed by a list of weekdays.  Its action is
  547. Xbest illustrated with examples:
  548. X.PP
  549. X.nf
  550. X    REM 1 +1 OMIT Sat Sun MSG Important Event
  551. X.fi
  552. X.PP
  553. XThis reminder is normally triggered on the first of every month, as well
  554. Xas the day preceding it.  However, if the first of the month falls on a
  555. XSunday or Monday, then the reminder is triggered starting from the
  556. Xprevious Friday.  This is because the \fIdelta\fR of +1 does not count
  557. XSaturday or Sunday when it counts backwards from the trigger date to
  558. Xdetermine how much advance warning to give.
  559. X.PP
  560. XContrast this with the use of "++1" in the above command.  In this case,
  561. Xthe reminder is triggered on the first of each month, as well as the day
  562. Xpreceding it.  The omitted days are counted.
  563. X.PP
  564. X.nf
  565. X    REM 1 -1 OMIT Sat Sun MSG Last working day of month
  566. X.fi
  567. X.PP
  568. XAgain, in the above example, the \fIback\fR of \-1 normally causes the
  569. Xtrigger date to be the last day of the month.  However, because of the
  570. X\fBOMIT\fR clause, if the first of the month falls on a Sunday or Monday,
  571. Xthe trigger date is moved backwards past the weekend to Friday.  (If you
  572. Xhave globally omitted holidays, the reminder will be moved back past them,
  573. Xalso.  See "The OMIT command" for more details.)
  574. X.PP
  575. XBy comparison, if we had used "\-\-1", the reminder would be triggered on
  576. Xthe last day of the month, regardless of the \fBOMIT\fR.
  577. X.PP
  578. X.B TIMED REMINDERS
  579. X.PP
  580. XTimed reminders are those which have an \fBAT\fR keyword followed
  581. Xby a \fItime\fR and optional \fItdelta\fR and \fItrepeat\fR.  The \fItime\fR
  582. Xmust be specified in 24-hour format, with 0:00 representing midnight,
  583. X12:00 representing noon, and 23:59 representing one minute to midnight.
  584. X.PP
  585. X\fBRemind\fR treats timed reminders specially.  If the trigger date
  586. Xfor a timed reminder is the same as the current system date, the
  587. Xreminder is queued for later activation.  When \fBRemind\fR has
  588. Xfinished processing the reminder file,
  589. Xit puts itself in the background, and activates timed reminders when the
  590. Xsystem time reached the specified time.
  591. X.PP
  592. XIf the trigger date is \fInot\fR the same as the system date, the reminder
  593. Xis not queued.
  594. X.PP
  595. XFor example, the following reminder, triggered every working day, 
  596. Xwill emit a message telling you to
  597. Xleave at 5:00pm:
  598. X.PP
  599. X.nf
  600. X    REM Mon Tue Wed Thu Fri AT 17:00 MSG Time to leave!
  601. X.fi
  602. X.PP
  603. XThe following reminder will be triggered on Thursdays and Fridays,
  604. Xbut will only be queued on Fridays:
  605. X.PP
  606. X.nf
  607. X    REM Fri ++1 AT 13:00 MSG Lunch at 1pm Friday.
  608. X.fi
  609. X.PP
  610. XThe \fItdelta\fR and \fItrepeat\fR have the same form as a \fIrepeat\fR
  611. Xand \fIdelta\fR, but are specified in minutes.  For example, this reminder
  612. Xwill be triggered at 12:00pm as well as 45 minutes before:
  613. X.PP
  614. X.nf
  615. X    REM AT 12:00 +45 MSG Example
  616. X.fi
  617. X.PP
  618. XThe following will be issued starting at 10:45, every half hour until 11:45,
  619. Xand again at noon.
  620. X.PP
  621. X.nf
  622. X    REM AT 12:00 +75 *30 MSG Example2
  623. X.fi
  624. X.PP
  625. XThe "+75" means that the reminder is issued starting 75 minutes before noon;
  626. Xin other words, at 10:45.  The *30 specifies that the reminder is subsequently
  627. Xto be issued every 30 minutes.  Note that the reminder is always issued at
  628. Xthe specified time, even if the \fItdelta\fR is not a multiple of the
  629. X\fItrepeat\fR.  So the above example is issued at 10:45am, 11:15am, 11:45am,
  630. Xand 12:00pm.  Note that in the time specification, there is no distinction
  631. Xbetween the "+" and "++" forms of \fItdelta\fR.
  632. X.PP
  633. XNormally, \fBRemind\fR will issue timed reminders as it processes the reminder
  634. Xscript, as well as queuing them for later.  If you do not want \fBRemind\fR to
  635. Xissue the reminders when processing the script, but only to queue them
  636. Xfor later, use the \fB\-a\fR command-line option.  If you do not want
  637. Xreminders to be queued for later, use the \fB\-q\fR command-line
  638. Xoption.
  639. X.PP
  640. XNormally, \fBRemind\fR forks a background process to handle queued reminders.
  641. XIf you want \fBRemind\fR to remain in the foreground, use the \fB\-f\fR
  642. Xcommand-line option.  This is useful, for example, in .xinitrc
  643. Xscripts, where you can use the command:
  644. X.PP
  645. X.nf
  646. X    remind -fa myreminders &
  647. X.fi
  648. X.PP
  649. XThis ensures that when you exit X-Windows, the \fBRemind\fR process is killed.
  650. X.PP
  651. X.B WARNING ABOUT TIMED REMINDERS
  652. X.PP
  653. XNote:  If you use user-defined functions or variables (described later)
  654. Xin the bodies of timed reminders, then when the timed reminders are
  655. Xactivated, the variables and functions have the definitions which were
  656. Xin effect at the end of the reminder script.  These definitions may
  657. X\fInot\fR necessarily be those which were in effect at the time the reminder
  658. Xwas queued.
  659. X.PP
  660. X.SH THE SUBSTITUTION FILTER
  661. X.PP
  662. XBefore being processed, the body of a
  663. X.B REM
  664. Xcommand is passed through a substitution filter.  The filter scans for
  665. Xsequences "%x" (where "x" is any letter and certain other characters)
  666. Xand performs substitutions as
  667. Xshown below.  (All dates refer to the trigger date of the reminder.)
  668. X.TP
  669. X.B %a
  670. Xis replaced with "on \fIweekday, day month, year\fR"
  671. X.RS
  672. XFor example, consider the reminder:
  673. X.PP
  674. XREM 18 Oct 1990 +4 MSG Meeting with Bob %a.
  675. X.PP
  676. XOn 16 October 1990, it would print "Meeting with Bob on Thursday, 18 October,
  677. X1990."
  678. X.PP
  679. XOn 17 October 1990, it would print "Meeting with Bob tomorrow."
  680. X.PP
  681. XOn 18 October 1990, it would print "Meeting with Bob today."
  682. X.RE
  683. X.TP
  684. X.B %b
  685. Xis replaced with "in \fIdiff\fR day's time" where
  686. X.I diff
  687. Xis the
  688. X.B actual
  689. Xnumber of days between the current date and the trigger date.
  690. X(\fBOMITs\fR have no effect.)
  691. X.RS
  692. XFor example, consider:
  693. X.PP
  694. XREM 18 Oct 1990 +4 MSG Meeting with Bob %b.
  695. X.PP
  696. XOn 16 October 1990, it would print "Meeting with Bob in 2 days' time."
  697. X.PP
  698. XOn 17 October 1990, it would print "Meeting with Bob tomorrow."
  699. X.PP
  700. XOn 18 October 1990, it would print "Meeting with Bob today."
  701. X.RE
  702. X.TP
  703. X.B %c
  704. Xis replaced with "on \fIweekday\fR"
  705. X.RS
  706. XExample: REM 18 Oct 1990 +4 MSG Meeting with Bob %c.
  707. X.PP
  708. XOn 16 October 1990, it would print "Meeting with Bob on Thursday."
  709. X.PP
  710. XOn 17 October 1990, it would print "Meeting with Bob tomorrow."
  711. X.PP
  712. XOn 18 October 1990, it would print "Meeting with Bob today."
  713. X.RE
  714. X.TP
  715. X.B %d
  716. Xis replaced with "\fIday\fR", the day of the month.
  717. X.TP
  718. X.B %e
  719. Xis replaced with "on \fIdd/mm/yyyy\fR"
  720. X.TP
  721. X.B %f
  722. Xis replaced with "on \fImm/dd/yyyy\fR"
  723. X.TP
  724. X.B %g
  725. Xis replaced with "on \fIweekday, day month\fR"
  726. X.TP
  727. X.B %h
  728. Xis replaced with "on \fIdd/mm\fR"
  729. X.TP
  730. X.B %i
  731. Xis replaced with "on \fImm/dd\fR"
  732. X.TP
  733. X.B %j
  734. Xis replaced with "on \fIweekday, month day-th, year\fR"  This form appends the
  735. Xcharacters "st", "nd", "rd" or "th" to the day of the month, as appropriate.
  736. X.TP
  737. X.B %k
  738. Xis replaced with "on \fIweekday, month day-th\fR"
  739. X.TP
  740. X.B %l
  741. Xis replaced with "on \fIyyyy/mm/dd\fR"
  742. X.TP
  743. X.B %m
  744. Xis replaced with "\fImonth\fR", the name of the month.
  745. X.TP
  746. X.B %n
  747. Xis replaced with the number (1 to 12) of the month.
  748. X.TP
  749. X.B %o
  750. Xis replaced with " (today)" if and only if the current system date is the same
  751. Xas the date being used by
  752. X.B Remind
  753. Xas the current date.  Recall that you can specify a date for
  754. X.B Remind
  755. Xto use on the command line.  This substitution is not generally useful in a
  756. X.B REM
  757. Xcommand, but is useful in a
  758. X.B BANNER
  759. Xcommand.  (See "The BANNER Command.")
  760. X.TP
  761. X.B %p
  762. Xis replaced with "s" if the
  763. X.I diff
  764. Xbetween the current date and the trigger date is not 1.  You can use this
  765. Xto construct reminders like:
  766. X.RS
  767. XREM 1 Jan +4 MSG %x day%p to go before New Year!
  768. X.RE
  769. X.TP
  770. X.B %q
  771. Xis replaced with "'s" if the
  772. X.I diff
  773. Xbetween the trigger date and the current date is 1.  Otherwise, it is replaced
  774. Xwith "s'"  This can be used as follows:
  775. X.RS
  776. XREM 1 Jan +4 MSG New Year in %x day%q time!
  777. X.RE
  778. X.TP
  779. X.B %r
  780. Xis replaced with the day of the month (01 to 31) padded with a leading zero
  781. Xif needed to pad to two digits.
  782. X.TP
  783. X.B %s
  784. Xis replaced with "st", "nd", "rd" or "th" depending on the day of the month.
  785. X.TP
  786. X.B %t
  787. Xis replaced with the number of the month (01 to 12) padded to two digits
  788. Xwith a leading zero.
  789. X.TP
  790. X.B %u
  791. Xis replaced with "on \fIweekday, day-th month, year\fR"  This is similar
  792. Xto
  793. X.B %a
  794. Xexcept that "st", "nd", "rd" or "th" is added to the
  795. X.I day
  796. Xas appropriate.
  797. X.TP
  798. X.B %v
  799. Xis replaced with "on \fIweekday, day-th month\fR"
  800. X.TP
  801. X.B %w
  802. Xis replaced with "\fIweekday\fR", the name of the day of the week.
  803. X.TP
  804. X.B %x
  805. Xis replaced with the
  806. X.I diff
  807. Xbetween the current date and the trigger date.  The
  808. X.I diff
  809. Xis defined as the actual number of days between these two dates;
  810. X.B OMITs
  811. Xare not counted.  (Strict date subtraction is performed.)
  812. X.TP
  813. X.B %y
  814. Xis replaced with "\fIyear\fR", the year of the trigger date.
  815. X.TP
  816. X.B %z
  817. Xis replaced with "\fIyy\fR", the last two digits of the year.
  818. X.TP
  819. X.B %_
  820. X(percent-underscore) is replaced with a newline.  You can use this to
  821. Xachieve multi-line reminders.
  822. X.TP
  823. X.B %1
  824. Xis replaced with "now", "\fIm\fR minutes from now", "\fIm\fR minutes ago",
  825. X"\fIh\fR hours from now", "\fIh\fR hours ago", "\fIh\fR hours and \fIm\fR
  826. Xminutes from now" or "\fIh\fR hours and \fIm\fR minutes ago", as appropriate
  827. Xfor a timed reminder.  Note that unless you specify the \fB\-a\fR option,
  828. Xtimed reminders will be triggered like normal reminders, and thus a timed
  829. Xreminder which occurred earlier in the day may be triggered.  This
  830. Xcauses the need for the "...ago" forms.
  831. X.TP
  832. X.B %2
  833. Xis replaced with "at \fIhh\fR:\fImm\fRam" or "..pm" depending on the
  834. X.B AT
  835. Xtime of the reminder.
  836. X.TP
  837. X.B %3
  838. Xis replaced with "at \fIhh\fR:\fImm\fR" in 24-hour format.
  839. X.TP
  840. X.B %4
  841. Xis replaced with "\fImm\fR" where \fImm\fR is the number of minutes between
  842. X"now" and the time specified by \fBAT\fR.  If the \fBAT\fR time is
  843. Xearlier than the current time, then the result is negative.
  844. X.TP
  845. X.B %5
  846. Xis replaced with "\fIma\fR" where \fIma\fR is the absolute value of the number
  847. Xproduced by \fB%4\fR.
  848. X.TP
  849. X.B %6
  850. Xis replaced with "ago" or "from now", depending on the relationship between
  851. Xthe \fBAT\fR time and the current time.
  852. X.TP
  853. X.B %7
  854. Xis replaced with the number of hours between the \fBAT\fR time and the
  855. Xcurrent time.  It is always non-negative.
  856. X.TP
  857. X.B %8
  858. Xis replaced with the number of minutes between the \fBAT\fR time and
  859. Xthe current time, after the hours (\fB%7\fR) have been subtracted out.
  860. XThis is a number ranging from 0 to 59.
  861. X.TP
  862. X.B %9
  863. Xis replaced with "s" if the value produced by \fB%8\fR is not 1.
  864. X.TP
  865. X.B %0
  866. Xis replaced with "s" if the value produced by \fB%7\fR is not 1.
  867. X.TP
  868. X.B %!
  869. Xis replaced with "is" if the current time is before the \fBAT\fR time,
  870. Xor "was" if it is after.
  871. X.TP
  872. X.B %@
  873. Xis similar to \fB%2\fR but displays the current time.
  874. X.TP
  875. X.B %#
  876. Xis similar to \fB%3\fR but displays the current time.
  877. X.TP
  878. X.B 
  879. X%"
  880. X(percent-doublequote) is removed.  This sequence is not 
  881. Xused by the substitution filter,
  882. Xbut is used to tell \fBremind\fR which text to include in a calendar
  883. Xentry when the \fB\-c\fR option is chosen.  See "Calendar
  884. XMode"
  885. X.PP
  886. XNotes:
  887. X.TP
  888. Xo
  889. X.B Remind
  890. Xnormally prints a blank line after each reminder; if the last character
  891. Xof the body is "%", the blank line will not be printed.
  892. X.TP
  893. Xo
  894. XSubstitutions a, b, c, e, f, g, h, i, j, k, l, u and v all are replaced
  895. Xwith "today" if the current date equals the trigger date, or "tomorrow"
  896. Xif the trigger date is one day after the current date.  Thus, they are
  897. X.B not
  898. Xthe same as substitutions built up from the simpler %w, %y, etc.
  899. Xsequences.
  900. X.TP
  901. Xo
  902. XAny of the substitutions dealing with time (0 through 9 and '!')
  903. Xproduce undefined results if used in a reminder which does not have
  904. Xan \fBAT\fR keyword.  Also, if a reminder has a \fIdelta\fR and may
  905. Xbe triggered on several days, the time substitutions ignore the date.  Thus,
  906. Xthe \fB%1\fR substitution may report that a meeting is in 15 minutes, for
  907. Xexample, even though it may only be in 2 days time, because a \fIdelta\fR has
  908. Xtriggered the reminder.  It is recommended that you use the time substitutions
  909. Xonly in timed reminders with no \fIdelta\fR which are designed to be
  910. Xqueued for timed activation.
  911. X.TP 
  912. Xo
  913. XCapital letters can be used in the substitution sequence, in which case
  914. Xthe first character of the substituted string is capitalized (if it is
  915. Xnormally a lower-case letter.)
  916. X.TP 
  917. Xo
  918. XAll other characters following a "%" sign are simply copied.  In particular,
  919. Xto get a "%" sign out, use "%%" in the body.  To start the body of a reminder
  920. Xwith a space, use "% ", since
  921. X.B remind
  922. Xnormally scans for the first non-space character after a
  923. X.B MSG,
  924. X.B CAL
  925. Xor
  926. X.B RUN
  927. Xtoken.
  928. X.SH THE OMIT COMMAND
  929. X.PP
  930. XIn addition to being a keyword in the \fBREM\fR command,
  931. X\fBOMIT\fR is a command in its own right.  Its syntax is:
  932. X.PP
  933. X.RS
  934. X\fBOMIT\fR \fIday\fR \fImonth\fR [\fIyear\fR]
  935. X.RE
  936. X.PP
  937. XThe \fBOMIT\fR command is used to "globally" omit certain days, which
  938. Xare usually holidays.  These globally-omitted days are skipped by the
  939. X"\-" and "+" forms of \fIback\fR and \fIdelta\fR.  Some examples:
  940. X.PP
  941. X.nf
  942. X    OMIT 1 Jan
  943. X    OMIT 7 Sep 1992
  944. X.fi
  945. X.PP
  946. XThe first example specifies a holiday which occurs on the same date each
  947. Xyear - New Year's Day.  The second example specifies a holiday which
  948. Xchanges each year - Labour Day.  For these types of holidays, you
  949. Xmust create an \fBOMIT\fR command for each year.  (Later, in the
  950. Xdescription of expressions and some of the more advanced features of
  951. X\fBRemind\fR, you will see how to automate this for some cases.)
  952. X.PP
  953. XFor convenience, you can use a \fIdelta\fR and \fBMSG\fR or \fBRUN\fR
  954. Xkeyword in the \fBOMIT\fR command.  The following sequences are exactly
  955. Xequivalent:
  956. X.PP
  957. X.nf
  958. X    OMIT 1 Jan
  959. X    REM 1 Jan +4 MSG New year's day is %b!
  960. X
  961. X    and
  962. X
  963. X    OMIT 1 Jan +4 MSG New year's day is %b!
  964. X.fi
  965. X.PP
  966. X.B THE BEFORE, AFTER AND SKIP KEYWORDS
  967. X.PP
  968. XNormally, days which are omitted, whether by a global \fBOMIT\fR command
  969. Xor the local \fBOMIT\fR keyword in a \fBREM\fR statement, only affect the
  970. Xcounting of the \-\fIback\fR or the +\fIdelta\fR.  For example, suppose
  971. Xyou have a meeting every Wednesday.  Suppose, too, that you have indicated
  972. X11 Nov as a holiday:
  973. X.PP
  974. X.nf
  975. X    OMIT 11 Nov +4 MSG Remembrance Day
  976. X    REM Wed +1 MSG Code meeting %b.
  977. X.fi
  978. X.PP
  979. XThe above sequence will issue a reminder about a meeting for 11 November 1992,
  980. Xwhich is a Wednesday.  This is probably incorrect.  There are three
  981. Xoptions:
  982. X.TP
  983. X.B BEFORE
  984. XThis keyword moves the reminder to before any omitted days.  Thus, in
  985. Xthe above example, use of \fBBEFORE\fR would cause the meeting reminder
  986. Xto be triggered on Tuesday, 10 November 1992.
  987. X.TP
  988. X.B AFTER
  989. XThis keyword moves the reminder to after any omitted days.  In the above
  990. Xexample, the meeting reminder would be triggered on Thursday, 12 November
  991. X1992.
  992. X.TP
  993. X.B SKIP
  994. XThis keyword causes the reminder to be skipped completely on any omitted
  995. Xdays.  Thus, in the above example, the reminder would not be triggered
  996. Xon 11 November 1992.  However, it would be triggered as usual on the following
  997. XWednesday, 18 November 1992.
  998. X.PP
  999. XThe \fBBEFORE\fR and \fBAFTER\fR keywords move the trigger date of a
  1000. Xreminder to before or after a block of omitted days, respectively.
  1001. XSuppose you normally run a backup on the first day of the month.  However,
  1002. Xif the first day of the month is a weekend or holiday, you run the backup
  1003. Xon the first working day following the weekend or holiday.  You could use:
  1004. X.PP
  1005. X.nf
  1006. X    REM 1 OMIT Sat Sun AFTER RUN do_backup
  1007. X.fi
  1008. X.PP
  1009. XLet's examine how the trigger date is computed.  The \fB1\fR specifies
  1010. Xthe first day of the month.  The local \fBOMIT\fR keyword causes the
  1011. X\fBAFTER\fR keyword to move the reminder forward past weekends.
  1012. XFinally, the \fBAFTER\fR keyword will keep moving the reminder forward
  1013. Xuntil it has passed any holidays specified with global \fBOMIT\fR
  1014. Xcommands.
  1015. X.SH THE INCLUDE COMMAND
  1016. X.PP
  1017. X\fBRemind\fR allows you to include other files in your reminder script,
  1018. Xsimilar to the C preprocessor #include directive.  For example, your
  1019. Xsystem administrator may maintain a file of holidays or system-wide
  1020. Xreminders.  You can include these in your reminder script as follows:
  1021. X.PP
  1022. X.nf
  1023. X    INCLUDE /usr/share/remind/holidays
  1024. X    INCLUDE /usr/share/remind/reminders
  1025. X.fi
  1026. X.PP
  1027. X(The actual pathnames vary from system to system - ask your system
  1028. Xadministrator.)
  1029. X.PP
  1030. X\fBINCLUDE\fR files can be nested up to a depth of 8.
  1031. X.PP
  1032. X.SH THE RUN COMMAND
  1033. X.PP
  1034. XIf you include other files in your reminder script, you may not always
  1035. Xentirely "trust" the contents of the other files.  For example, they
  1036. Xmay contain \fBRUN\fR-type reminders which could be used to access your
  1037. Xfiles or perform undesired actions.  The \fBRUN\fR command can restrict
  1038. Xthis:  If you include the command \fBRUN OFF\fR in your top-level reminder
  1039. Xscript, any reminder or expression which would normally execute a system
  1040. Xcommand is disabled.  \fBRUN ON\fR will re-enable the execution of
  1041. Xsystem commands.  Note that the \fBRUN\fR command can \fIonly\fR be used
  1042. Xin your top-level reminder script; it will \fInot\fR work in any files
  1043. Xaccessed by the \fBINCLUDE\fR command.  This is to protect you from someone
  1044. Xplacing a \fBRUN ON\fR command in an included file.
  1045. X.PP
  1046. XIf you run \fBRemind\fR with the \fB\-r\fR command-line option,
  1047. X\fBRUN\fR-type reminders and the \fBshell()\fR function will be disabled,
  1048. Xregardless of any \fBRUN\fR commands in the reminder script.
  1049. X.PP
  1050. XOne use of the \fBRUN\fR command is to provide a secure interface
  1051. Xbetween \fBRemind\fR and the \fBElm\fR mail system.  The \fBElm\fR
  1052. Xsystem can automatically scan incoming mail for reminder or calendar
  1053. Xentries, and place them in your calendar file.  To use this feature,
  1054. Xyou should set the calendar filename option under \fBElm\fR to be something
  1055. Xlike "~/.reminders.in", \fInot\fR your main reminder file!  This is
  1056. Xso that any \fBRUN ON\fR commands mailed to you can never be activated.
  1057. X.PP
  1058. XThen, you can use the \fBElm\fR \fIscan message for calendar entries\fR
  1059. Xcommand to place reminders prefaced by "->" into .reminders.in.  In
  1060. Xyour main .reminders file, include the following lines:
  1061. X.PP
  1062. X.nf
  1063. X    RUN OFF   # Disable RUN
  1064. X    INCLUDE .reminders.in
  1065. X    RUN ON    # Re-enable RUN
  1066. X.fi
  1067. X.PP
  1068. X.SH THE BANNER COMMAND
  1069. X.PP
  1070. XWhen \fBRemind\fR first issues a reminder, it prints a message like this:
  1071. X.PP
  1072. X.nf
  1073. X    Reminders for Friday, 30th October, 1992 (today):
  1074. X.fi
  1075. X.PP
  1076. XThe \fBBANNER\fR command lets you change the format.  It should appear
  1077. Xbefore any \fBREM\fR commands.  The format is:
  1078. X.PP
  1079. X.RS
  1080. X\fBBANNER\fR \fIformat\fR
  1081. X.RE
  1082. X.PP
  1083. XThe \fIformat\fR is similar to the \fIbody\fR of a \fBREM\fR command.  It
  1084. Xis passed through the substitution filter, with an implicit trigger of
  1085. Xthe current system date.  Thus, the default banner is equivalent to:
  1086. X.PP
  1087. X.nf
  1088. X    BANNER Reminders for %w, %d%s %m, %y%o:
  1089. X.fi
  1090. X.PP
  1091. XYou can disable the banner completely with BANNER %.  Or you can create
  1092. Xa custom banner:
  1093. X.PP
  1094. X.nf
  1095. X    BANNER Hi - here are your reminders for %y/%t/%r:
  1096. X.fi
  1097. X.SH CONTROLLING THE OMIT CONTEXT
  1098. X.PP
  1099. XSometimes, it is necessary to temporarily change the global \fBOMITs\fR
  1100. Xwhich are in force for a few reminders.  Three commands allow you to do
  1101. Xthis:
  1102. X.TP
  1103. X.B PUSH-OMIT-CONTEXT
  1104. XThis command saves the current global \fBOMITs\fR on an internal stack.
  1105. X.TP
  1106. X.B CLEAR-OMIT-CONTEXT
  1107. XThis command clears all of the global \fBOMITs\fR, starting you off with
  1108. Xa "clean slate."
  1109. X.TP
  1110. X.B POP-OMIT-CONTEXT
  1111. XThis command restores the global \fBOMITs\fR which were saved by the most
  1112. Xrecent \fBPUSH-OMIT-CONTEXT\fR.
  1113. X.PP
  1114. XFor example, suppose you have a block of reminders which require a clear
  1115. X\fBOMIT\fR context, and that they also introduce unwanted global \fBOMITs\fR
  1116. Xwhich could interfere with later reminders.  You could use the following
  1117. Xfragment:
  1118. X.PP
  1119. X.nf
  1120. X    PUSH-OMIT-CONTEXT    # Save the current context
  1121. X    CLEAR-OMIT-CONTEXT    # Clean the slate
  1122. X    # Block of reminders goes here
  1123. X    POP-OMIT-CONTEXT    # Restore the saved omit context
  1124. X.fi
  1125. X.SH EXPRESSIONS
  1126. X.PP
  1127. XIn certain contexts, to be described later, \fBRemind\fR will accept
  1128. Xexpressions for evaluation.  \fBRemind\fR expressions resemble C
  1129. Xexpressions, but operate on different types of objects.
  1130. X.PP
  1131. X.B DATA TYPES
  1132. X.PP
  1133. X\fBRemind\fR expressions understand four types of objects:
  1134. X.TP
  1135. X.B INT
  1136. XThe \fBINT\fR data type consists of the integers representable in one machine
  1137. Xword.  The \fBINT\fR data type corresponds to the C "int" type.
  1138. X.TP
  1139. X.B STRING
  1140. XThe \fBSTRING\fR data type consists of strings of characters.  It is
  1141. Xsomewhat comparable to a C character array, but more closely resembles
  1142. Xthe string type in BASIC.
  1143. X.TP
  1144. X.B TIME
  1145. XThe \fBTIME\fR data type consists of times of the day.  The \fBTIME\fR
  1146. Xdata type is internally stored as an integer representing the number
  1147. Xof minutes since midnight.
  1148. X.TP
  1149. X.B DATE
  1150. XThe \fBDATE\fR data type consists of dates (later than 1 January 1990.)
  1151. XInternally, \fBDATE\fR objects are stored as the number of days since
  1152. X1 January 1990.
  1153. X.PP
  1154. X.B CONSTANTS
  1155. X.PP
  1156. XThe following examples illustrate constants in \fBRemind\fR expressions:
  1157. X.TP
  1158. X.B INT constants
  1159. X12, 36, -10, 0, 1209
  1160. X.TP
  1161. X.B STRING constants
  1162. X"Hello there", "This is a test", "\\n\\gosd\\w", ""
  1163. X.PP
  1164. X.RS
  1165. XNote that the empty string is represented by "", and that
  1166. Xbackslashes in a string are \fInot\fR interpreted specially, as in they are
  1167. Xin C.
  1168. X.RE
  1169. X.TP
  1170. X.B TIME constants
  1171. X12:33, 0:01, 14:15, 16:42
  1172. X.PP
  1173. X.RS
  1174. XNote that \fBTIME\fR constants are written in 24-hour format
  1175. X.RE
  1176. X.TP
  1177. X.B DATE constants
  1178. X\fBDATE\fR constants have no readable representation.  They must be
  1179. Xcreated with the \fBdate()\fR function, which takes the year, month
  1180. Xand day as arguments:
  1181. X.PP
  1182. X.RS
  1183. Xdate(1992, 2, 29), date(1996, 4, 2), date(2001, 12, 17)
  1184. X.PP
  1185. XHowever, \fBDATE\fR constants are \fIprinted\fR as
  1186. X\fIyyyy\fR/\fImm\fR/\fIdd\fR.
  1187. X.RE
  1188. X.PP
  1189. X.B OPERATORS
  1190. X.PP
  1191. X\fIRemind\fR has the following operators.  Operators on the same line
  1192. Xhave equal precedence, while operators on lower lines have lower precedence
  1193. Xthan those on higher lines.  The operators approximately correspond to
  1194. XC operators.
  1195. X.PP
  1196. X.nf
  1197. X    !  -     (unary logical negation and arithmetic negation)
  1198. X    *  /  %        
  1199. X    +  -
  1200. X    <  <=  >  >=
  1201. X    ==  !=
  1202. X    &&
  1203. X    ||
  1204. X.fi
  1205. X.PP
  1206. X.B DESCRIPTION OF OPERATORS
  1207. X.PP
  1208. X.TP
  1209. X.B !
  1210. XLogical negation.  Can be applied to an \fBINT\fR type.  If the operand
  1211. Xis non-zero, returns zero.  Otherwise, returns 1.
  1212. X.TP
  1213. X.B \-
  1214. XUnary minus.  Can be applied to an \fBINT\fR.  Returns the negative
  1215. Xof the operand.
  1216. X.TP
  1217. X.B *
  1218. XMultiplication.  Returns the product of two \fBINT\fRs.
  1219. X.TP
  1220. X.B /
  1221. XInteger division.  Returns the quotient of two \fBINT\fRs, discarding the
  1222. Xremainder.
  1223. X.TP
  1224. X.B %
  1225. XModulus.  Returns the remainder upon dividing one \fBINT\fR by another.
  1226. X.TP
  1227. X.B +
  1228. XHas several uses.  These are:
  1229. X.PP
  1230. X.RS
  1231. X\fBINT\fR + \fBINT\fR - returns the sum of two \fBINT\fRs.
  1232. X.PP
  1233. X\fBINT\fR + \fBTIME\fR or \fBTIME\fR + \fBINT\fR - returns a \fBTIME\fR
  1234. Xobtained by adding
  1235. X\fBINT\fR minutes to the original \fBTIME\fR.
  1236. X.PP
  1237. X\fBINT\fR + \fBDATE\fR or \fBDATE\fR + \fBINT\fR - returns a \fBDATE\fR
  1238. Xobtained by adding \fBINT\fR days to the original \fBDATE\fR.
  1239. X.PP
  1240. X\fBSTRING\fR + \fBSTRING\fR - returns a \fBSTRING\fR which is the
  1241. Xconcatenation of the two orignal
  1242. X\fBSTRING\fRs.
  1243. X.PP
  1244. X\fBSTRING\fR + anything or anything + \fBSTRING\fR -
  1245. Xconverts the non-\fBSTRING\fR
  1246. Xargument to a \fBSTRING\fR, and then performs concatenation.  See
  1247. Xthe \fBcoerce()\fR function.
  1248. X.RE
  1249. X.TP
  1250. X.B \-
  1251. XHas several uses.  These are:
  1252. X.PP
  1253. X.RS
  1254. X\fBINT\fR - \fBINT\fR - returns the difference of two \fBINT\fRs.
  1255. X.PP
  1256. X\fBDATE\fR - \fBDATE\fR - returns (as an \fBINT\fR) the difference in days
  1257. Xbetween two \fBDATE\fRs.
  1258. X.PP
  1259. X\fBTIME\fR - \fBTIME\fR - returns (as an \fBINT\fR) the difference in minutes
  1260. Xbetween two \fBTIME\fRs.
  1261. X.PP
  1262. X\fBDATE\fR - \fBINT\fR - returns a \fBDATE\fR which is \fBINT\fR days
  1263. Xearlier than
  1264. Xthe original \fBDATE\fR.
  1265. X.PP
  1266. X\fBTIME\fR - \fBINT\fR - returns a \fBTIME\fR which is \fBINT\fR minutes
  1267. Xearlier
  1268. Xthan the original \fBTIME\fR.
  1269. X.RE
  1270. X.TP
  1271. X.B <, <=, >, and >=
  1272. XThese are the comparison operators.  They can take operands of any type,
  1273. Xbut both operands must be of the same type.  The comparison operators
  1274. Xreturn 1 if the comparison is true, or 0 if it is false.  Note that
  1275. Xstring comparison is done following the lexical ordering of
  1276. Xcharacters on your system, and that upper and lower case \fIare\fR
  1277. Xdistinct for these operators.
  1278. X.TP
  1279. X.B ==, !=
  1280. X== tests for equality, returning 1 if its operands are equal, and
  1281. X0 if they are not.  != tests for inequality.
  1282. X.PP
  1283. X.RS
  1284. XIf the operands are not of the same type, == returns 0 and != returns
  1285. X1.  Again, string comparisons are case-sensitive.
  1286. X.RE
  1287. X.TP
  1288. X.B &&
  1289. XThis is the logical AND operator.  Both of its operands must be of
  1290. Xtype \fBINT\fR.  It returns 1 if both operands are non-zero, and 0
  1291. Xotherwise.
  1292. X.TP
  1293. X.B ||
  1294. XThis is the logical OR operator.  Both of its operands must be of
  1295. Xtype \fBINT\fR.  It returns 1 if either operand is non-zero, and 0
  1296. Xotherwise.
  1297. X.PP
  1298. X.B NOTES
  1299. X.PP
  1300. XOperators of equal precedence are \fIalways\fR evaluated from left
  1301. Xto right, except where parentheses dictate otherwise.  This is important,
  1302. Xbecause the enhanced "+" and "\-" operators are not necessarily associative.
  1303. XFor example:
  1304. X.PP
  1305. X.nf
  1306. X    1 + 2 + "string" + 3 + 4  yields "3string34"
  1307. X    1 + (2 + "string") + (3 + 4)  yields "12string7"
  1308. X    12:59 + 1 + "test"  yields "13:00test"
  1309. X    12:59 + (1 + "test")  yields "12:591test"
  1310. X.fi
  1311. X.PP
  1312. XThe logical operators are \fInot\fR so-called short-circuit operators, as
  1313. Xthey are in C.  Both operands are always evaluated.  Thus, an expression
  1314. Xsuch as:
  1315. X.PP
  1316. X.nf
  1317. X    (f!=0) && (100/f <= 3)
  1318. X.fi
  1319. X.PP
  1320. Xwill cause an error if f is zero.
  1321. X.PP
  1322. X.B VARIABLES
  1323. X.PP
  1324. X\fBRemind\fR allows you to assign values to variables.  The \fBSET\fR
  1325. Xcommand is used as follows:
  1326. X.PP
  1327. X\fBSET\fR \fIvar\fR \fIexpr\fR
  1328. X.PP
  1329. X\fIVar\fR is the name of a variable.  It must start with a letter or
  1330. Xunderscore, and consist only of letters, digits and underscores.  Only
  1331. Xthe first 12 characters of a variable name are significant.  Variable
  1332. Xnames are \fInot\fR case sensitive; thus, "Afoo" and "afOo" are the same
  1333. Xvariable.  Examples:
  1334. X.PP
  1335. X.nf
  1336. X    SET a 10 + (9*8)
  1337. X    SET b "This is a test"
  1338. X    SET mydir getenv("HOME")
  1339. X    SET time 12:15
  1340. X    SET date today()
  1341. X.fi
  1342. X.PP
  1343. XNote that variables themselves have no type.  They take on the type of
  1344. Xwhatever you store in them.
  1345. X.PP
  1346. XTo delete a variable, use the \fBUNSET\fR command:
  1347. X.PP
  1348. X\fBUNSET\fR \fIvar\fR [\fIvar\fR...]
  1349. X.PP
  1350. XFor example, to delete all the variables declared above, use:
  1351. X.PP
  1352. X.nf
  1353. X    UNSET a b mydir time date
  1354. X.fi
  1355. X.PP
  1356. X.B BUILT-IN FUNCTIONS
  1357. X.PP
  1358. X\fBRemind\fR has a plethora of built-in functions.  The syntax for a function
  1359. Xcall is the same as in C - the function name, followed a comma-separated list
  1360. Xof arguments in parentheses.  Function names are not case-sensitive.  If
  1361. Xa function takes no arguments, it must be followed by "()" in the function
  1362. Xcall.  Otherwise, \fBRemind\fR will interpret it as a variable name,
  1363. Xand probably not work correctly.
  1364. X.PP
  1365. XIn the descriptions below, short forms are used to denote acceptable
  1366. Xtypes for the arguments.  The characters "i", "s", "d" and "t" denote
  1367. X\fBINT\fR, \fBSTRING\fR, \fBDATE\fR and \fBTIME\fR arguments,
  1368. Xrespectively.  If an argument can be one of several types, the characters
  1369. Xare concatenated.  For example, "di_arg" denotes an argument which can be
  1370. Xa \fBDATE\fR or an \fBINT\fR.  "x_arg" denotes an argument which can be
  1371. Xof any type.  The type of the argument is followed by
  1372. Xan underscore and an identifier naming the argument, for convenience.
  1373. X.PP
  1374. XThe built-in functions are:
  1375. X.TP
  1376. X.B abs(i_num)
  1377. XReturns the absolute value of \fInum\fR.
  1378. X.TP
  1379. X.B access(s_file, si_mode)
  1380. XTests the access permissions for the file \fIfile\fR.  \fIMode\fR can
  1381. Xbe a string, containing a mix of the characters "rwx" for read,
  1382. Xwrite and execute permission testing.  Alternatively, \fImode\fR can
  1383. Xbe a number as described in the Unix \fBaccess\fR(2) system call.  The
  1384. Xfunction returns 0 if the file can be accessed with the specified \fImode\fR,
  1385. Xand -1 otherwise.
  1386. X.TP
  1387. X.B asc(s_string)
  1388. XReturns an \fBINT\fR which is the ASCII code of the first character
  1389. Xin \fIstring\fR.  As a special case, \fBasc("")\fR returns 0.
  1390. X.TP
  1391. X.B baseyr()
  1392. XReturns the "base year" which was compiled into \fBRemind\fR (normally
  1393. X1990.)  All dates are stored internally as the number of days since
  1394. X1 January of \fBbaseyr()\fR.
  1395. X.TP
  1396. X.B char(i_i1 [,i_i2...])
  1397. XThis function can take any number of \fBINT\fR arguments.  It returns
  1398. Xa \fBSTRING\fR consisting of the characters specified by the arguments.
  1399. XNote that none of the arguments can be 0, unless there is only one
  1400. Xargument.  As a special case, \fBchar(0)\fR returns "".
  1401. X.TP
  1402. X.B choose(i_index, x_arg1 [,x_arg2...])
  1403. X\fBChoose\fR must take at least two arguments, the first of which is
  1404. Xan \fBINT\fR.  If \fIindex\fR is \fIn\fR, then the \fIn\fRth subsequent
  1405. Xargument is returned.  If \fIindex\fR is less than 1, then \fIarg1\fR
  1406. Xis returned.  If \fIindex\fR is greater than the number of subsequent
  1407. Xarguments, then the last argument is returned.  Examples:
  1408. X.PP
  1409. X.nf
  1410. X        \fBchoose(0, "foo", 1:13, 1000)\fR returns "foo"
  1411. X        \fBchoose(1, "foo", 1:13, 1000)\fR returns "foo"
  1412. X        \fBchoose(2, "foo", 1:13, 1000)\fR returns 1:13
  1413. X        \fBchoose(3, "foo", 1:13, 1000)\fR returns 1000
  1414. X        \fBchoose(4, "foo", 1:13, 1000)\fR returns 1000
  1415. X.fi
  1416. X.RS
  1417. XNote that all arguments to \fBchoose()\fR are \fIalways\fR
  1418. Xevaluated.
  1419. X.RE
  1420. X.TP
  1421. X.B coerce(s_type, x_arg)
  1422. XThis function converts \fIarg\fR to the specified \fItype\fR, if such
  1423. Xconversion is possible.  \fIType\fR must be one of "INT", "STRING",
  1424. X"DATE" or "TIME" (case-insensitive).
  1425. XThe conversion rules are as follows:
  1426. X.RS
  1427. X.PP
  1428. XIf \fIarg\fR is already of the \fItype\fR specified, it is returned
  1429. Xunchanged.
  1430. X.PP
  1431. XIf \fItype\fR is "STRING", then \fIarg\fR is converted to a string
  1432. Xconsisting of its printed representation.
  1433. X.PP
  1434. XIf \fItype\fR is "DATE", then an \fBINT\fR \fIarg\fR is converted
  1435. Xby interpreting it as the number of days since 1 January \fBbaseyr()\fR.
  1436. XA \fBSTRING\fR \fIarg\fR is converted by attempting to read it as if
  1437. Xit were a printed date.  A \fBTIME\fR \fIarg\fR cannot be converted to
  1438. Xa date.
  1439. X.PP
  1440. XIf \fItype\fR is "TIME", then an \fBINT\fR \fIarg\fR is converted
  1441. Xby interpreting it as the number of minutes since midnight.
  1442. XA \fBSTRING\fR \fIarg\fR is converted by attempting to read it as if
  1443. Xit were a printed time.  A \fBDATE\fR \fIarg\fR cannot be converted to
  1444. Xa time.
  1445. X.PP
  1446. XIf \fItype\fR is "INT", then \fBDATE\fR and \fBTIME\fR arguments are
  1447. Xconverted using the reverse of procedures described above.  A
  1448. X\fBSTRING\fR \fIarg\fR is converted by parsing it as an integer.
  1449. X.RE
  1450. X.TP
  1451. X.B date(i_y, i_m, i_d)
  1452. XThe \fBdate()\fR function returns a \fBDATE\fR object with the year,
  1453. Xmonth and day components specified by \fIy\fR, \fIm\fR and \fId\fR.
  1454. X.TP
  1455. X.B day(d_date)
  1456. XThis function takes a \fBDATE\fR as an argument, and returns an \fBINT\fR
  1457. Xwhich is the day-of-month component of \fIdate\fR.
  1458. X.TP
  1459. X.B daysimon(i_m, i_y)
  1460. XReturns the number of days in month \fIm\fR (1-12) of the year \fIy\fR.
  1461. X.TP
  1462. X.B defined(s_var)
  1463. XReturns 1 if the variable named by \fIvar\fR is defined, or 0 if it is not.
  1464. X.RS
  1465. XNote that \fBdefined()\fR takes a \fBSTRING\fR argument; thus, to check
  1466. Xif variable X is defined, use:
  1467. X.PP
  1468. X.nf
  1469. X        defined("X")
  1470. X.fi
  1471. X.PP
  1472. Xand not:
  1473. X.PP
  1474. X.nf
  1475. X        defined(X)
  1476. X.fi
  1477. X.PP
  1478. XThe second example will attempt to evaluate X, and will return an
  1479. Xerror if it is undefined or not of type \fBSTRING\fR.
  1480. X.RE
  1481. X.TP
  1482. X.B filename()
  1483. XReturns (as a \fBSTRING\fR) the name of the current file being processed
  1484. Xby \fBRemind\fR.  Inside included files, returns the name of the
  1485. Xincluded file.
  1486. X.TP
  1487. X.B getenv(s_envvar)
  1488. XSimilar to the \fBgetenv\fR(2) system call.  Returns a string representing
  1489. Xthe value of the specified environment variable.  Returns "" if the
  1490. Xenvironment variable is not defined.  Note that the names of environment
  1491. Xvariables are generally case-sensitive; thus, getenv("HOME") is not
  1492. Xthe same as getenv("home").
  1493. X.TP
  1494. X.B hour(t_time)
  1495. XReturns the hour component of \fItime\fR.
  1496. X.TP
  1497. X.B iif(si_test, x_argtrue, x_argfalse)
  1498. XIf \fItest\fR is not zero, and not the null string "", returns
  1499. X\fIargtrue\fR.  Otherwise, returns \fIargfalse\fR.  Note that all
  1500. Xarguments are \fIalways\fR evaluated.
  1501. X.TP
  1502. X.B index(s_search, s_target [,i_start)
  1503. XReturns an \fBINT\fR which is the location of \fItarget\fR in the
  1504. Xstring \fIsearch\fR.  The first character of a string is numbered 1.
  1505. XIf \fItarget\fR does not exist in \fIsearch\fR, then 0 is returned.
  1506. X.RS
  1507. XThe optional parameter \fIstart\fR specifies the position in
  1508. X\fIsearch\fR at which to start looking for \fItarget\fR.
  1509. X.RE
  1510. X.TP
  1511. X.B isleap(id_arg)
  1512. XReturns 1 if \fIarg\fR is a leap year, and 0 otherwise.  \fIArg\fR can
  1513. Xbe either an \fBINT\fR or a \fBDATE\fR object.  If a \fBDATE\fR is
  1514. Xsupplied, then the year component is used in the test.
  1515. X.TP
  1516. X.B isomitted(d_date)
  1517. XReturns 1 if \fIdate\fR is omitted, given the current global \fBOMIT\fR
  1518. Xcontext.  Returns 0 otherwise.
  1519. X.TP
  1520. X.B lower(s_string)
  1521. XReturns a \fBSTRING\fR with all upper-case characters in \fIstring\fR
  1522. Xconverted to lower-case.
  1523. X.TP
  1524. X.B max(x_arg1 [,x_arg2...)
  1525. XCan take any number of arguments, and returns the maximum.  The arguments
  1526. Xcan be of any type, but must all be of the same type.  They are compared
  1527. Xas with the > operator.
  1528. X.TP
  1529. X.B min(x_arg1 [,x_arg2...)
  1530. XCan take any number of arguments, and returns the minimum.  The arguments
  1531. Xcan be of any type, but must all be of the same type.  They are compared
  1532. Xas with the < operator.
  1533. X.TP
  1534. X.B minute(t_time)
  1535. XReturns the minute component of \fItime\fR.
  1536. X.TP
  1537. X.B mon(di_arg)
  1538. XIf \fIarg\fR is of \fBDATE\fR type, returns a string which names the month
  1539. Xcomponent of the date.  If \fIarg\fR is an \fBINT\fR from 1 to
  1540. X12, returns a string which names the month.
  1541. X.TP
  1542. X.B monnum(d_date)
  1543. XReturns an \fBINT\fR from 1 to 12, representing the month component of
  1544. X\fIdate\fR.
  1545. X.TP
  1546. X.B now()
  1547. XReturns the current system time, as a \fBTIME\fR type.
  1548. X.TP
  1549. X.B ord(i_num)
  1550. XReturns a string which is the ordinal number \fInum\fR.  For example,
  1551. X\fBord(2)\fR returns "2nd", and \fBord(213)\fR returns "213th".
  1552. X.TP
  1553. X.B ostype()
  1554. XReturns "UNIX" on UNIX systems, and "MSDOS" on MS-DOS systems.
  1555. X.TP
  1556. X.B plural(i_num [,s_str1 [,s_str2]])
  1557. XCan take from one to three arguments.  If one argument is supplied, returns
  1558. X"s" if \fInum\fR is not 1, and "" if \fInum\fR is 1.
  1559. X.RS
  1560. XIf two arguments are supplied, returns \fIstr1\fR + "s" if \fInum\fR is
  1561. Xnot 1.  Otherwise, returns \fIstr1\fR.
  1562. X.PP
  1563. XIf three arguments are supplied, returns \fIstr1\fR if \fInum\fR is 1, and
  1564. X\fIstr2\fR otherwise.
  1565. X.RE
  1566. X.TP
  1567. X.B realtoday()
  1568. XReturns the date as provided by the operating system.  This is in contrast to
  1569. X\fBRemind\fR's concept of "today", which may be changed if it is running
  1570. Xin calendar mode, or if a date has been supplied on the command line.
  1571. X.TP
  1572. X.B sgn(i_num)
  1573. XReturns -1 if \fInum\fR is negative, 1 if \fInum\fR is positive,
  1574. Xand 0 if \fInum\fR is zero.
  1575. X.TP
  1576. X.B shell(s_cmd)
  1577. XExecutes \fIcmd\fR as a system command, and returns the first 511
  1578. Xcharacters of output resulting from \fIcmd\fR.  Any whitespace
  1579. Xcharacter in the output is converted to a space.  Note that if \fBRUN
  1580. XOFF\fR has been executed, or the \fB\-r\fR command-line option has
  1581. Xbeen used, \fBshell()\fR will result in an error, and \fIcmd\fR will
  1582. Xnot be executed.
  1583. X.TP
  1584. X.B strlen(s_str)
  1585. XReturns the length of \fIstr\fR.
  1586. X.TP
  1587. X.B substr(s_str, i_start [,i_end])
  1588. XReturns a \fBSTRING\fR consisting of all characters in \fIstr\fR from
  1589. X\fIstart\fR up to and including \fIend\fR.  Characters are numbered
  1590. Xfrom 1.  If \fIend\fR is not supplied, then it defaults to the length
  1591. Xof \fIstr\fR.
  1592. X.TP
  1593. X.B time(i_hr, i_min)
  1594. XCreates a \fBTIME\fR with the hour and minute components specified by
  1595. X\fIhr\fR and \fImin\fR.
  1596. X.TP
  1597. X.B today()
  1598. XReturns \fBRemind\fR's notion of "today."  This may be the actual system
  1599. Xdate, or a date supplied on the command line, or the date of the
  1600. Xcalendar entry currently being computed.
  1601. X.TP
  1602. X.B trigdate()
  1603. XReturns the calculated trigger date of the last \fBREM\fR command.  If used
  1604. Xin the \fIbody\fR of a \fBREM\fR command, returns that command's trigger date.
  1605. X.TP
  1606. X.B trigger(d_date)
  1607. XReturns a string suitable for use in a \fBREM\fR command, allowing you to
  1608. Xcalculate trigger dates in advance.  See the section "Expression pasting"
  1609. Xfor more information.
  1610. X.TP
  1611. X.B trigtime()
  1612. XReturns the time of the last \fBREM\fR command with an \fBAT\fR clause.
  1613. X.TP
  1614. X.B trigvalid()
  1615. XReturns 1 if the value returned by \fBtrigdate()\fR is valid for the most
  1616. Xrecent \fBREM\fR command, or 0 otherwise.  Sometimes \fBREM\fR commands
  1617. Xcannot calculate a trigger date.  For example, the following \fBREM\fR
  1618. Xcommand can never be triggered:
  1619. X.PP
  1620. X.nf
  1621. X        REM Mon OMIT Mon SKIP MSG Impossible!
  1622. X.fi
  1623. X.PP
  1624. X.TP
  1625. X.B typeof(x_arg)
  1626. XReturns "STRING", "INT", "DATE" or "TIME", depending on the type of \fIarg\fR.
  1627. X.TP
  1628. X.B upper(s_string)
  1629. XReturns a \fBSTRING\fR with all lower-case characters in \fIstring\fR
  1630. Xconverted to upper-case.
  1631. X.TP
  1632. X.B value(s_varname [,x_default])
  1633. XReturns the value of the specified variable.  For example, value("X"+"Y")
  1634. Xreturns the value of variable XY, if it is defined.  If XY is not defined,
  1635. Xan error results.
  1636. X.RS
  1637. XHowever, if you supply a second argument, it is returned if the \fIvarname\fR
  1638. Xis not defined.  The expression value("XY", 0) will return 0 if XY is not
  1639. Xdefined, and the value of XY if it is defined.
  1640. X.RE
  1641. X.TP
  1642. X.B version()
  1643. XReturns a string specifying the version of \fBRemind\fR.  For version 
  1644. X03.00.00, returns "03.00.00".  It is guaranteed that as new versions of
  1645. X\fBRemind\fR are released, the value returned by \fBversion()\fR will
  1646. Xstrictly increase, according to the rules for string ordering.
  1647. X.TP
  1648. X.B wkday(di_arg)
  1649. XIf \fIarg\fR is a \fBDATE\fR, returns a string representing the day of the
  1650. Xweek of the date.  If \fIarg\fR is an \fBINT\fR from 0 to 6, returns
  1651. Xthe corresponding weekday ("Sunday" to "Saturday").
  1652. X.TP
  1653. X.B wkdaynum(d_date)
  1654. XReturns a number from 0 to 6 representing the day-of-week of the specified
  1655. X\fIdate\fR.  (0 represents Sunday, and 6 represents Saturday.)
  1656. X.TP
  1657. X.B year(d_date)
  1658. XReturns a \fBINT\fR which is the year component of \fIdate\fR.
  1659. X.SH EXPRESSION PASTING
  1660. X.PP
  1661. XAn extremely powerful feature of \fBRemind\fR is its macro capability,
  1662. Xor "expression pasting."
  1663. X.PP
  1664. XIn almost any situation where \fBRemind\fR is not expecting an expression,
  1665. Xyou can "paste" an expression in.  To do this, surround the expression
  1666. Xwith square brackets.  For example:
  1667. X.PP
  1668. X.nf
  1669. X    REM [trigger(mydate)] MSG foo
  1670. X.fi
  1671. X.PP
  1672. XThis evaluates the expression "trigger(mydate)", where "mydate" is
  1673. Xpresumably some pre-computed variable, and then "pastes" the result
  1674. Xinto the command-line for the parser to process.
  1675. X.PP
  1676. XA formal description of this is:  When \fBRemind\fR encounters a
  1677. X"pasted-in" expression, it evaluates the expression, and coerces the
  1678. Xresult to a \fBSTRING\fR.  It then substitutes the string for the
  1679. Xpasted-in expression, and continues parsing.  Note, however, that
  1680. Xexpressions are evaluated only once, not recursively.  Thus, writing:
  1681. X.PP
  1682. X.nf
  1683. X    ["[a+b]"]
  1684. X.fi
  1685. X.PP
  1686. Xcauses \fBRemind\fR to read the token "[a+b]".  It does not interpret
  1687. Xthis as a pasted-in expression.  In fact, the only way to get a literal
  1688. Xleft-bracket into a reminder is to use ["["].
  1689. X.PP
  1690. XYou can use expression pasting almost anywhere.  However, there are a few
  1691. Xexceptions:
  1692. X.TP
  1693. Xo
  1694. XIf \fBRemind\fR is expecting an expression, as in the \fBSET\fR command,
  1695. Xor the \fBIF\fR command, then no expression pasting takes place.  The
  1696. Xexpression is simply evaluated as if the square brackets were not there.
  1697. X.TP
  1698. Xo
  1699. XYou cannot use expression pasting for the first token on a line.
  1700. XFor example, the following will not work:
  1701. X.PP
  1702. X.nf
  1703. X        ["SET"] a 1
  1704. X.fi
  1705. X.RS
  1706. XThis restriction is because \fBRemind\fR must be able to unambiguously
  1707. Xdetermine the first token of a line for the flow-control commands (to
  1708. Xbe discussed later.)
  1709. X.PP
  1710. XIn fact, if \fBRemind\fR cannot determine the first token on a line, it
  1711. Xassumes that it is a \fBREM\fR command.  If expression-pasting is used,
  1712. X\fBRemind\fR assumes it is a \fBREM\fR command.  Thus, the following
  1713. Xthree commands are equivalent:
  1714. X.PP
  1715. X.nf
  1716. X        REM 12 Nov 1993 AT 13:05 MSG BOO!
  1717. X        12 Nov 1993 AT 13:05 MSG BOO!
  1718. X        [12] ["Nov " + 1993] AT [12:05+60] MSG BOO!
  1719. X.fi
  1720. X.RE
  1721. X.TP
  1722. Xo
  1723. XYou cannot use expression-pasting to determine the type (\fBMSG\fR,
  1724. X\fBCAL\fR, etc.) of a \fBREM\fR command.  You can paste expressions
  1725. Xbefore and after the \fBMSG\fR, etc keywords, but cannot do something like
  1726. Xthis:
  1727. X.PP
  1728. X.nf
  1729. X        REM ["12 Nov 1993 AT 13:05 " + "MSG" + " BOO!"]
  1730. X.fi
  1731. X.PP
  1732. X.B COMMON PITFALLS IN EXPRESSION PASTING
  1733. X.PP
  1734. XRemember, when pasting in expressions, that extra spaces are not
  1735. Xinserted.  Thus, something like:
  1736. X.PP
  1737. X.nf
  1738. X    REM[expr]MSG[expr]
  1739. X.fi
  1740. X.PP
  1741. Xwill probably fail.
  1742. X.PP
  1743. XIf you use an expression to calculate a \fIdelta\fR or \fIback\fR,
  1744. Xensure that the result is a positive number.  Something like:
  1745. X.PP
  1746. X.nf
  1747. X    REM +[mydelta] Nov 12 1993 MSG foo
  1748. X.fi
  1749. X.PP
  1750. Xwill fail if \fImydelta\fR happens to be negative.
  1751. X.PP
  1752. X.SH FLOW CONTROL COMMANDS
  1753. X.PP
  1754. X\fBRemind\fR has commands which control the flow of a reminder script.
  1755. XNormally, reminder scripts are processed sequentially.  However,
  1756. X\fBIF\fR and related commands allow you to process files conditionally,
  1757. Xand skip sections which you don't want interpreted.
  1758. X.PP
  1759. X.B THE IF COMMAND
  1760. X.PP
  1761. XThe \fBIF\fR command has the following form:
  1762. X.PP
  1763. X.nf
  1764. X    IF expr
  1765. X        t-command
  1766. X        t-command...
  1767. X    ELSE
  1768. X        f-command
  1769. X        f-command...
  1770. X    ENDIF
  1771. X.fi
  1772. X.PP
  1773. XNote that the commands are shown indented for clarity.  Also, the \fBELSE\fR
  1774. Xportion can be omitted.  \fBIF\fR commands can be nested up to a small limit,
  1775. Xprobably around 8 or 16 levels of nesting, depending on your system.
  1776. X.PP
  1777. XIf the \fIexpr\fR evaluates to a non-zero \fBINT\fR, or a non-null
  1778. X\fBSTRING\fR, then the \fBIF\fR portion is considered true, and the
  1779. X\fIt-commands\fR are executed.  If \fIexpr\fR evaluates to zero or
  1780. Xnull, then the \fIf-commands\fR (if the \fBELSE\fR portion is present)
  1781. Xare executed.  If \fIexpr\fR is not of type \fBINT\fR or \fBSTRING\fR,
  1782. Xthen it is an error.
  1783. X.PP
  1784. XExamples:
  1785. X.PP
  1786. X.nf
  1787. X    IF defined("want_hols")
  1788. X        INCLUDE /usr/share/remind/holidays
  1789. X    ENDIF
  1790. X
  1791. X    IF today() > date(1992, 2, 10)
  1792. X        set missed_ap "You missed it!"
  1793. X    ELSE
  1794. X        set missed_ap "Still have time..."
  1795. X    ENDIF
  1796. X.fi
  1797. X.PP
  1798. X.B THE IFTRIG COMMAND
  1799. X.PP
  1800. XThe \fBIFTRIG\fR command is similar to an \fBIF\fR command, except
  1801. Xthat it computes a trigger (as in the \fBREM\fR command), and evaluates
  1802. Xto true if a corresponding \fBREM\fR command would trigger.  Examples:
  1803. X.PP
  1804. X.nf
  1805. X    IFTRIG 1 Nov
  1806. X        ; Executed on 1 Nov
  1807. X    ELSE
  1808. X        ; Executed except on 1 Nov
  1809. X    ENDIF
  1810. X
  1811. X    IFTRIG 1 -1 OMIT Sat Sun +4
  1812. X        ; Executed on last working day of month,
  1813. X        ; and the 4 working days preceding it
  1814. X    ELSE
  1815. X        ; Executed except on above days
  1816. X    ENDIF
  1817. X.fi
  1818. X.PP
  1819. XNote that the \fBIFTRIG\fR command computes a trigger date, which can
  1820. Xbe retrieved with the \fBtrigdate()\fR function.  You can use all of
  1821. Xthe normal trigger components, such as \fBUNTIL\fR, \fIdelta\fR, etc in the
  1822. X\fBIFTRIG\fR command.
  1823. X.PP
  1824. X.SH USER-DEFINED FUNCTIONS
  1825. X.PP
  1826. XIn addition to the built-in functions, \fBRemind\fR allows you to define
  1827. Xyour own functions.  The \fBFSET\fR command does this for you:
  1828. X.PP
  1829. X\fBFSET\fR \fIfname\fR(\fIargs\fR) \fIexpr\fR
  1830. X.PP
  1831. X\fIFname\fR is the name of the function, and follows the convention for
  1832. Xnaming variables.  \fIArgs\fR is a comma-separated list of arguments, and
  1833. X\fIexpr\fR is an expression.  \fIArgs\fR can be empty, in which case
  1834. Xyou define a function taking no parameters.  Here are some examples:
  1835. X.PP
  1836. X.nf
  1837. X    FSET double(x) 2*x
  1838. X    FSET yeardiff(date1, date2) year(date1) - year(date2)
  1839. X    FSET since(x) ord(year(trigdate())-x)
  1840. X.fi
  1841. X.PP
  1842. XThe last function is useful in birthday reminders.  For example:
  1843. X.PP
  1844. X.nf
  1845. X    REM 1 Nov +12 MSG Dean's [since(1984)] birthday is %b.
  1846. X.fi
  1847. X.PP
  1848. XDean was born in 1984.  The above example, on 1 November 1992, would print:
  1849. X.PP
  1850. X.nf
  1851. X    Dean's 8th birthday is today.
  1852. X.fi
  1853. X.PP
  1854. XNotes:
  1855. X.TP
  1856. Xo
  1857. XIf you access a variable in \fIexpr\fR which is not in the list of arguments,
  1858. Xthe "global" value (if any) is used.
  1859. X.TP
  1860. Xo
  1861. XFunction and parameter names are significant only to 12 characters.
  1862. X.TP
  1863. Xo
  1864. XThe \fBvalue()\fR function \fIalways\fR accesses the "global" value of a
  1865. Xvariable, even if it has the same name as an argument.  For example:
  1866. X.RS
  1867. X.nf
  1868. X        fset func(x) value("x")
  1869. X        set x 1
  1870. X        set y func(5)
  1871. X.fi
  1872. X.PP
  1873. XThe above sequence sets y to 1, which is the global value of x.
  1874. X.RE
  1875. X.TP
  1876. Xo
  1877. XUser-defined functions may call other functions, including other user-defined
  1878. Xfunctions.  However, recursive calls are not allowed.
  1879. X.TP
  1880. Xo
  1881. XUser-defined functions are not syntax-checked when they are defined; parsing
  1882. Xoccurs only when they are called.
  1883. X.TP
  1884. Xo
  1885. XIf a user-defined function has the same name as a built-in function,
  1886. Xit is ignored and the built-in function is used.  To prevent conflicts
  1887. Xwith future versions of \fBRemind\fR (which may define more built-in
  1888. Xfunctions), you may wish to name all user-defined functions beginning
  1889. Xwith an underscore.
  1890. X.PP
  1891. X.SH THE SATISFY CLAUSE
  1892. X.PP
  1893. XThe form of \fBREM\fR which uses \fBSATISFY\fR is as follows:
  1894. X.PP
  1895. X\fBREM\fR \fItrigger\fR \fBSATISFY\fR \fIexpr\fR
  1896. X.PP
  1897. XThe way this works is as follows:  \fBRemind\fR first calculates a trigger
  1898. Xdate, in the normal fashion.  Next, it sets \fBtrigdate()\fR to the
  1899. Xcalculated trigger date.  It then evaluates \fIexpr\fR.  If the result
  1900. Xis not the null string or zero, processing
  1901. Xends.  Otherwise, \fBRemind\fR computes the next trigger date, and re-tests
  1902. X\fIexpr\fR.  This iteration continues until \fIexpr\fR evaluates to non-zero
  1903. Xor non-null, or until the iteration limit specified with the \fB\-x\fR
  1904. Xcommand-line option is reached.
  1905. X.PP
  1906. XIf \fIexpr\fR is not satisfied, then \fBtrigvalid()\fR is set to 0.
  1907. XOtherwise, \fBtrigvalid()\fR is set to 1.  In any event, no error message
  1908. Xis issued.
  1909. X.PP
  1910. XThis is really useful only if \fIexpr\fR involves a call to the
  1911. X\fBtrigdate()\fR function; otherwise, \fIexpr\fR will not change as
  1912. X\fBRemind\fR iterates.
  1913. X.PP
  1914. XAn example of the usefulness of \fBSATISFY\fR:  Suppose you wish to
  1915. Xbe warned of every Friday the 13th.  Your first attempt may be:
  1916. X.PP
  1917. X.nf
  1918. X    # WRONG!
  1919. X    REM Fri 13 +2 MSG Friday the 13th is %b.
  1920. X.fi
  1921. X.PP
  1922. XBut this won't work.  This reminder triggers on the first Friday
  1923. Xon or after the 13th of each month.  The way to do it is with a
  1924. Xmore complicated sequence:
  1925. X.PP
  1926. X.nf
  1927. X    REM 13 SATISFY wkdaynum(trigdate()) == 5
  1928. X    IF trigvalid()
  1929. X        REM [trigger(trigdate())] +2 MSG \\
  1930. X        Friday the 13th is %b.
  1931. X    ENDIF
  1932. X.fi
  1933. X.PP
  1934. XLet's see how this works.  The \fBSATISFY\fR clause iterates through
  1935. Xall the 13ths of successive months, until a trigger date is found whose
  1936. Xday-of-week is Friday (== 5).  If a valid date was found, we use the
  1937. Xcalculated trigger date (converted into a trigger format with the
  1938. X\fBtrigger()\fR function) to set up the next reminder.
  1939. X.PP
  1940. XWe could also have written:
  1941. X.PP
  1942. X.nf
  1943. X    REM Fri SATISFY day(trigdate()) == 13
  1944. X.fi
  1945. X.PP
  1946. Xbut this would result in more iterations, since "Fridays" occur more
  1947. Xoften than "13ths of the month."
  1948. X.PP
  1949. XThis technique of using one \fBREM\fR command to calculate a trigger date
  1950. Xto be used by another command is quite powerful.  For example, suppose
  1951. Xyou wanted to OMIT Labour day, which is the first Monday in September.  You
  1952. Xcould use:
  1953. X.PP
  1954. X.nf
  1955. X    # Note: SATISFY 1 is an idiom for "do nothing"
  1956. X    REM Mon 1 Sept SATISFY 1
  1957. X    OMIT [trigger(trigdate())]
  1958. X.fi
  1959. X.PP
  1960. X\fBCAVEAT:\fR This \fIonly\fR omits the \fInext\fR Labour Day, not
  1961. Xall Labour Days in the future.  This could cause strange results, as
  1962. Xthe \fBOMIT\fR context can change depending on the current date.  For
  1963. Xexample, if you use the following command after the above commands:
  1964. X.PP
  1965. X.nf
  1966. X    REM Mon AFTER msg hello
  1967. X.fi
  1968. X.PP
  1969. Xthe result will not be as you expect.  Consider producing a calendar
  1970. Xfor September, 1992.  Labour Day was on Monday, 7 September, 1992.
  1971. XHowever, when \fBRemind\fR gets around to calculating the trigger
  1972. Xfor Tuesday, 8 September, 1992, the \fBOMIT\fR command will now be
  1973. Xommitting Labour Day for 1993, and the "Mon AFTER" command
  1974. Xwill not be triggered.
  1975. X.PP
  1976. XIt is probably best to stay away from computing \fBOMIT\fR
  1977. Xtrigger dates unless you keep these pitfalls in mind.
  1978. X.PP
  1979. X.SH DEBUGGING REMINDER SCRIPTS
  1980. X.PP
  1981. XAlthough the command-line \fB\-d\fR option is useful for debugging, it
  1982. Xis often overkill.  For example, if you turn on the \fB\-dx\fR option for
  1983. Xa reminder file with many complex expressions, you'll get a huge amount of
  1984. Xoutput.  The \fBDEBUG\fR command allows you to control the debugging flags
  1985. Xunder program control.  The format is:
  1986. X.PP
  1987. X\fBDEBUG\fR [+\fIflagson\fR] [\-\fIflagsoff\fR]
  1988. X.PP
  1989. X\fIFlagson\fR and \fIflagsoff\fR consist of strings of the characters "extvl"
  1990. Xwhich correspond to the debugging options discussed in the command-line
  1991. Xoptions section.  If preceded with a "+", the corresponding group of
  1992. Xdebugging options is switched on.  Otherwise, they are switched off.
  1993. XFor example, you could use this sequence to debug a complicated expression:
  1994. X.PP
  1995. X.nf
  1996. X    DEBUG +x
  1997. X    set a very_complex_expression(many_args)
  1998. X    DEBUG \-x
  1999. X.fi
  2000. X.PP
  2001. X.B THE DUMPVARS COMMAND
  2002. X.PP
  2003. XThe command \fBDUMPVARS\fR displays the values of variables in memory.  Its
  2004. Xformat is:
  2005. X.PP
  2006. X\fBDUMPVARS\fR [\fIvar\fR...]
  2007. X.PP
  2008. XIf you supply a space-separated list of variable names, the corresponding
  2009. Xvariables are displayed.  If you do not supply a list of variables, then
  2010. Xall variables in memory are displayed.
  2011. X.PP
  2012. X.B THE ERRMSG COMMAND
  2013. X.PP
  2014. XThe \fBERRMSG\fR command has the following format:
  2015. X.PP
  2016. X\fBERRMSG\fR \fIbody\fR
  2017. X.PP
  2018. XThe \fIbody\fR is passed through the substitution filter (with an
  2019. Ximplicit trigger date of \fBtoday()\fR) and printed to the error
  2020. Xoutput stream.  Example:
  2021. X.PP
  2022. X.nf
  2023. X    IF !defined("critical_var")
  2024. X        ERRMSG You must supply a value for "critical_var"
  2025. X        EXIT
  2026. X    ENDIF
  2027. X.fi
  2028. X.PP
  2029. X.B THE EXIT COMMAND
  2030. X.PP
  2031. XThe above example also shows the use of the \fBEXIT\fR command.  This
  2032. Xcauses an unconditional exit from script processing.  Any queued
  2033. Xtimed reminders are discarded.  If you are in calendar mode
  2034. X(described next), then the calendar processing is aborted.
  2035. X.PP
  2036. X.SH CALENDAR MODE
  2037. X.PP
  2038. XIf you supply the \fB\-c\fR or \fB\-s\fR command-line option, the \fBRemind\fR
  2039. Xruns in "calendar mode."  In this mode, \fBRemind\fR interprets the script
  2040. Xrepeatedly, performing one iteration through the whole file for each day
  2041. Xin the calendar.  Reminders which trigger are saved in internal buffers,
  2042. Xand then inserted into the calendar in the appropriate places.
  2043. X.PP
  2044. XFor example, if you have a reminder script called ".reminders", and you
  2045. Xexecuted this command:
  2046. X.PP
  2047. X.nf
  2048. X    remind -c .reminders jan 1993
  2049. X.fi
  2050. X.PP
  2051. Xthen \fBRemind\fR executes the script 31 times, once for each day in
  2052. XJanuary.  Each time it executes the script, it increments the value
  2053. Xof \fBtoday()\fR.  Any reminders whose trigger date matches \fBtoday()\fR
  2054. Xare entered into the calendar.
  2055. X.PP
  2056. X\fBMSG\fR and \fBCAL\fR-type reminders, by default, have their entire
  2057. Xbody inserted into the calendar.  \fBRUN\fR-type reminders are not
  2058. Xnormally inserted into the calendar.  However, if you enclose a portion of
  2059. Xthe body in the %"...%" sequence, only that portion is inserted.  For
  2060. Xexample, consider the following:
  2061. X.PP
  2062. X.nf
  2063. X    REM 6 Jan MSG %"David's birthday%" is %b
  2064. X.fi
  2065. X.PP
  2066. XIn the normal mode, \fBRemind\fR would print "David's birthday is today"
  2067. Xon 6 January.  However, in the calendar mode, only the text "David's birthday"
  2068. Xis inserted into the box for 6 January.
  2069. X.PP
  2070. XIf you explicitly use the %"...%" sequence in a \fBRUN\fR-type reminder,
  2071. Xthen the text between the delimiters is inserted into the calendar.
  2072. XIf you use the sequence %"%" in a \fBMSG\fR or \fBCAL\fR-type reminder, then
  2073. Xno calendar entry is produced for that reminder.
  2074. X.PP
  2075. X.B PRESERVING VARIABLES
  2076. X.PP
  2077. XBecause \fBRemind\fR iterates through the script for each day in the calendar,
  2078. Xslow operations may severely reduce the speed of producing a calendar.
  2079. X.PP
  2080. XFor example, suppose you set the variables "me" and "hostname" as follows:
  2081. X.PP
  2082. X.nf
  2083. X    SET me shell("whoami")
  2084. X    SET hostname shell("hostname")
  2085. X.fi
  2086. X.PP
  2087. XNormally, \fBRemind\fR clears all variables between iterations in calendar
  2088. Xmode.  However, if certain variables are slow to compute, and will
  2089. Xnot change between iterations, you can "preserve" their values with the
  2090. X\fBPRESERVE\fR command.  Also, since function definitions are preserved
  2091. Xbetween calendar iterations, there is no need to redefine them on each
  2092. Xiteration.  Thus, you could use the following sequence:
  2093. X.PP
  2094. X.nf
  2095. X    IF ! defined("initialized")
  2096. X        set initialized 1
  2097. X        set me shell("whoami")
  2098. X        set hostname shell("hostname")
  2099. X        fset func complex_expr()
  2100. X        preserve initialized me hostname
  2101. X    ENDIF
  2102. X.fi
  2103. X.PP
  2104. XThe operation is as follows:  On the first iteration through the script,
  2105. X"initialized" is not defined.  Thus, the commands between \fBIF\fR and
  2106. X\fBENDIF\fR are executed.  The \fBPRESERVE\fR command ensures that the
  2107. Xvalues of initialized, me and hostname are preserved for subsequent
  2108. Xiterations.  On the next iteration, the commands are skipped, since
  2109. Xinitialized has remained defined.  Thus, time-consuming operations which
  2110. Xdo not depend on the value of \fBtoday()\fR are done only once.
  2111. X.PP
  2112. XNote that for efficiency, \fBRemind\fR caches the reminder script
  2113. X(and any \fBINCLUDE\fRd files) in memory when producing a calendar.
  2114. X.PP
  2115. XTimed reminders are sorted and placed into the calendar in time order.
  2116. XThese are followed by non-timed reminders.  \fBRemind\fR automatically
  2117. Xplaces the time of timed reminders in the calendar according to the
  2118. X\fB\-b\fR command-line option.
  2119. X.PP
  2120. X.SH DAEMON MODE
  2121. X.PP
  2122. XIf you use the \fB\-z\fR command-line option, \fBRemind\fR runs in the
  2123. X"daemon" mode.  In this mode, no "normal" reminders are issued.
  2124. XInstead, only timed reminders are collected and queued, and are then
  2125. Xissued whenever they reach their trigger time.
  2126. X.PP
  2127. XIn addition, \fBRemind\fR wakes up every few minutes to check the modification
  2128. Xdate on the reminder script (the filename supplied on the command line.)
  2129. XIf \fBRemind\fR detects that the script has changed, it re-executes itself
  2130. Xin daemon mode, and interprets the changed script.
  2131. X.PP
  2132. XIn daemon mode, \fBRemind\fR also re-reads the remind script when it
  2133. Xdetects that the system date has changed.
  2134. X.PP
  2135. XIn daemon mode, \fBRemind\fR acts as if the \fB\-f\fR option had been used,
  2136. Xso to run in the daemon mode in the background, use:
  2137. X.PP
  2138. X.nf
  2139. X    remind -z .reminders &
  2140. X.fi
  2141. X.PP
  2142. XIf you use \fBsh\fR or \fBbash\fR, you may have to use the "nohup" command
  2143. Xto ensure that the daemon is not killed whn you log out.
  2144. X.PP
  2145. X.SH MISCELLANEOUS
  2146. X.PP
  2147. X.B COMMAND ABBREVIATIONS
  2148. X.PP
  2149. XThe following commands can be abbreviated:
  2150. X.TP
  2151. Xo
  2152. X\fBREM\fR can be omitted - it is implied if no other valid command
  2153. Xis present.
  2154. X.TP
  2155. Xo
  2156. X\fBCLEAR-OMIT-CONTEXT\fR --> \fBCLEAR\fR
  2157. X.TP
  2158. Xo
  2159. X\fBPUSH-OMIT-CONTEXT\fR --> \fBPUSH\fR
  2160. X.TP
  2161. Xo
  2162. X\fBPOP-OMIT-CONTEXT\fR --> \fBPOP\fR
  2163. X.TP
  2164. Xo
  2165. X\fBDUMPVARS\fR --> \fBDUMP\fR
  2166. X.TP
  2167. Xo
  2168. X\fBBANNER\fR --> \fBBAN\fR
  2169. X.TP
  2170. Xo
  2171. X\fBINCLUDE\fR --> \fBINC\fR
  2172. X.PP
  2173. X.B NIFTY EXAMPLES
  2174. X.PP
  2175. XThis section is a sampling of what you can do with \fBRemind\fR.
  2176. X.PP
  2177. X.nf
  2178. X    REM 5 Feb 1991 AT 14:00 +45 *30 \\
  2179. X    RUN mail -s "Meeting at %2" $LOGNAME </dev/null &
  2180. X.fi
  2181. X.PP
  2182. XOn 5 February, 1991, this reminder will mail
  2183. Xyou reminders of a 2:00pm meeting at 1:15,
  2184. X1:45 and 2:00.  The subject of the mail message will be "Meeting at 2:00pm"
  2185. Xand the body of the message will be blank.
  2186. X.PP
  2187. X.nf
  2188. X    REM AT 17:00 RUN echo "5:00pm - GO HOME!" | xless -g +0+0 &
  2189. X.fi
  2190. X.PP
  2191. XThis reminder will pop up an xless window at 5:00pm every day.  The xless
  2192. Xwindow will contain the line "5:00pm - GO HOME!"
  2193. X.PP
  2194. X.nf
  2195. X    REM AT 23:59 RUN (sleep 120; remind -a [filename()]) &
  2196. X.fi
  2197. X.PP
  2198. XThis reminder will run at one minute to midnight.  It will cause a new
  2199. Xremind process to start at one minute past midnight.  This allows you to
  2200. Xhave a continuous reminder service so you can work through the night and
  2201. Xstill get timed reminders for early in the morning.  Note that this
  2202. Xtrick is no longer necessary, providing you run \fBRemind\fR in
  2203. Xdaemon mode.
  2204. X.PP
  2205. X.nf
  2206. X    remind \-c12 /dev/null Jan 1993
  2207. X.fi
  2208. X.PP
  2209. XThis invocation of \fBremind\fR will cause it to print a calendar for
  2210. X1993, with all entries left blank.
  2211. X.PP
  2212. X.nf
  2213. X    REM CAL [trigdate()-date(year(trigdate()), 1, 1)+1]
  2214. X.fi
  2215. X.PP
  2216. XThis example puts an entry in each box of a calendar showing the number
  2217. X(1-365 or 366) of the day of the year.
  2218. X.PP
  2219. X.nf
  2220. X    REM Tue 2 Nov SATISFY (year(trigdate())%4) == 0
  2221. X    IF trigvalid()
  2222. X        REM [trigger(trigdate())] ++5 MSG \\
  2223. X        U.S. Presidential Election!!
  2224. X    ENDIF
  2225. X.fi
  2226. X.PP
  2227. XThis example warns you 5 days ahead of each American presidential
  2228. Xelection.  The first \fBREM\fR command calculates the first Tuesday after
  2229. Xthe first Monday in November.  (This is equivalent to the first
  2230. XTuesday on or after 2 November.)  The \fBSATISFY\fR clause ensures
  2231. Xthat the trigger date is issued only in election years, which are
  2232. Xmultiples of 4.  The second \fBREM\fR command actually issues the
  2233. Xreminder.
  2234. X.SH AUTHOR
  2235. X.PP
  2236. XDavid F. Skoll
  2237. X.SH BUGS
  2238. X.PP
  2239. XDate calculation is a bit "brute force."
  2240. X.PP
  2241. XThe MS-DOS version of \fBRemind\fR does not support queuing or timed
  2242. Xactivation of reminders.
  2243. X.PP
  2244. X\fBRemind\fR has some built-in limits on total line length,
  2245. Xsubstitution buffer length, number of global \fBOMIT\fRs, etc.
  2246. X.PP
  2247. X.SH SEE ALSO
  2248. X.pp
  2249. Xrem, elm, kall
  2250. SHAR_EOF
  2251. $TOUCH -am 1109141292 remind.1 &&
  2252. chmod 0600 remind.1 ||
  2253. echo "restore of remind.1 failed"
  2254. set `wc -c remind.1`;Wc_c=$1
  2255. if test "$Wc_c" != "71460"; then
  2256.     echo original size 71460, current size $Wc_c
  2257. fi
  2258. fi
  2259. echo "End of part 11, continue with part 12"
  2260. exit 0
  2261.  
  2262. exit 0 # Just in case...
  2263.