Aimee:

Looks like you're mixing code from a number of different suggestions.  There
were some good suggestions, but some parts do not work well or are not
needed with other parts.  First, the answer to your question, and then some
complete (but untested) code.

The reason why you're always getting the survey link is because of the
following code:
        <cfif application.counter mod 7 eq 0>
The MOD operator returns the remainder when one integer is divided by
another integer (remember long division?).  So, for example, 5 MOD 2 = 1,
because
        2 (a) goes into 5 two (b) times,
        2 (a) x 2 (b) = 4 (c),
        and 5 - 4 (c) = 1

In your case, APPLICATION.Counter is initially set to 0.  0 MOD 7 = 0
because 7 goes into 0 zero times and has a remainder of 0.  So the above
CFIF statement is always true.

Now, the "complete" code (which is not really complete because I'm going to
leave out the CFMAIL stuff and just use a comment to show where the link is
supposed to go 8^>):

Application.cfm:
        <!--- ------------------------------------------------------
            The locks are needed because APPLICATION variables can be
            used by multiple threads.  The IsDefined() doesn't need to
            be locked because it's not accessing the variable, just
            checking if it exists.
         ------------------------------------------------------ --->

        <!--- Initialize APPLICATION.Counter --->
        <CFIF NOT IsDefined("APPLICATION.Counter")>
                <CFLOCK TYPE="Exclusive" NAME="lckCreateCounter" TIMEOUT="5">
                        <CFSET APPLICATION.Counter = 0>
                </CFLOCK>
        </CFIF>


ActionPage.cfm:
        <!--- ------------------------------------------------------
            Copy the value from the APPLICATION scope to a local
            scope so we don't need to keep locking it.
         ------------------------------------------------------ --->
        <!--- Get counter value --->
        <CFLOCK TYPE="ReadOnly" NAME="lckReadCounter">
                <CFSET Counter = APPLICATION.Counter>
        </LOCK>

        <!--- ------------------------------------------------------
            To get around the 0 MOD 7 = 0 issue described above,
            forget about MOD and just check the value.  Compare it
            to 6 instead of 7 because our numbering starts at 0.
            Sequential incrementation from 0 to 6 encompasses
            7 numbers: 0, 1, 2, 3, 4, 5, 6
         ------------------------------------------------------ --->
        <!--- Check counter value --->
        <CFIF Counter EQ 6>
                <!--- 7th number: reset counter to 0 & show link --->
                <CFLOCK TYPE="Exclusive" NAME="lckWriteCounter">
                        <CFSET APPLICATION.Counter = 0>
                </CFLOCK>

                <!--- ***** show survey code ***** --->
        <CFELSE>
                <!--- Not 7th number: Increment counter --->
                <CFLOCK TYPE="Exclusive" NAME="lckWriteCounter">
                        <CFSET APPLICATION.Counter = APPLICATION.Counter + 1>
                </CFLOCK>
        </CFIF>

Hope this works for you.

--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 625-9191
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/


> -----Original Message-----
> From: Clark, Aimee [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 26, 2002 5:42 PM
> To: CF-Talk
> Subject: RE: Using a counter variable
>
>
> Mosh,
>       I tried this and it did work, but, it's still showing my survey link
> even though the counter has been set back to 0. Can you tell why?
>
> <cflock type="READONLY" name="lckReadCounter" timeout="20">
>       <cfset counter = application.counter>
> </cflock>
>
> <cfif application.counter mod 7 eq 0>
>       <cflock type="EXCLUSIVE" name="lckWriteCounter" timeout="20">
>               <cfset application.counter = 0>
>       </cflock>
> <cfmail query = "GetCall" to="[EMAIL PROTECTED]"
> from="[EMAIL PROTECTED]"
>         subject="Closed Help Desk Ticket"
>         type="HTML"><body link="red" alink="red" vlink="red">
>               Your Help Desk call (Ticket No. #GetCall.ID#) has been
> closed.  If you believe the call should not be closed, or the
> problem occurs
> again, please reply to this message or call the Help Desk, to let us know.
> <P>
> <div align="center"><H3>Call Information</h3></div><P>
> <h4><b><font color="Red">Ticket Number:</font></b>  #GetCall.ID#<P>
> <b><font color="Red">Problem Description:</font></b>  <BR>
> #GetCall.Issue#<P>
> <b><font color="Red">Resolution:</font></b> <BR>
> #GetCall.Resolution#<br><br>
> <P></h4></body>
> <div><font color="Red"></font><a
> href="http://dailynews/helpdesk/test/HDSurvey.cfm?ID=#ID#";
> target="_blank">Click here to answer a brief survey about your issue and
> resolution.</a></font></div>
> <p>#counter#</p>
> </cfmail>
>
> <cfelse>
> <cflock type="EXCLUSIVE" name="lckWriteCounter" timeout="20">
>       <cfset application.counter = application.counter + 1>
> </cflock>
> <cfmail query = "GetCall" to="[EMAIL PROTECTED]"
> from="[EMAIL PROTECTED]"
>         subject="Closed Help Desk Ticket"
>         type="HTML"><body link="red" alink="red" vlink="red">
>               Your Help Desk call (Ticket No. #GetCall.ID#) has been
> closed.  If you believe the call should not be closed, or the
> problem occurs
> again, please reply to this message or call the Help Desk, to let us know.
> <P>
> <div align="center"><H3>Call Information</h3></div><P>
> <h4><b><font color="Red">Ticket Number:</font></b>  #GetCall.ID#<P>
> <b><font color="Red">Problem Description:</font></b>  <BR>
> #GetCall.Issue#<P>
> <b><font color="Red">Resolution:</font></b> <BR>
> #GetCall.Resolution#<br><br>
> <P></h4></body>
> <p>#counter#</p>
> </cfmail>
> </cfif>
>
> Thank you,
>       Aimee' Clark
>
> -----Original Message-----
> From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, November 26, 2002 3:41 PM
> To: CF-Talk
> Subject: RE: Using a counter variable
>
>
> You haven't made your counter variable persistent.  Every time
> someone makes
> a new request of your application, Application.cfm creates a new variable
> called "counter" and sets it equal to 0.  You need to make your variable
> persistent.  And since you want it to work across multiple users,
> it should
> probably persist in the APPLICATION scope.
>
> So, your Application.cfm should look something like:
>
>       <CFIF NOT IsDefined("APPLICATION.Counter")>
>               <CFLOCK TYPE="Exclusive" NAME="lckCreateCounter">
>                       <CFSET APPLICATION.Counter = 0>
>               </CFLOCK>
>       </CFIF>
>
> Your action page should look something like:
>
>       <!--- Get counter value --->
>       <CFLOCK TYPE="ReadOnly" NAME="lckReadCounter">
>               <CFSET Counter = APPLICATION.Counter>
>       </LOCK>
>
>       <CFIF Counter EQ 6>
>               <!--- Increment counter --->
>               <CFLOCK TYPE="Exclusive" NAME="lckWriteCounter">
>                       <CFSET APPLICATION.Counter = 0>
>               </CFLOCK>
>
>               <!--- ***** show survey code ***** --->
>       <CFELSE>
>               <!--- Increment counter --->
>               <CFLOCK TYPE="Exclusive" NAME="lckWriteCounter">
>                       <CFSET APPLICATION.Counter = APPLICATION.Counter +
> 1>
>               </CFLOCK>
>       </CFIF>
>
>
> --
> Mosh Teitelbaum
> evoch, LLC
> Tel: (301) 625-9191
> Fax: (301) 933-3651
> Email: [EMAIL PROTECTED]
> WWW: http://www.evoch.com/
>
>
> > -----Original Message-----
> > From: Clark, Aimee [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, November 26, 2002 4:03 PM
> > To: CF-Talk
> > Subject: Using a counter variable
> >
> >
> > I have an application in which I want every 7th record closed in
> > a table to
> > generate an email asking the user to participate in a survey.
> >
> > I have <cfset counter = 0> in the application.cfm file.
> >
> > I have <cfset counter = counter +1> in my action page right after
> > an update
> > that is done to the table.
> >
> > Then I have <cfif counter EQ 7>
> >     execute generating email
> >     then it resets the counter back to 0
> >
> > However my counter is not incrementing at all. It just keep
> staying at 1.
> > I'm not sure why. Can someone provide some assistance with this?
> >
> > Thank you,
> > Aimee' Clark
> > Web Developer
> > Stinson Morrison Hecker
> >
> >
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm

Reply via email to