Entries for month: May 2011
Dump or list all ColdFusion Variables in all scopes.
On some occasions you may run into issues where you need a variable but your not sure what scope it’s in. Well I’ve found the code below extremely helpful for finding what scope the variable I’m looking for is in.
Basically the function, “getPageContext().getBuiltInScopes()” will list all variables in all scopes.
I ran into an issue recently where my production server's code used a different drive letter than my development environment. A small handful of applications relied on that drive letter and would break if the drive letter wasn't changed before deployment. In these specific scenarios, I couldn't call expandPath() or getTemplatePath() directly because the application wasn't in the root of the website.
My solution to this issue was to put the code below in my application.cfm / application.cfc file which sets an application variable called "driveLetter" to the applications current drive letter; then I call the application variable instead of the static drive letter that could change.
Get Drive letter
If you want to get the drive letter once, you could use do something like below.
<cfset variables.driveLetter = listGetAt(expandPath('\'),1,'\')&'\' />
Get drive letter, then set application variable.
Below is the exact code I used in my application.cfm file to set the application variable initially, that way I don't have to run the script every time.
<cflock scope='application' timeout='5'>
<cfset application.driveLetter = listGetAt(expandPath('\'),1,'\')&'\'/>