The enclosed code works fine if I use: [* if ((($daycnt-1) % 7) == 0) { *] however if I make it [$ if ((($daycnt-1) % 7) == 0) $] it seems to execute (at least partially, it's not clear that everything inside gets executed) every time. Am I missing something about variable scope? Or is something wrong here? Note that the [$ is being executed within a [* loop. I've stripped a bunch out of the code, so do't expect it to make a lot of sense otherwise. <HEAD><TITLE>Monthly Calendar</TITLE> <script language="JavaScript"> <!-- function MM_displayStatusMsg(msgStr) { //v1.2 status=msgStr; document.MM_returnValue = true; } //--> </script> </HEAD> <body> <CENTER> <P> <FONT SIZE="-1"> Choose your view: <A HREF="calendar.html?CurView=dayview&time=">Today's Events</A> | <FONT COLOR="#555555">This Month's Calendar</FONT> | <A HREF="calendar.html?CurView=listview&time=&month=&year=">This Month's Listing</A> <BR> </FONT> <TABLE BORDER="1" CELLPADDING="4" WIDTH=100%> <TR> <TD COLSPAN=14 ALIGN=CENTER> </TD> </TR> <TR> <TD COLSPAN=14 ALIGN=CENTER> <FONT SIZE="+2" COLOR="#800000"></FONT> </TD> </TR> <tr> <th align=center colspan=2>[+ 7 +]</th> <th align=center colspan=2>[+ 1 +]</th> <th align=center colspan=2>[+ 2 +]</th> <th align=center colspan=2>[+ 3 +]</th> <th align=center colspan=2>[+ 4 +]</th> <th align=center colspan=2>[+ 5 +]</th> <th align=center colspan=2>[+ 6 +]</th> </tr> [- $NDays = 31; # Mon=1, Sun=7 $FirstDOW = 3; if ($FirstDOW == 7) { $Offset = 0; } else { $Offset = $FirstDOW; } $EndPoint = ($NDays + $Offset) - (($NDays + $Offset) % 7); $EndPoint += $Offset + 1; $BegPoint = 0 - $Offset; #$dbgEval = 1; -] <tr> [* for ($i = 0; $i < 7; ++$i) { *] <td align=left width="4%" bgcolor="#EEEEEE"> </td> <td align=left width="10%"> </td> [* } *] </tr> [* for ($daycnt = 1, $i = $BegPoint+1; $i <= $EndPoint; ++$i, ++$daycnt) { *] [# The following line executes sometimes when it should not when using # the [$ directive. # However, if you change the line to use [ * (and change the # corresponding endif, it works fine. #] [# if ((($daycnt-1) % 7) == 0) #] [* if ((($daycnt-1) % 7) == 0) { *] <tr> [* for ($j = 0; $j < 7; ++$j) { *] [$ if ($i+$j < 1 || $i+$j > $NDays) $] <td align=left valign=top colspan=2 bgcolor="#EEEEEE"> <font size=1>x</font> </td> [$ else $] <td valign=top align=left width="4%" bgcolor="#EEEEEE"> <a href="calendar.html?CurView=dayview&time=[+time()+]&day=[+$i+$j+]&year=[+$SWCCal::CurYear+]&month=[+$SWCCal::CurMonth+]"> [+$i+$j+]</a> </td> <td align=left width="10%"></td> [$ endif $] [* } *] </tr> <tr> [* } *] [# endif #] [$ if ($i < 1 || $i > $NDays) $] <td align=left valign=top colspan=2 bgcolor="#EEEEEE"> <font size=1>[+ $EndPoint +]<br><br><br><br><br></font> </td> [$ else $] <td align=left valign=top colspan=2> <font size=1> <a href="calendar.html?CurView=detail&time=[+time()+]&UID=[+$titleUID+]" onMouseOver="MM_displayStatusMsg('[+$titleLongTmp+]');return document.MM_returnValue">[+$titleTmp+]</a><br> </font> </td> [$ endif $] [$ if (($daycnt % 7) == 0) $] </tr> [$ endif $] [* } *] </TABLE> </CENTER> </body> Kee Hinckley Somewhere Consulting Group - Consultants without the cubes(tm) I'm not sure which upsets me more: that people are so unwilling to accept responsibility for their own actions, or that they are so eager to regulate everyone else's.