cf.Objective() Attendee...

Just a quick blog but I am excited to say that I am greatful to be able to attend cfObjective this year. I attended last year's event and had a great time learning new stuff whether it's about a framework that I have not seen before or just new coding techniques. I feel like last years event had motivated me in ways that I think has helped me as a developer. Not only did I learn new developing techniques but also fell in love with the art of user group meetings I guess you could say. I know that there is a local twin cities CFUG group but I hate driving to Minneapolis if I don't have to. I started up an internal Imagetrend user group meetings that seems to interest a lot of my co-workers. Usually I see turn outs of 15 people consistently which I think is pretty good. Anyways I digress, I cannot wait for this years conference and I will probably blog my thoughts and opinions on each of the sessions I tend. Hopefully to those that do read my blog and are attending the event I will get to meet you. I will be the big guy with the Halo tattoos hah.

Random Coldfusion Error

So just a quick post of an error I was receiving on an environment with an older version of Coldfusion 8 (prior to 8.01). The error was "Branch target offset too large for short". I googled this error an not a lot of clear help but what it came down to is the main function was just too large ( 1,000 lines of code). And it really only came up when I added like 15-20 more lines to the function. In order to fix it however I just broke my new changes off into their own function and it seemed to work. Further refactoring of this function is almost a must and will probably happen when I have time to do so. Just wanted to point this out, maybe for my own reminder but maybe it might help someone else.

VarScoper Gotcha Example

So I grabbed a function from a cfc that we use (replaced sensitive data of course) and as you can see there are some non-scoped variables. When I run through the varscoper that I have (version 1.3 latest from RIAforge I believe) it doesn't catch some variables. First it says that Template and TemplatePath need to be var scoped but they are actually in the arguments scope not the local scope. Second of all it doesn't catch the returnVariable from the invoke on line 40 and then it also doesn't catch PeopleID on line 38. I figured the PeopleID is fine since it is in the argument scope, but if varscoper is supposed to catch unscoped arguments than this would be a problem anyways. I attached the example hopefully the line numbers are the same as in CFBuilder.

view plain print about
2    <cffunction name="PersonLayout">
3        <cfargument name="PersonID" required="yes">
4        <cfargument name="Page" required="no" default="">
5        <cfargument name="Template" required="no" default="">
6        <cfargument name="TemplatePath" required="no" default="">
7        <cfargument name="FullScreen" required="no" default="true">
8        <cfargument name="ColoredBackground" required="no" default="false">
9        <cfargument name="Breadcrumbs" required="no" default="#arrayNew(1)#">
11        <cfset var FullPath = "" />
12        <cfset var Outerwidth = "" />
13        <cfset var InnerWidth = "" />
14        <cfset var personCrumb = "" />
16        <cfif Template eq "">
17            <cfset Template = ListLast(CGI.PATH_INFO,"/")>
18            <cfset Template = Replace(Template,"dsp_","cnt_","All")>
19        </cfif>
21        <cfif TemplatePath eq "">
22            <cfset FullPath = request.URLHost & CGI.PATH_INFO>
23            <cfset TemplatePath = ReplaceNoCase(FullPath,request.URLRoot,request.TemplatePath,"")>
24            <cfset TemplatePath = ReplaceNoCase(TemplatePath,ListLast(CGI.PATH_INFO,"/"),"","")>
25        </cfif>
27        <cfif FullScreen eq "true">
28            <cfset outerWidth="100%">
29            <cfset innerWidth="90%">
30        <cfelse>
31            <cfset outerWidth="700">
32            <cfset innerWidth="650">
33        </cfif>
35        <cfinvoke
36            component="cfc_DA_Q_PeopleData"
37            method="getPeopleHeader"
38            PeopleID="#PeopleID#"
39            FieldList="FirstName"
40            returnVariable="getPersonInfo">

41        </cfinvoke>
43        <cfscript>
44            personCrumb = structnew();
45            personCrumb.display = "person (#getPersonInfo.FirstName#)";
46            personCrumb.url = "People/Overview/dsp_viewPerson.cfm?PeopleID=#PeopleID#";
47            arrayprepend(Breadcrumbs,personCrumb);
50        <cfoutput>
51        <table width="100%" style="height: 100%" cellpadding="0" cellspacing="0" border="0">
52            <tr>
53                <td nowrap valign="top" id="SideMenu" width="200" rowspan="2">
54                    #PeopleMenu(arguments.PeopleID,arguments.Page,breadcrumbs)#
55                </td>
56                <td style="padding:0px;" valign="top"><cf_tag_Breadcrumbs2 Breadcrumbs="#Breadcrumbs#"></td>
57            </tr>
58            <tr>
59                <td width="100%" valign="top" colspan="2">
60                    <table width="#outerWidth#" cellpadding="8" cellspacing="0" border="0" align="center">
62                        <tr>
63                            <td>
64                                <cfif ColoredBackground>
65                                    <cf_tag_RoundedCornersTop bgcolor="##E9E9E9">
66                                </cfif>
67                                <table width="100%" cellspacing="0" cellpadding="0" border="0" <cfif ColoredBackground>class="roundtable" style="background-color:##E9E9E9;"</cfif>>
68                                    <tr>
69                                        <td>
70                                            <div id="outerContent">
71                                            <table width="#innerWidth#" cellpadding="8" cellspacing="0" border="0" align="center">
72                                                <tr>
73                                                    <td>
74                                                        <cf_tag_personHeader
75                                                            PeopleID="#PeopleID#"
76                                                            getQueries="true"
77                                                            showHealth="#request.config.personShowHealthIndicator#">

78                                                    </td>
79                                                </tr>
80                                                <tr>
81                                                    <td>
82                                                        <div id="innerContent">
83                                                            <cfinclude template="#TemplatePath##Template#">
84                                                        </div>
85                                                    </td>
86                                                </tr>
87                                            </table>
88                                            </div>
89                                        </td>
90                                    </tr>
91                                </table>
92                                <cfif ColoredBackground>
93                                    <cf_tag_RoundedCornersBottom bgcolor="##E9E9E9">
94                                </cfif>
95                            </td>
96                        </tr>
97                    </table>
98                    <cf_tag_personFooter>
99                </td>
100            </tr>
101        </table>
102        </cfoutput>
104    </cffunction>

Life Update

So not development related but just a quick update. So I finally signed away my life again and bought a house! This was actually rushed sort of since they only accepted our offer like 2 weeks ago. But it is nice to be able to get out of my crappy apartment. The house (townhome) has 2 bedrooms and 1 bathroom but it is about twice the size of my apartment so it is a nice upgrade.

Also, I have gotten engaged to my girlfriend Cassie of 7 years (wow). She accepted (crazy I know) and I had asked her at the Minnesota Zoo. I thought I was pretty good, it was hard keeping it a secret for about a week and a half from her since we live together. Anyways those are the two biggest updates I will try and write more development related posts. You can follow my twitter as well (if you don't already)

VarScoper Gotcha

So I have been heavily scoping an older cfc and the varscoper tool ( has been really helpful. One thing that we have found so far while using it is it doesn't catch cfinvoke's returnVariable attribute. Now I understand that cfinvokes may not be the best way to run a function, but in any case it has missed the returnedVariable.

Coldfusion Directory Compare

So I wrote this page to compare my many music directories to make figure out what is missing between the directories so I can sync them better. One problem I had was that if the file names were named differently it would determine them either missing or a new folder. If anyone else has any suggestions to make it better, please let me know.

view plain print about
1<cfsetting showdebugoutput="false" />
2<cfdirectory action="list" directory="\\ryan\Music" name="dirQuery" recurse="true" type="dir" listinfo="all" />
3<cfdirectory action="list" directory="Z:\My Music" name="dirQuery2" recurse="true" type="dir" listinfo="all" />
5<cfset Directory1Struct = {} />
6<cfset ProblemDirectory1 = {} />
8<cfloop query="dirQuery">
9    <cfif Directory EQ '\\ryan\Music'>
10        <cfset StructInsert(Directory1Struct,Name,{}) />
11    <cfelse>
12        <cfset ParentDirectory = ListGetAt(Directory,ListFindNoCase(Directory,'Music','\')+1,'\') />
13        <cfif NOT StructKeyExists(Directory1Struct[ParentDirectory],Name)>
14            <cfset StructInsert(Directory1Struct[ParentDirectory],Name,Name) />
15        <cfelse>
16            <cfif NOT StructKeyExists(ProblemDirectory1,ParentDirectory)>
17                <cfset StructInsert(ProblemDirectory1,ParentDirectory,{}) />
18                <cfset StructInsert(ProblemDirectory1[ParentDirectory],Name,Name) />
19            <cfelse>
20                <cfif NOT StructKeyExists(ProblemDirectory1[ParentDirectory],Name)>
21                    <cfset StructInsert(ProblemDirectory1[ParentDirectory],Name,Name) />
22                </cfif>
23            </cfif>
24        </cfif>
25    </cfif>
28<cfset Directory2Struct = {} />
29<cfset ProblemDirectory2 = {} />
31<cfloop query="dirQuery2">
32    <cfif Directory EQ '\\ryan\My Music'>
33        <cfset StructInsert(Directory2Struct,Name,{}) />
34    <cfelse>
35        <cfset ParentDirectory = ListGetAt(Directory,ListFindNoCase(Directory,'My Music','\')+1,'\') />
36        <cfif NOT StructKeyExists(Directory2Struct[ParentDirectory],Name)>
37            <cfset StructInsert(Directory2Struct[ParentDirectory],Name,Name) />
38        <cfelse>
39            <cfif NOT StructKeyExists(ProblemDirectory2,ParentDirectory)>
40                <cfset StructInsert(ProblemDirectory2,ParentDirectory,{}) />
41                <cfset StructInsert(ProblemDirectory2[ParentDirectory],Name,Name) />
42            <cfelse>
43                <cfif NOT StructKeyExists(ProblemDirectory2[ParentDirectory],Name)>
44                    <cfset StructInsert(ProblemDirectory2[ParentDirectory],Name,Name) />
45                </cfif>
46            </cfif>
47        </cfif>
48    </cfif>
51<cfset DifferenceStruct = {} />
54<cfloop collection="#Directory2Struct#" item="Artist">
55    <cfif StructKeyExists(Directory1Struct,Artist)>
56        <cfif isStruct(Directory2Struct[Artist])>
57            <cfloop collection="#Directory2Struct[Artist]#" item="Album">
58                <cfif NOT StructKeyExists(Directory1Struct[Artist],Album)>
59                    <cfif NOT StructKeyExists(DifferenceStruct,Artist)>
60                        <cfset StructInsert(DifferenceStruct,Artist,{}) />
61                        <cfset StructInsert(DifferenceStruct[Artist],Album,Album) />
62                    <cfelse>
63                        <cfset StructInsert(DifferenceStruct[Artist],Album,Album) />
64                    </cfif>
65                </cfif>
66            </cfloop>
67        </cfif>
68    </cfif>
70<cfdump var="#DifferenceStruct#"><cfabort>
72<cfdump var="#DirectoryStruct#" label="Directory Struct">
73<cfdump var="#ProblemDirectory#" label="Problem Struct">
76<cfset Directory1Listing = ListToArray(Replace(ValueList(,"'","''","all")) />
77<cfset Directory2Listing = ListToArray(Replace(ValueList(,"'","''","all")) />
79<cfset MissingStruct = {} />
80<cfset Counter = 1 />
81<cfloop array="#Directory1Listing#" index="artist">
82    <cfif NOT ArrayFind(Directory2Listing,artist)>
83        <cfset StructInsert(MissingStruct,artist,artist) />
84    </cfif>
86<cfdump var="#MissingStruct#"><cfabort>

Coldfusion 9 Syntax Gotcha

So I was working with a coworker trying to convert an app to be Coldfusion 9 friendly, and came into a strange issue. If you set

view plain print about
1<cfset local.arguments = structnew() />

it will actually over write the Arguments scope. Kinda weird but I suppose it makes sense. So to fix it we just do:

view plain print about
1<cfset local.args = structnew() />

Probably a known issue, but thought I would share.

Finding Coldfusion Components.

So I have been having this issue where Coldfusion cannot seem to find my components. So my application looks like this:

view plain print about
2    <cfsetting showdebugoutput="true" />
3    <cfset"YourSpace1">
4    <cfset this.clientManagement = "Yes">
5    <cfset this.sessionManagement = "Yes">
6    <cfset this.sessionTimeout = "#CreateTimeSpan(0, 0, 80, 0)#">
8    <!----------------------------------------------------------------------------------->
10    <cffunction name="onApplicationStart">    
11            <cfset application.appStarted = now()>        
12    </cffunction>
14    <!----------------------------------------------------------------------------------->
16    <cffunction name="onRequestStart">    
18        <cfset request.DataSource = "rvikander">
19        <cfset request.CompanyName = "Your Space">
20        <cfset request.SiteTitle = "Welcome To Your Space! beta ver 1.0">
21        <cfset request.FileRoot = "F:\websites\rvikander\">
22        <cfset request.ImagePath = "_extensions/_images/">
23        <cfset request.UserImageRoot = request.FileRoot & "_extensions\_images\_user\">
24        <cfset request.UserImagePath = "_extensions\_images\_user\">
25        <cfset request.JavascriptPath = "_extensions/_javascript/">
26        <cfset request.SupportEmail = "">
28        <cfinclude template="header.cfm">
29    </cffunction>
31    <!----------------------------------------------------------------------------------->
33    <cffunction name="onSessionEnd">    
35    <cfinvoke
36        component="cfc_Actions"
37        method="saveLog"
38        Log="Off"
39        UserID="#Session.UserID#"
40        returnVariable="saveLog">

41    </cfinvoke>
43    <cflogout>
45    <cflocation url="index.cfm?Page=Home">
47    </cffunction>
49    <!----------------------------------------------------------------------------------->

And all I am doing is a simple invoke to a component not doing dot notation path. And that did not seem to work. The one thing I have found that works was to setup a Custom Tag path in the administrator pointing to my extensions directory. If anyone has any thoughts, please let me know!

Previous Entries

BlogCFC was created by Raymond Camden. This blog is running version Contact Blog Owner