Stephen Lloyd

Software Engineer

8/15/17User Group Meeting

Thank you so much for taking the time out to meet at our inaugural Seattle ColdFusion User Group meeting. As promised, here is the link to the slide deck for our meeting: http://bit.ly/2uo0CHI.

  • Test your Code Live using Online services
  • Overview of various frameworks
  • List of Resources
4/7/15CFC's / Custom Tags / User Defined Functions
  • http://stackoverflow.com/questions/648674/how-do-you-decide-what-to-use-udf-or-custom-tag
  • http://www.careerride.com/view.aspx?id=2382
ColdFusion Component (CFC's)
  • Multiple entry points are available for CFC
  • CFC does support formalized parameter passing and validation mechanism
  • Persistence is possible for CFC
  • CFCs can be accessed as web services
Custom Tags
  • A single entry point is available for custom tags
  • Custom tags does not support formalized parameter passing and validation mechanism
  • Persistence is not possible for custom tags
  • Custom tags are accessible locally and only by ColdFusion
User Defined Functions
If what you need to do involves output to the screen, and if it makes sense to "wrap" this around some other code or text, then a custom tag might be in order. In all other cases a UDF works fine and generally better. That being said, in close to 8 years of CF development, I really haven't ever came across a very good reason for a custom tag. I'm not saying the reasons don't exist, but I would say that they are rare.
7/1/13cfScript Dump

Inside the script:
<cfscript>
  MyDump(thevariable);
</cfscript>

Outside the script:
<cffunction name="MyDump">
  <cfargument name="OBJ" required="yes">
  <cfdump var="#OBJ#"><cfabort>
</cffunction>

3/22/10File Extension Code

<cfset variables.myfile = "TA_H264_768kbit_Widescreen.mov" />
<cfset variables.filepath = ExpandPath('video\') & variables.myfile />

<cfswitch expression="#LCase(ListLast(variables.myfile, "."))#">
<cfcase value="avi">
<cfset variables.contentType = "video/x-msvideo" />
</cfcase>
<cfcase value="doc">
<cfset variables.contentType = "application/msword" />
</cfcase>
<cfcase value="exe">
<cfset variables.contentType = "application/octet-stream" />
</cfcase>
<cfcase value="gif">
<cfset variables.contentType = "image/gif" />
</cfcase>
<cfcase value="jpg,jpeg">
<cfset variables.contentType = "image/jpg" />
</cfcase>
<cfcase value="mp3">
<cfset variables.contentType = "audio/mpeg" />
</cfcase>
<cfcase value="mov">
<cfset variables.contentType = "video/quicktime" />
</cfcase>
<cfcase value="mpe,mpg,mpeg">
<cfset variables.contentType = "video/mpeg" />
</cfcase>
<cfcase value="pdf">
<cfset variables.contentType = "application/pdf" />
</cfcase>
<cfcase value="png">
<cfset variables.contentType = "image/png" />
</cfcase>
<cfcase value="ppt">
<cfset variables.contentType = "application/vnd.ms-powerpoint" />
</cfcase>
<cfcase value="wav">
<cfset variables.contentType = "audio/x-wav" />
</cfcase>
<cfcase value="xls">
<cfset variables.contentType = "application/vnd.ms-excel" />
</cfcase>
<cfcase value="zip">
<cfset variables.contentType = "application/zip" />
</cfcase>
<cfdefaultcase>
<cfset variables.contentType = "application/unknown" />
</cfdefaultcase>
</cfswitch>

<cfheader name="Content-disposition" value="attachment;filename=#variables.myfile#" />
<cfcontent type="#variables.contentType#" file="#variables.filepath#" />

 


Stephen Lloyd 05/03/2018