<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>My mostly ColdFusion Blog, with some other stuff thrown in</title>
			<link>http://blog.garthe.com/index.cfm</link>
			<description>My random findings during 15 years of using the best programming language in the world.</description>
			<language>en-us</language>
			<pubDate>Mon, 21 May 2012 01:13:38-0500</pubDate>
			<lastBuildDate>Tue, 02 Sep 2008 14:07:00-0500</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>davidgarthe@gmail.com</managingEditor>
			<webMaster>davidgarthe@gmail.com</webMaster>
			
			
			
			
			
			<item>
				<title>ListFindNoCase problem with spaces</title>
				<link>http://blog.garthe.com/index.cfm/2008/9/2/ListFindNoCase-problem-with-spaces</link>
				<description>
				
				I ran into a problem today trying to find a person&apos;s userId value from a list of values using &quot;&lt;strong&gt;listFindNoCase&lt;/strong&gt;&quot;.

Here&apos;s the code:&lt;br&gt;

&lt;code&gt;
&lt;cfset allowedValues = &quot;33333a, 44444b, 55555c, 66666d, 77777e, 88888f, 99999g&quot;&gt;

&lt;cfif listFindNoCase(allowedValues,session.userId)&gt;
	This person is allowed in.
&lt;cfelse&gt;
	This person is not allowed in.
&lt;/cfif&gt;
&lt;/code&gt;

Its difficult to see on this page, but there is a space after each comma in &quot;allwedValues&quot;. This causes coldFusion to compare &quot;33333a&quot; to &quot; 33333a&quot;, resulting in a false response.  Removing the space between each value solved this, although it seems to be a bug to me.

SOLUTION:&lt;br&gt;
&lt;code&gt;
&lt;cfset allowedValues = &quot;33333a,44444b,55555c,66666d,77777e,88888f,99999g&quot;&gt;
&lt;/code&gt;
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Tue, 02 Sep 2008 14:07:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2008/9/2/ListFindNoCase-problem-with-spaces</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>What happened to the variables I set?</title>
				<link>http://blog.garthe.com/index.cfm/2008/2/27/What-happened-to-the-variables-I-set</link>
				<description>
				
				Here&apos;s a question for everyone out there.

I created a query:

&lt;code&gt;
&lt;cfquery dbtype=&quot;query&quot; name=&quot;companyInfo&quot;&gt;
	SELECT *
	FROM companyList
	WHERE companyId = #url.companyId#
&lt;/cfquery&gt;
&lt;/code&gt;

Then without really thinking tried to set some new variables so my page wouldn&apos;t error out:

&lt;code&gt;
&lt;cfset companyInfo.newVariableOne = &quot;&quot;&gt;
&lt;cfset companyInfo.newVariableTwo = &quot;&quot;&gt;
&lt;/code&gt;

I did a CFDUMP of companyInfo, and it dumps the query result without the additional variables.  What exactly happened to the new variables?  If I try to declare the structure with a StructNew() it overwrites the query.

Now before anyone gets anxious, I realize you can&apos;t set a static variable like this into a complex object type, especially a query.  I&apos;d have to create the new column in the query, and specify what row this value is for, and blah blah blah.

I&apos;m just curious if anyone knows how Coldfusion handles this situation, and how I would retrieve a static value set like this. Thanks.
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Wed, 27 Feb 2008 11:17:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2008/2/27/What-happened-to-the-variables-I-set</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>cftextarea bug</title>
				<link>http://blog.garthe.com/index.cfm/2008/2/3/cftextarea-bug</link>
				<description>
				
				Came across an interesting bug today with CFTEXTAREA.  Not a bug with ColdFusion, but a bug with the Homesite update files from Adobe.  Below is how Homesite filled in the tag using their WYSIWYG:

&lt;code&gt;
&lt;cftextarea  name=&quot;commentmessage&quot; message=&quot;Please enter a comment&quot; disabled=&quot;No&quot; required=&quot;Yes&quot; enabled=&quot;Yes&quot; visible=&quot;Yes&quot; richtext=&quot;Yes&quot; skin=&quot;default&quot; width=&quot;550&quot; height=&quot;300&quot; toolbar=&quot;Basic&quot;&gt;&lt;/cftextarea&gt;
&lt;/code&gt;

As you can see, it has enabled=&quot;Yes&quot;, and disabled=&quot;No&quot;.  Kind of strange to have them both as options, and I&apos;ve never really recognized it before this problem came up.  I had simply updated my Homesite files with the tag and help files from Adobe.

When I went to submit the form, the &quot;commentmessage&quot; form variable was not passed in the form scope.  I believe this is from the browser interpreting having &quot;disabled&quot; anywhere in the textarea.

I simply removed both variables(since ColdFusion defaults CFTEXTAREA to enabled=&quot;yes&quot;), and all is well.

&lt;code&gt;
&lt;cftextarea  name=&quot;commentmessage&quot; message=&quot;Please enter a comment&quot; required=&quot;Yes&quot; visible=&quot;Yes&quot; richtext=&quot;Yes&quot; skin=&quot;default&quot; width=&quot;550&quot; height=&quot;300&quot; toolbar=&quot;Basic&quot;&gt;&lt;/cftextarea&gt;
&lt;/code&gt;

Hope this helps someone out there.
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Sun, 03 Feb 2008 14:33:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2008/2/3/cftextarea-bug</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>setting a dynamic variable name</title>
				<link>http://blog.garthe.com/index.cfm/2008/1/27/setting-a-dynamic-variable-name</link>
				<description>
				
				This is probably known to many, but you can set a variable with a dynamic name.  I&apos;ve only come across one or two instances in ten years where this is necessary.  Those times have always been to quickly fix existing code and remove hard-coding of variable names.

There&apos;s always 10 ways to get to the same destination with programming, and I usually don&apos;t take this one.  However, it is an option, so I&apos;m demonstrating it here.

An example is perhaps when you need to set a variable for each student (Mark_classes, Tom_classes), and then assign a value to that new variable.  This can be done with the code below:

&lt;code&gt;
&lt;cfoutput query=&quot;myQuery&quot;&gt;
	&lt;cfset &quot;#myQuery.Name#_classes&quot; = myQuery.numberOfClasses&gt;
&lt;/cfoutput&gt;
&lt;/code&gt;

Just be sure to put the quotes around the dynamic variable name.
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Sun, 27 Jan 2008 10:08:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2008/1/27/setting-a-dynamic-variable-name</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFWINDOW and CFFORM don&apos;t like hidden form variables named &quot;action&quot;</title>
				<link>http://blog.garthe.com/index.cfm/2008/1/2/CFWINDOW-and-CFFORM-doesnt-like-action-hidden-form-variable</link>
				<description>
				
				I kept getting an error with a CFFORM that I was using within a CFWINDOW.  The error was:

&lt;strong&gt;error: http: Error retrieving markup for element editWindow_body : Not Found&lt;/strong&gt;

This error message would go away if I would use a regular HTML form tag.  After a bit of searching I found &lt;a href=&quot;http://www.webmasterkb.com/Uwe/Forum.aspx/cold-fusion/16239/How-to-POST-FORM-within-CFWINDOW&quot; target=&quot;_blank&quot;&gt;the solution&lt;/a&gt;.  I had a hidden variable in the form named &quot;action&quot;.  Such as:

&lt;code&gt;
&lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;editCompany&quot;&gt;
&lt;/code&gt;

It appears that the Javascript/Ajax libraries for coldFusion 8 have the form variable &quot;action&quot; as a reserved word, and this was conflicting with the normal operation of the page.  I quickly changed the name of the hidden variable to &quot;myAction&quot; along with the code and everything works normally.

&lt;code&gt;
&lt;input type=&quot;hidden&quot; name=&quot;myAction&quot; value=&quot;editCompany&quot;&gt;
&lt;/code&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Wed, 02 Jan 2008 13:40:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2008/1/2/CFWINDOW-and-CFFORM-doesnt-like-action-hidden-form-variable</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFLOOP inside of a CFOUTPUT</title>
				<link>http://blog.garthe.com/index.cfm/2007/12/17/CFLOOP-inside-of-a-CFOUTPUT</link>
				<description>
				
				Previously, I wrote about using a &lt;a href=&quot;http://blog.garthe.com/index.cfm/2007/10/4/CFLOOP-inside-of-a-CFLOOP&quot; &gt;CFLOOP inside of a CFLOOP&lt;/a&gt;.  Here&apos;s another solution for a quirky problem you might encounter.

Sometimes a situation exists where you need to use a CFLOOP inside of a CFOUTPUT.  I had two queries, the first was the main query (queryOneList), and the second (queryTwoList) was going to be used to dynamically create the columns in a table for an administration area.

This is a pretty unique situation, and it created a unique problem.  Below is the code I initially wrote:

&lt;code&gt;
&lt;table&gt;
&lt;cfoutput QUERY=&quot;queryOneList&quot;&gt;
&lt;tr&gt;
	&lt;td&gt;#queryOneList.MEDIUM_NAME#&lt;/td&gt;
	&lt;td&gt;#queryOneList.MEDIUM_DESC#&lt;/td&gt;
	&lt;cfloop query=&quot;queryTwoList&quot;&gt;
	&lt;td&gt;&lt;A href=&quot;xyz.cfm?mn=#queryOneList.MEDIUM_NAME#&amp;code=#queryTwoList.CODE#&quot;&gt;#queryTwoList.CODE_NAME#&lt;/A&gt;&lt;/td&gt;
	&lt;/cfloop&gt;
&lt;/tr&gt;
&lt;/cfoutput&gt;
&lt;/table&gt;
&lt;/code&gt;

The problem was that since I scope all variables, the queryOneList.MEDIUM_NAME value INSIDE THE CFLOOP was always the first value returned from &quot;queryOneList&quot;.  Obviously, I needed to reference that row&apos;s value.  I quickly solved this problem by referencing the value as so in the url link:

&lt;code&gt;
&lt;table&gt;
&lt;cfoutput QUERY=&quot;queryOneList&quot;&gt;
&lt;tr&gt;
	&lt;td&gt;#queryOneList.MEDIUM_NAME#&lt;/td&gt;
	&lt;td&gt;#queryOneList.MEDIUM_DESC#&lt;/td&gt;
	&lt;cfloop query=&quot;queryTwoList&quot;&gt;
	&lt;td&gt;&lt;A href=&quot;xyz.cfm?mn=#queryOneList.MEDIUM_NAME[queryOneList.currentRow]#&amp;code=#queryTwoList.CODE#&quot;&gt;#queryTwoList.CODE_NAME#&lt;/A&gt;&lt;/td&gt;
	&lt;/cfloop&gt;
&lt;/tr&gt;
&lt;/cfoutput&gt;
&lt;/table&gt;
&lt;/code&gt;

Another solution would have been to create another variable on the first line after the CFOUTPUT with the value, and referencing it:

&lt;code&gt;
&lt;cfoutput QUERY=&quot;queryOneList&quot;&gt;
&lt;cfset theNameIs = queryOneList.MEDIUM_NAME&gt;
&lt;tr&gt;
	&lt;td&gt;#queryOneList.MEDIUM_NAME#&lt;/td&gt;
	&lt;td&gt;#queryOneList.MEDIUM_DESC#&lt;/td&gt;
	&lt;cfloop query=&quot;queryTwoList&quot;&gt;
	&lt;td&gt;&lt;A href=&quot;xyz.cfm?mn=#theNameIs#&amp;code=#queryTwoList.CODE#&quot;&gt;#queryTwoList.CODE_NAME#&lt;/A&gt;&lt;/td&gt;
	&lt;/cfloop&gt;
&lt;/tr&gt;
&lt;/cfoutput&gt;
&lt;/table&gt;
&lt;/code&gt;

Either way will work I guess, but I prefer the first method.  It&apos;s more pro in my opinion.
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Mon, 17 Dec 2007 15:26:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/12/17/CFLOOP-inside-of-a-CFOUTPUT</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Flex error : #2049 Security sandbox violation</title>
				<link>http://blog.garthe.com/index.cfm/2007/11/21/Flex-error--2049-Security-sandbox-violation</link>
				<description>
				
				I was having a problem today with a Flex app that uploads images using a coldfusion file.  The situation was that web users could hit this website using two separate domains (i.e. - myCoolSite.com vs. myKoolSite.com).

The application file had a variable that would specify the domain name, and I would build the ActionUrl for the Flex app using this domain name.  The Flex application would bomb (only in IE for some reason) when the action page url was not the same domain as the one they came in on (which the Flash SWF url was at).  Keep in mind that its the exact same site on the server.

The Flex error was #2049 Security sandbox violation: _ cannot upload data to....  This states the Url is bad.  Not so.  The app was just having problems using the url on a different domain.  So, I changed the code that builds the ActionUrl based on the current domain, and voila!  Problem solved.

Simple code to create ActionUrl is below:&lt;br&gt;

&lt;code&gt;
&lt;cfif cgi.https IS &quot;on&quot;&gt;
	&lt;cfset httpValue=&quot;https://&quot;&gt;
&lt;cfelse&gt;
	&lt;cfset httpValue=&quot;http://&quot;&gt;
&lt;/cfif&gt;
&lt;cfset uploadActionStringUrl = &quot;#httpValue##cgi.HTTP_HOST#/myFileContainingCFFILE.cfm&quot;&gt;
&lt;/code&gt;

Happy Turkey Day everyone!  Be safe.
				
				</description>
						
				
				<category>Flex</category>				
				
				<pubDate>Wed, 21 Nov 2007 10:41:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/11/21/Flex-error--2049-Security-sandbox-violation</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Creating a hierarchy list with Coldfusion</title>
				<link>http://blog.garthe.com/index.cfm/2007/10/26/Creating-a-hierarchy-list-with-Coldfusion</link>
				<description>
				
				I came across a stored procedure that returns data in the following format:

&lt;img src=&quot;http://blog.garthe.com/images//cfdumpImage.gif&quot;&gt;

The dilemma was how to display this so that each level was shown as a &quot;sublevel&quot; of the one above it.  I easily accomplished this by keeping a list of the current levels.  Each time a new level was added, I&apos;d add this value to the &quot;levelList&quot;.  When that level was ended, I&apos;d remove that value from &quot;levelList&quot;.  With this list, I would always know where I was.  I would be able to end each unordered list and start new ones where needed.
				 [More]
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Fri, 26 Oct 2007 17:16:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/10/26/Creating-a-hierarchy-list-with-Coldfusion</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Coldfusion query of queries with a reserved word in SQL</title>
				<link>http://blog.garthe.com/index.cfm/2007/10/26/Coldfusion-query-of-queries-with-a-reserved-word-in-SQL</link>
				<description>
				
				My client has a stored procedure that was returning a column named &quot;level&quot;.  While trying to execute a query of queries on the resultset, I ran into some issues because &quot;Level&quot; is a reserved word in T-SQL.  The stored proc simply returns a column aliased as &quot;level&quot;.  Its not actually that in the table, so this problem wasn&apos;t an issue previously.

I was going to change the stored procedure itself, but other applications rely on the naming structure already in place.  Any change would be a pain.

I was able to work with the query of queries by putting brackets around my reserved word column.  Now ColdFusion and Sql are quite happy!

&lt;code&gt;
&lt;cfquery dbtype=&quot;query&quot; name=&quot;shortenedQuery&quot;&gt;
	SELECT categoryName, [level], name
	FROM queryResults
&lt;/cfquery&gt;
&lt;/code&gt;
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<category>SQL</category>				
				
				<pubDate>Fri, 26 Oct 2007 15:33:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/10/26/Coldfusion-query-of-queries-with-a-reserved-word-in-SQL</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Checking for child node in xml document with coldfusion</title>
				<link>http://blog.garthe.com/index.cfm/2007/10/12/isDefined-for-xml-document-with-coldfusion</link>
				<description>
				
				Problem:&lt;br&gt;
The xml document I was trying to invoke would sometimes return child nodes, and sometimes not.  Since I would reference the values of the child nodes in my result set, I needed to first check to see if they existed.

isDefined doesn&apos;t work with Xml documents, and I didn&apos;t want to convert it to another object type just for that. I could have tried to reference the child node with a try/catch around it and if it broke, then I knew it didn&apos;t exist.  Thats a bit messy and more of a hack than I&apos;m comfortable with.

Solution:&lt;br&gt;
After a bit of searching, I remembered &quot;XmlChildPos&quot;.  It returns the location of the child node, and if no child is found, returns a &quot;-1&quot;!  Mission accomplished.

&lt;strong&gt;XmlChildPos(elem, childName, N)&lt;/strong&gt;

Here&apos;s an example xml document where one person has children, and another does not.

&lt;code&gt;
&lt;employees&gt;
	&lt;employee&gt;
		&lt;name&gt;Bob&lt;/name&gt;
		&lt;title&gt;Rock Star&lt;/title&gt;
		&lt;children&gt;3&lt;/children&gt;
	&lt;/employee&gt;
	&lt;employee&gt;
		&lt;name&gt;Tom&lt;/name&gt;
		&lt;title&gt;Accountant&lt;/title&gt;
	&lt;/employee&gt;
&lt;/employees&gt;
&lt;/code&gt;

Now, I don&apos;t know if this is properly formatted xml or what, but its being sent this way from a very, very big company who aren&apos;t going to change it.

So, I bring in the xml and store it in a variable called &quot;xmlResult&quot; that starts at the &quot;employees&quot; level.

I need to see if children exists for employee &quot;Tom&quot; and display the amount if it does.

&lt;code&gt;
&lt;cfset myXMLDoc = XMLParse(&quot;http://www.xmlUrl.com/xml.rss&quot;)&gt;
&lt;cfset xmlResult = XMLSearch(myXMLDoc, &quot;/employees&quot;)&gt;

&lt;cfloop from=&quot;1&quot; to=&quot;#arrayLen(XMLSearch(xmlResult, &apos;/employees&apos;))#&quot; index=&quot;i&quot;&gt;
&lt;cfif xmlChildPos(xmlResult[i].employee,&quot;children&quot;, 1) GT 0&gt;
	#xmlResult[i].employee.children#
&lt;/cfif&gt;
&lt;/cfloop&gt;
&lt;/code&gt;

Thats it.  Enjoy!
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Fri, 12 Oct 2007 22:24:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/10/12/isDefined-for-xml-document-with-coldfusion</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFLOOP inside of a CFLOOP</title>
				<link>http://blog.garthe.com/index.cfm/2007/10/4/CFLOOP-inside-of-a-CFLOOP</link>
				<description>
				
				I ran into a problem today and it turned out to be a simple naming conflict.

I had a loop that was looping through a session variable.  I had named the index &quot;i&quot;, which is my default loop index name.  Inside the loop was a structDelete command which wasn&apos;t working.

&lt;code&gt;
&lt;cfset maxValue = StructCount(session.formVars)&gt;
&lt;cfloop from=&quot;1&quot; to=&quot;#maxValue#&quot; index=&quot;i&quot;&gt;
	&lt;cfinclude template=&quot;act_ProcessFormVars.cfm&quot;&gt;

	&lt;cfset temp = structDelete(session.formVars,i)&gt;
&lt;/cfloop&gt;
&lt;/code&gt;

After a bit of looking, I dug into the included file &quot;act_ProcessFormVars.cfm&quot; and found that there was a loop within it, that also used &quot;i&quot; for an index.  This was causing a conflict and causing the variable &quot;i&quot; to be overwritten during each iteration of the loop.  &quot;i&quot; would literally become the last value plus one of the inside loop at the time for structDelete to execute.

Here&apos;s an example:

&lt;code&gt;
&lt;cfoutput&gt;
&lt;cfloop from=&quot;1&quot; to=&quot;3&quot; index=&quot;i&quot;&gt;
	first: #i#&lt;br&gt;
	&lt;cfloop from=&quot;1&quot; to=&quot;3&quot; index=&quot;i&quot;&gt;
	&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:#i#&lt;br&gt;
	&lt;/cfloop&gt;
	last: #i#&lt;br&gt;&lt;br&gt;
&lt;/cfloop&gt;
&lt;/cfoutput&gt;
&lt;/code&gt;

&quot;i&quot; in the above loop would become:

first: 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:3&lt;br&gt;
last: 4&lt;br&gt;

first: 2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:3&lt;br&gt;
last: 4&lt;br&gt;

first: 3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;inner:3&lt;br&gt;
last: 4&lt;br&gt;


The solution is to simply rename one of the two loop&apos;s indexing names (&quot;i&quot; to &quot;z&quot;), and there won&apos;t be any conflicts!
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Thu, 04 Oct 2007 13:25:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/10/4/CFLOOP-inside-of-a-CFLOOP</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Finding the last day of the month</title>
				<link>http://blog.garthe.com/index.cfm/2007/10/1/Finding-the-last-day-of-the-month</link>
				<description>
				
				Pretty simple equation to show the last day of a month. First, get the first day of next month.

&lt;code&gt;
&lt;cfset createdNextMonthDate = CreateDate(year(Now()),month(dateAdd(&apos;m&apos;,1,Now())),1)&gt;
&lt;/code&gt;

Then we&apos;ll simply subtract one day from that new date.

&lt;code&gt;
&lt;cfset lastDayOfMonthForAdStartDate = dateAdd(&apos;d&apos;,-1,createdNextMonthDate)&gt;
&lt;/code&gt;

You could put this all into one long line, but I split it up for easier readability.

If you want to set it up as a function, the pass in the date as &quot;datePassed&quot; to the following code, and you will get the last day in that month:

&lt;code&gt;
&lt;cffunction name=&quot;getLastDayOfMonth&quot; access=&quot;public&quot; returntype=&quot;date&quot;&gt;
&lt;cfargument name=&quot;datePassed&quot; type=&quot;date&quot; required=&quot;Yes&quot;&gt;

&lt;cfset createdNextMonthDate = CreateDate(year(arguments.datePassed),month(dateAdd(&apos;m&apos;,1,arguments.datePassed)),1)&gt;
&lt;cfset lastDayOfMonthForAdStartDate = dateAdd(&apos;d&apos;,-1,createdNextMonthDate)&gt;

&lt;cfreturn lastDayOfMonthForAdStartDate&gt;

&lt;/cffunction&gt;
&lt;/code&gt;
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Mon, 01 Oct 2007 14:05:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/10/1/Finding-the-last-day-of-the-month</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Creating an easier to read array/structure hybrid</title>
				<link>http://blog.garthe.com/index.cfm/2007/9/18/Creating-an-easier-to-read-arraystructure-hybrid</link>
				<description>
				
				Here&apos;s something I came across today that I had never realized or seen before.  I created a two dimensional array and filled it with data.

&lt;code&gt;
&lt;cfset myArray = ArrayNew(2)&gt;

&lt;cfset myArray[1][1] = &quot;Charles&quot;&gt;
&lt;cfset myArray[1][2] = &quot;President&quot;&gt;
&lt;cfset myArray[2][1] = &quot;Vicki&quot;&gt;
&lt;cfset myArray[2][2] = &quot;VP&quot;&gt;
&lt;cfset myArray[3][1] = &quot;Bob&quot;&gt;
&lt;cfset myArray[3][2] = &quot;Controller&quot;&gt;
&lt;cfset myArray[4][1] = &quot;David&quot;&gt;
&lt;cfset myArray[4][2] = &quot;Programmer&quot;&gt;
&lt;/code&gt;

Pretty much standard array practice, right?  Well, I started thinking that sometimes its hard to remember which dimension of the array stores what values.  So I started thinking about a more logical format I could use and came up with the following:

&lt;code&gt;
&lt;cfset myArray = ArrayNew(1)&gt;

&lt;cfset myArray[1][&quot;name&quot;] = &quot;Charles&quot;&gt;
&lt;cfset myArray[1][&quot;title&quot;] = &quot;President&quot;&gt;
&lt;cfset myArray[2][&quot;name&quot;] = &quot;Vicki&quot;&gt;
&lt;cfset myArray[2][&quot;title&quot;] = &quot;VP&quot;&gt;
&lt;cfset myArray[3][&quot;name&quot;] = &quot;Bob&quot;&gt;
&lt;cfset myArray[3][&quot;title&quot;] = &quot;Controller&quot;&gt;
&lt;cfset myArray[4][&quot;name&quot;] = &quot;David&quot;&gt;
&lt;cfset myArray[4][&quot;title&quot;] = &quot;Programmer&quot;&gt;
&lt;/code&gt;

Now each value in the array is holding a structure with two values, name and title.  I personally find this to be better and allows for easier readability.

To display all values, all I have to do is:

&lt;code&gt;
&lt;cfoutput&gt;
	&lt;cfloop from=&quot;1&quot; to=&quot;arrayLen(myArray)&quot; index=&quot;i&quot;&gt;
		Name: #myArray[i].name#&lt;br&gt;
		Title: #myArray[i].title#&lt;br&gt;
	&lt;/cfloop&gt;
&lt;/cfoutput&gt;
&lt;/code&gt;

For me, its a little easier to read.
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Tue, 18 Sep 2007 20:34:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/9/18/Creating-an-easier-to-read-arraystructure-hybrid</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>onAIR Bus Tour Summer 2007</title>
				<link>http://blog.garthe.com/index.cfm/2007/8/16/onAIR-Bus-Tour-Summer-2007</link>
				<description>
				
				Last night I went to Adobe&apos;s presentation of AIR - Adobe Integrated Runtime.  I have to tell you, it was great going, and I&apos;m very excited to see what new apps I can develop.

Oh, and I met Ben Forta as well.  Very cool guy.  He basically got me started with coldFusion 10 years ago when I bought his first CFWACK book.  Thanks Ben.

&lt;a href=&quot;http://www.adobe.com/go/air&quot;&gt;http://www.adobe.com/go/air&lt;/a&gt;
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<category>AIR</category>				
				
				<pubDate>Thu, 16 Aug 2007 18:12:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/8/16/onAIR-Bus-Tour-Summer-2007</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>StructAppend, form variables, and the GET method</title>
				<link>http://blog.garthe.com/index.cfm/2007/8/14/StructAppend-form-variables-and-the-GET-method</link>
				<description>
				
				I made a very silly mistake today.  I was putting my url and form variables into the request scope through the application.cfm file

&lt;code&gt;
&lt;cfset StructAppend(request, url, &quot;no&quot;)&gt;
&lt;cfset StructAppend(request, form, &quot;no&quot;)&gt;
&lt;/code&gt;

Next I had a form page, which was using the GET method to post the form (simplified below).

&lt;code&gt;
&lt;form action=&quot;formAction.cfm&quot; method=&quot;GET&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;reportId&quot; value=&quot;#url.reportId#&quot;&gt;
&lt;textarea cols=&quot;40&quot; rows=&quot;3&quot; name=&quot;reportComment&quot;&gt;&lt;/textarea&gt;
&lt;input type=&quot;submit&quot; value=&quot;Add Comment&quot;&gt;
&lt;/form&gt;
&lt;/code&gt;

On the form action page, I was referencing form.reportId, and it was bombing since it did not exist.  In fact, the form scope did not exist at all!  The values existed in the request scope, so what happened?  Did the StructAppend call removes the form scope after it appended it to the request scope?  After about five minutes, I remembered that the GET method of posting a form passes all variables through the URL string rather than a form scope.

My mistake was easily fixed by changing the form method to POST, or by simply referencing the REQUEST scope, which I should have been doing in the first place!

Silly mistake.  I&apos;m glad nobody knows I did that.
				
				</description>
						
				
				<category>coldFusion</category>				
				
				<pubDate>Tue, 14 Aug 2007 10:23:00-0500</pubDate>
				<guid>http://blog.garthe.com/index.cfm/2007/8/14/StructAppend-form-variables-and-the-GET-method</guid>
				
			</item>
			
		 	
			</channel></rss>
