Answered
Variable scope: Application.cfm vs Application.cfc - very confused
Hi all,
ColdFusion newbie here, so please bear with me:)
I'm currently tasked with upgrading a huge ColdFusion 5 project (over 1000 CF pages) to ColdFusion 8, I tried to refactor some of the old code into CFCs, but ran into a problem with variable scope, or the lack thereof.
In the old application, there's one Application.cfm in which a bunch of global variables are defined, without scope, like:
<CFSCRIPT>
...
PrimaryDataSource = "TestDB"
...
</CFSCRIPT>
It seems that variables defined like this can be accessed fine in all the CFM pages using #PrimaryDataSource#, but not in any of my new CFC pages.
What do I have to do to make these global scopeless variables available to the CFCs? Also, what does it actually mean if the global variables are defined without any scope?
I'm really new to ColdFusion, so I'd be very grateful if anyone could shed a light here!
Many thanks in advance.
Billy
ColdFusion newbie here, so please bear with me:)
I'm currently tasked with upgrading a huge ColdFusion 5 project (over 1000 CF pages) to ColdFusion 8, I tried to refactor some of the old code into CFCs, but ran into a problem with variable scope, or the lack thereof.
In the old application, there's one Application.cfm in which a bunch of global variables are defined, without scope, like:
<CFSCRIPT>
...
PrimaryDataSource = "TestDB"
...
</CFSCRIPT>
It seems that variables defined like this can be accessed fine in all the CFM pages using #PrimaryDataSource#, but not in any of my new CFC pages.
What do I have to do to make these global scopeless variables available to the CFCs? Also, what does it actually mean if the global variables are defined without any scope?
I'm really new to ColdFusion, so I'd be very grateful if anyone could shed a light here!
Many thanks in advance.
Billy
