House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Incrementing a variable

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi,
FlashGuy
12/17/02 07:15 A
Youll need to do something like...
Mike Townend
12/17/02 07:26 A
What do you need it to do?
Mike Townend
12/17/02 07:57 A
Are you trying to get this result?
webguy
12/17/02 07:29 A
> Are you trying to get this result?
FlashGuy
12/17/02 07:39 A
No...no error. code works just fine.
FlashGuy
12/17/02 08:05 A
> Probably too much work, right?
Thomas Chiverton
12/17/02 11:28 A
You might want to look at something like...
Mike Townend
12/17/02 08:16 A
Spooky
Taz
12/17/02 08:26 A
Flash guy - Use a session variable.
Stephen Moretti
12/17/02 08:24 A
Are you using fusebox?
John McCosker
12/17/02 08:13 A
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 07:15 AM

Hi, For some reason I can't get my variable to increment when my page is reloaded. I have the following in my application.cfm file <cfset child = 0> In my index.cfm file I have the following. <cfset child=child + 1> Everytime I refresh the page manually or by using an <a href within mu file to reload mu index.cfm it doesn't increment? --------------------------------------------------- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba ---------------------------------------------------

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Townend
12/17/2002 07:26 AM

Youll need to do something like... In Application.cfm <CFLOCK TIMEOUT="5" THROWONTIMEOUT="No" TYPE="EXCLUSIVE" SCOPE="APPLICATION">   <CFPARAM NAME="Application.child" DEFAULT="0"> </CFLOCK> And in the index file <CFLOCK TIMEOUT="5" THROWONTIMEOUT="No" TYPE="EXCLUSIVE" SCOPE="APPLICATION">   <CFSET Application.child = Application.Child + 1> </CFLOCK> HTH Hi, For some reason I can't get my variable to increment when my page is reloaded. I have the following in my application.cfm file <cfset child = 0> In my index.cfm file I have the following. <cfset child=child + 1> Everytime I refresh the page manually or by using an <a href within mu file to reload mu index.cfm it doesn't increment? --------------------------------------------------- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba ---------------------------------------------------

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 07:47 AM

Hmm...OK I just tried it out and its not quite working the way I wanted it to. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Townend
12/17/2002 07:57 AM

What do you need it to do? It does pretty much what your orignal code does... Ive just moved it to a persistant scope... Hmm...OK I just tried it out and its not quite working the way I wanted it to. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
webguy
12/17/2002 07:29 AM

Are you trying to get this result? 1st view of index.cfm value=1 2nd view of index.cfm value=2 3rd view of index.cfm value=3 If so you are doing to wrong because this is what you are actually doing 1st view of index.cfm   appliation.cfm sets child = 0   index.cfm sets child = child + 1 = 1 2nd view of index.cfm   appliation.cfm sets child = 0   index.cfm sets child = child + 1 = 1 3rd view of index.cfm   appliation.cfm sets child = 0   index.cfm sets child = child + 1 = 1 Webguy ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 07:39 AM

> Are you trying to get this result? > > 1st view of index.cfm value=1 > 2nd view of index.cfm value=2 > 3rd view of index.cfm value=3 > Yes. > If so you are doing to wrong because this is what you are actually doing OK..I see...how would I go about doing the above? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
webguy
12/17/2002 08:00 AM

That code looks ok to me , how is it not working ? An error ? ----- Excess quoted text cut - see Original Post for more ----- WG Detainees in Guantánamo: As One Year Anniversary Nears, US Bars Scrutiny By Human Rights Group http://www.amnestyusa.org/news/2002/usa12132002.html ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 08:05 AM

No...no error. code works just fine. Its not not behaving like I want it to. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
webguy
12/17/2002 08:14 AM

Use a session instead of a application scope In Application.cfm <CFLOCK TIMEOUT="5" THROWONTIMEOUT="No" TYPE="EXCLUSIVE" SCOPE="session">   <CFPARAM NAME="session.child" DEFAULT="0"> </CFLOCK> And in the index file <CFLOCK TIMEOUT="5" THROWONTIMEOUT="No" TYPE="EXCLUSIVE" SCOPE="session">   <CFSET session.child = session.Child + 1> </CFLOCK> WG ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 08:35 AM

OK...but every time I hit the refresh it increments. I don't want that. Also everytime I drill down into the directory structure I also want the counter to decrement if I click on a link to go back. Probably too much work, right? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Thomas Chiverton
12/17/2002 11:28 AM

> Probably too much work, right? Do-able with the ListLen posted earlier. -- Thomas C "Does google know ?"

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Taz
12/17/2002 07:31 AM

That's because on every page request you reset the value to zero What are you trying to do? Taz > Hi, > > For some reason I can't get my variable to increment when my page is reloaded. ----- Excess quoted text cut - see Original Post for more ----- file to reload mu index.cfm it doesn't increment? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 07:54 AM

I'm trying to set a variable based on were I am in my directory structure. At initial loading of my index.cfm I would set a variable to "0" WHen I click on a link and "drill-down" into the directory I want that variable incremented. At the same time if I go backup up in the directorure structure I want the variable decremented. Example: D:\dir1 [0] D:\dir2 [0] Click on D:\dir1 D:D:\dir1\test1 [1] D:\dir1\test2 [1] Click on D:\dir1\test D:D:\dir1 [1] D:\dir1\test1 [2] ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Townend
12/17/2002 08:16 AM

You might want to look at something like... <CFSET Child = ListLen(GetDirectoryFromPath(ExpandPath("*.*)), "\")> Or something similar HTH I'm trying to set a variable based on were I am in my directory structure. At initial loading of my index.cfm I would set a variable to "0" WHen I click on a link and "drill-down" into the directory I want that variable incremented. At the same time if I go backup up in the directorure structure I want the variable decremented. Example: D:\dir1 [0] D:\dir2 [0] Click on D:\dir1 D:D:\dir1\test1 [1] D:\dir1\test2 [1] Click on D:\dir1\test D:D:\dir1 [1] D:\dir1\test1 [2] ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Taz
12/17/2002 08:26 AM

Spooky You ought to do a ListLen() on the template path using '\' as the delimiter Taz

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
DDB Lists
12/17/2002 07:34 AM

Your application.cfm is loaded on every refresh so the variable is set to zero every time. You should put it in a persistant scope and check for it's existance: <cif not isdefined("application.child")> <cfset application.child = 0> </cfif> and <cfset application.child = application.child + 1> > I have the following in my application.cfm file > <cfset child = 0> > In my index.cfm file I have the following. > <cfset child=child + 1> > Everytime I refresh the page manually or by using an <a href within mu file to reload mu index.cfm it doesn't increment?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
FlashGuy
12/17/2002 07:56 AM

If I close the brower the application.child variable doesn't get cleared? ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Stephen Moretti
12/17/2002 08:24 AM

Flash guy - Use a session variable. DDBLists - you need cflocks on that code even in cfmx.  Its the classic example of a race condition. > If I close the brower the application.child variable doesn't get cleared? > > > > > > Your application.cfm is loaded on every refresh so the variable is set to ----- Excess quoted text cut - see Original Post for more -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Adrian Lynch
12/17/2002 07:25 AM

It will always get reset back to 0 with every page request. Hi, For some reason I can't get my variable to increment when my page is reloaded. I have the following in my application.cfm file <cfset child = 0> In my index.cfm file I have the following. <cfset child=child + 1> Everytime I refresh the page manually or by using an <a href within mu file to reload mu index.cfm it doesn't increment? --------------------------------------------------- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba ---------------------------------------------------

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paolo Cesana
12/17/2002 07:32 AM

It looks like you're resetting the variable each time a page loads.... Use cfparam instead to set it once if you choose to place the init in application.cfm Also, you need to think about variable scope... Rgds Paolo Cesana     IT Development Mgr. "Electricity is not the result of a series of upgrades to the candle" Auth. unknown Miami International Forwarders (MIF) Phone: (305)594-0038 Ext. 7326 Fax: (305)593-0431 mailto:paoloc@mif.com <mailto:paoloc@mif.com> http://www.mif.com <http://www.mif.com/>; Hi, For some reason I can't get my variable to increment when my page is reloaded. I have the following in my application.cfm file <cfset child = 0> In my index.cfm file I have the following. <cfset child=child + 1> Everytime I refresh the page manually or by using an <a href within mu file to reload mu index.cfm it doesn't increment? --------------------------------------------------- Colonel Nathan R. Jessop Commanding Officer Marine Ground Forces Guatanamo Bay, Cuba ---------------------------------------------------

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
John McCosker
12/17/2002 08:13 AM

Are you using fusebox? If you are you could use the fuseaction to determine if it increments or vise verca, e.g. D:\dir1 [0] fuseaction=thisFuse&counter=#attributes.counter# D:\dir2 [0] fuseaction=thisOtherFuse&counter=#attributes.counter# then in your app globals <CFPARAM NAME="attributes.counter" DEFAULT="0"> <cfwith expression="#attributes.fuseaction#">   <cfcase value="thisFuse"><CFSET attributes.counter=attributes.counter-1><cfcase>   <cfcase value="thisOtherFuse"><CFSET attributes.counter=attributes.counter+1><cfcase> </cfswitch> if your not using fusebox, in your application.cfm <CFPARAM NAME="counter" DEFAULT="0">   <CFIF GetBaseTemplatePath() CONTAINS("dir1")>     <CFSET counter=counter-1>   <CFELSEIF GetBaseTemplatePath() CONTAINS("dir2")>     <CFSET counter=counter+1>   </CFIF> and then in you links you'll always have to pass via hidden form field, cookie, or url <a href="index.cfm?counter=#counter#>link</a> I think this is along the right path, J I'm trying to set a variable based on were I am in my directory structure. At initial loading of my index.cfm I would set a variable to "0" WHen I click on a link and "drill-down" into the directory I want that variable incremented. At the same time if I go backup up in the directorure structure I want the variable decremented. Example: D:\dir1 [0] D:\dir2 [0] Click on D:\dir1 D:D:\dir1\test1 [1] D:\dir1\test2 [1] Click on D:\dir1\test D:D:\dir1 [1] D:\dir1\test1 [2] ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 19, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference